diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 20:47:32 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 20:47:32 +0000 |
commit | 3560b57722a5ffa93777c522456e8348b30c82b9 (patch) | |
tree | 1d435978ca0b2fdd2b5442e6807dd7cc45a17dc9 /content/shell | |
parent | 14e236c0297efef5d22b44c233f5cefc3ca9b532 (diff) | |
download | chromium_src-3560b57722a5ffa93777c522456e8348b30c82b9.zip chromium_src-3560b57722a5ffa93777c522456e8348b30c82b9.tar.gz chromium_src-3560b57722a5ffa93777c522456e8348b30c82b9.tar.bz2 |
Mac content shell: Fix new browser window.
This is a revert of most of r130140, and a better re-implementation thereof.
BUG=120153
TEST=as described
Review URL: https://chromiumcodereview.appspot.com/9982011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r-- | content/shell/shell_application_mac.mm | 6 | ||||
-rw-r--r-- | content/shell/shell_browser_context.cc | 9 | ||||
-rw-r--r-- | content/shell/shell_browser_context.h | 11 | ||||
-rw-r--r-- | content/shell/shell_browser_main_parts.cc | 7 | ||||
-rw-r--r-- | content/shell/shell_browser_main_parts.h | 4 | ||||
-rw-r--r-- | content/shell/shell_content_browser_client.cc | 3 |
6 files changed, 24 insertions, 16 deletions
diff --git a/content/shell/shell_application_mac.mm b/content/shell/shell_application_mac.mm index 3afb7a6..0ccce07 100644 --- a/content/shell/shell_application_mac.mm +++ b/content/shell/shell_application_mac.mm @@ -7,6 +7,7 @@ #include "base/auto_reset.h" #include "content/shell/shell.h" #include "content/shell/shell_browser_context.h" +#include "content/shell/shell_content_browser_client.h" #include "googleurl/src/gurl.h" @implementation ShellCrApplication @@ -25,7 +26,10 @@ } - (IBAction)newDocument:(id)sender { - content::Shell::CreateNewWindow(content::ShellBrowserContext::GetInstance(), + content::ShellBrowserContext* browserContext = + static_cast<content::ShellContentBrowserClient*>( + content::GetContentClient()->browser())->browser_context(); + content::Shell::CreateNewWindow(browserContext, GURL("about:blank"), NULL, MSG_ROUTING_NONE, diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index dbf6445..4765860 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -14,6 +14,7 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/geolocation_permission_context.h" #include "content/public/browser/speech_recognition_preferences.h" +#include "content/shell/shell_browser_main_parts.h" #include "content/shell/shell_download_manager_delegate.h" #include "content/shell/shell_resource_context.h" #include "content/shell/shell_url_request_context_getter.h" @@ -83,11 +84,9 @@ class ShellSpeechRecognitionPreferences : public SpeechRecognitionPreferences { } // namespace -ShellBrowserContext* ShellBrowserContext::GetInstance() { - return Singleton<ShellBrowserContext>::get(); -} - -ShellBrowserContext::ShellBrowserContext() { +ShellBrowserContext::ShellBrowserContext( + ShellBrowserMainParts* shell_main_parts) + : shell_main_parts_(shell_main_parts) { InitWhileIOAllowed(); } diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index 5dcf9b14..11220b0 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -10,7 +10,6 @@ #include "base/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/memory/singleton.h" #include "content/public/browser/browser_context.h" class DownloadManager; @@ -19,11 +18,13 @@ namespace content { class DownloadManagerDelegate; class ResourceContext; +class ShellBrowserMainParts; class ShellDownloadManagerDelegate; class ShellBrowserContext : public BrowserContext { public: - static ShellBrowserContext* GetInstance(); + explicit ShellBrowserContext(ShellBrowserMainParts* shell_main_parts); + virtual ~ShellBrowserContext(); // BrowserContext implementation. virtual FilePath GetPath() OVERRIDE; @@ -42,10 +43,6 @@ class ShellBrowserContext : public BrowserContext { virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; private: - ShellBrowserContext(); - virtual ~ShellBrowserContext(); - friend struct DefaultSingletonTraits<ShellBrowserContext>; - // Performs initialization of the ShellBrowserContext while IO is still // allowed on the current thread. void InitWhileIOAllowed(); @@ -58,6 +55,8 @@ class ShellBrowserContext : public BrowserContext { scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; scoped_refptr<SpeechRecognitionPreferences> speech_recognition_preferences_; + ShellBrowserMainParts* shell_main_parts_; + DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext); }; diff --git a/content/shell/shell_browser_main_parts.cc b/content/shell/shell_browser_main_parts.cc index a47c849..272b944 100644 --- a/content/shell/shell_browser_main_parts.cc +++ b/content/shell/shell_browser_main_parts.cc @@ -58,6 +58,8 @@ int ShellBrowserMainParts::PreCreateThreads() { } void ShellBrowserMainParts::PreMainMessageLoopRun() { + browser_context_.reset(new ShellBrowserContext(this)); + Shell::PlatformInitialize(); net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); @@ -69,14 +71,14 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { devtools_delegate_ = new ShellDevToolsDelegate( port, - ShellBrowserContext::GetInstance()->GetRequestContext()); + browser_context_->GetRequestContext()); } else { DLOG(WARNING) << "Invalid http debugger port number " << port; } } if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { - Shell::CreateNewWindow(ShellBrowserContext::GetInstance(), + Shell::CreateNewWindow(browser_context_.get(), GetStartupURL(), NULL, MSG_ROUTING_NONE, @@ -87,6 +89,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { void ShellBrowserMainParts::PostMainMessageLoopRun() { if (devtools_delegate_) devtools_delegate_->Stop(); + browser_context_.reset(); } bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { diff --git a/content/shell/shell_browser_main_parts.h b/content/shell/shell_browser_main_parts.h index b643807..2476747 100644 --- a/content/shell/shell_browser_main_parts.h +++ b/content/shell/shell_browser_main_parts.h @@ -44,7 +44,11 @@ class ShellBrowserMainParts : public BrowserMainParts { ui::Clipboard* GetClipboard(); ShellDevToolsDelegate* devtools_delegate() { return devtools_delegate_; } + ShellBrowserContext* browser_context() { return browser_context_.get(); } + private: + scoped_ptr<ShellBrowserContext> browser_context_; + scoped_ptr<ui::Clipboard> clipboard_; ShellDevToolsDelegate* devtools_delegate_; diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc index ae06ea7..588e002 100644 --- a/content/shell/shell_content_browser_client.cc +++ b/content/shell/shell_content_browser_client.cc @@ -7,7 +7,6 @@ #include "base/command_line.h" #include "base/file_path.h" #include "content/shell/shell.h" -#include "content/shell/shell_browser_context.h" #include "content/shell/shell_browser_main_parts.h" #include "content/shell/shell_devtools_delegate.h" #include "content/shell/shell_render_view_host_observer.h" @@ -349,7 +348,7 @@ crypto::CryptoModuleBlockingPasswordDelegate* #endif ShellBrowserContext* ShellContentBrowserClient::browser_context() { - return ShellBrowserContext::GetInstance(); + return shell_browser_main_parts_->browser_context(); } } // namespace content |