Allow embedders to provide their own BrowserContext implementation

This commit is contained in:
Adam Roben 2013-04-01 20:10:00 -04:00
parent 080d9f59e9
commit 3cef0dd98c
2 changed files with 9 additions and 1 deletions

View file

@ -21,7 +21,7 @@ BrowserMainParts::~BrowserMainParts() {
} }
void BrowserMainParts::PreMainMessageLoopRun() { void BrowserMainParts::PreMainMessageLoopRun() {
browser_context_.reset(new BrowserContext); browser_context_.reset(CreateBrowserContext());
// These two objects are owned by devtools_http_handler_. // These two objects are owned by devtools_http_handler_.
auto delegate = new DevToolsDelegate; auto delegate = new DevToolsDelegate;
@ -30,4 +30,8 @@ void BrowserMainParts::PreMainMessageLoopRun() {
devtools_http_handler_ = content::DevToolsHttpHandler::Start(factory, std::string(), delegate); devtools_http_handler_ = content::DevToolsHttpHandler::Start(factory, std::string(), delegate);
} }
BrowserContext* BrowserMainParts::CreateBrowserContext() {
return new BrowserContext;
}
} }

View file

@ -26,6 +26,10 @@ public:
content::DevToolsHttpHandler* devtools_http_handler() { return devtools_http_handler_; } content::DevToolsHttpHandler* devtools_http_handler() { return devtools_http_handler_; }
protected: protected:
// Subclasses should override this to provide their own BrowserContxt implementation. The caller
// takes ownership of the returned object.
virtual BrowserContext* CreateBrowserContext();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
virtual void PreMainMessageLoopStart() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE;
#endif #endif