summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/shell/shell_application_mac.h2
-rw-r--r--content/shell/shell_application_mac.mm11
-rw-r--r--content/shell/shell_browser_context.cc9
-rw-r--r--content/shell/shell_browser_context.h11
-rw-r--r--content/shell/shell_browser_main_parts.cc7
-rw-r--r--content/shell/shell_browser_main_parts.h4
-rw-r--r--content/shell/shell_content_browser_client.cc3
7 files changed, 28 insertions, 19 deletions
diff --git a/content/shell/shell_application_mac.h b/content/shell/shell_application_mac.h
index 3450ff3..88b8d9e 100644
--- a/content/shell/shell_application_mac.h
+++ b/content/shell/shell_application_mac.h
@@ -20,6 +20,8 @@
// CrAppControlProtocol:
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
+- (IBAction)newDocument:(id)sender;
+
@end
#endif // CONTENT_SHELL_SHELL_APPLICATION_MAC_H_
diff --git a/content/shell/shell_application_mac.mm b/content/shell/shell_application_mac.mm
index c8a6163..3afb7a6 100644
--- a/content/shell/shell_application_mac.mm
+++ b/content/shell/shell_application_mac.mm
@@ -5,6 +5,9 @@
#include "content/shell/shell_application_mac.h"
#include "base/auto_reset.h"
+#include "content/shell/shell.h"
+#include "content/shell/shell_browser_context.h"
+#include "googleurl/src/gurl.h"
@implementation ShellCrApplication
@@ -21,4 +24,12 @@
handlingSendEvent_ = handlingSendEvent;
}
+- (IBAction)newDocument:(id)sender {
+ content::Shell::CreateNewWindow(content::ShellBrowserContext::GetInstance(),
+ GURL("about:blank"),
+ NULL,
+ MSG_ROUTING_NONE,
+ NULL);
+}
+
@end
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
index 4765860..dbf6445 100644
--- a/content/shell/shell_browser_context.cc
+++ b/content/shell/shell_browser_context.cc
@@ -14,7 +14,6 @@
#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"
@@ -84,9 +83,11 @@ class ShellSpeechRecognitionPreferences : public SpeechRecognitionPreferences {
} // namespace
-ShellBrowserContext::ShellBrowserContext(
- ShellBrowserMainParts* shell_main_parts)
- : shell_main_parts_(shell_main_parts) {
+ShellBrowserContext* ShellBrowserContext::GetInstance() {
+ return Singleton<ShellBrowserContext>::get();
+}
+
+ShellBrowserContext::ShellBrowserContext() {
InitWhileIOAllowed();
}
diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h
index 11220b0..5dcf9b14 100644
--- a/content/shell/shell_browser_context.h
+++ b/content/shell/shell_browser_context.h
@@ -10,6 +10,7 @@
#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;
@@ -18,13 +19,11 @@ namespace content {
class DownloadManagerDelegate;
class ResourceContext;
-class ShellBrowserMainParts;
class ShellDownloadManagerDelegate;
class ShellBrowserContext : public BrowserContext {
public:
- explicit ShellBrowserContext(ShellBrowserMainParts* shell_main_parts);
- virtual ~ShellBrowserContext();
+ static ShellBrowserContext* GetInstance();
// BrowserContext implementation.
virtual FilePath GetPath() OVERRIDE;
@@ -43,6 +42,10 @@ 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();
@@ -55,8 +58,6 @@ 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 272b944..a47c849 100644
--- a/content/shell/shell_browser_main_parts.cc
+++ b/content/shell/shell_browser_main_parts.cc
@@ -58,8 +58,6 @@ int ShellBrowserMainParts::PreCreateThreads() {
}
void ShellBrowserMainParts::PreMainMessageLoopRun() {
- browser_context_.reset(new ShellBrowserContext(this));
-
Shell::PlatformInitialize();
net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider);
@@ -71,14 +69,14 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) {
devtools_delegate_ = new ShellDevToolsDelegate(
port,
- browser_context_->GetRequestContext());
+ ShellBrowserContext::GetInstance()->GetRequestContext());
} else {
DLOG(WARNING) << "Invalid http debugger port number " << port;
}
}
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
- Shell::CreateNewWindow(browser_context_.get(),
+ Shell::CreateNewWindow(ShellBrowserContext::GetInstance(),
GetStartupURL(),
NULL,
MSG_ROUTING_NONE,
@@ -89,7 +87,6 @@ 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 2476747..b643807 100644
--- a/content/shell/shell_browser_main_parts.h
+++ b/content/shell/shell_browser_main_parts.h
@@ -44,11 +44,7 @@ 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 588e002..ae06ea7 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -7,6 +7,7 @@
#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"
@@ -348,7 +349,7 @@ crypto::CryptoModuleBlockingPasswordDelegate*
#endif
ShellBrowserContext* ShellContentBrowserClient::browser_context() {
- return shell_browser_main_parts_->browser_context();
+ return ShellBrowserContext::GetInstance();
}
} // namespace content