summaryrefslogtreecommitdiffstats
path: root/ash/shell
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 21:32:48 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 21:32:48 +0000
commitfa4a458315fa15f2077a63ce3f5578bc499655be (patch)
treee208c18768533bf3260cd8c03d916953e5e7dce0 /ash/shell
parentd78e2b28e27bafe18efbfd2caeac68fbf7ef0f75 (diff)
downloadchromium_src-fa4a458315fa15f2077a63ce3f5578bc499655be.zip
chromium_src-fa4a458315fa15f2077a63ce3f5578bc499655be.tar.gz
chromium_src-fa4a458315fa15f2077a63ce3f5578bc499655be.tar.bz2
Support WebView in ash.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10054038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shell')
-rw-r--r--ash/shell/DEPS4
-rw-r--r--ash/shell/app_list.cc3
-rw-r--r--ash/shell/content_client/DEPS3
-rw-r--r--ash/shell/content_client/shell_browser_main_parts.cc120
-rw-r--r--ash/shell/content_client/shell_browser_main_parts.h77
-rw-r--r--ash/shell/content_client/shell_content_browser_client.cc373
-rw-r--r--ash/shell/content_client/shell_content_browser_client.h210
-rw-r--r--ash/shell/content_client/shell_main_delegate.cc108
-rw-r--r--ash/shell/content_client/shell_main_delegate.h64
-rw-r--r--ash/shell/shell_main.cc118
-rw-r--r--ash/shell/window_type_launcher.cc5
11 files changed, 984 insertions, 101 deletions
diff --git a/ash/shell/DEPS b/ash/shell/DEPS
new file mode 100644
index 0000000..24f7ff1
--- /dev/null
+++ b/ash/shell/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+content",
+ "+sandbox",
+]
diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc
index 19f4336..2e4fd77 100644
--- a/ash/shell/app_list.cc
+++ b/ash/shell/app_list.cc
@@ -92,7 +92,8 @@ class WindowTypeLauncherItem : public ash::AppListItemModel {
case EXAMPLES_WINDOW: {
#if !defined(OS_MACOSX)
views::examples::ShowExamplesWindow(
- views::examples::DO_NOTHING_ON_CLOSE, NULL);
+ views::examples::DO_NOTHING_ON_CLOSE,
+ ash::Shell::GetInstance()->browser_context());
#endif
break;
}
diff --git a/ash/shell/content_client/DEPS b/ash/shell/content_client/DEPS
new file mode 100644
index 0000000..60dbcf4
--- /dev/null
+++ b/ash/shell/content_client/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+content",
+]
diff --git a/ash/shell/content_client/shell_browser_main_parts.cc b/ash/shell/content_client/shell_browser_main_parts.cc
new file mode 100644
index 0000000..2aaaed2
--- /dev/null
+++ b/ash/shell/content_client/shell_browser_main_parts.cc
@@ -0,0 +1,120 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/shell/content_client/shell_browser_main_parts.h"
+
+#include "ash/shell/shell_delegate_impl.h"
+#include "ash/shell/window_watcher.h"
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/i18n/icu_util.h"
+#include "base/message_loop.h"
+#include "base/string_number_conversions.h"
+#include "base/threading/thread.h"
+#include "base/threading/thread_restrictions.h"
+#include "content/public/common/content_switches.h"
+#include "content/shell/shell.h"
+#include "content/shell/shell_browser_context.h"
+#include "content/shell/shell_devtools_delegate.h"
+#include "content/shell/shell_switches.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/net_module.h"
+#include "ui/aura/client/stacking_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/base/clipboard/clipboard.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/test/compositor_test_support.h"
+#include "ui/views/test/test_views_delegate.h"
+#include "ui/views/focus/accelerator_handler.h"
+
+namespace ash {
+namespace shell {
+void InitWindowTypeLauncher();
+
+namespace {
+class ShellViewsDelegate : public views::TestViewsDelegate {
+ public:
+ ShellViewsDelegate() {}
+ virtual ~ShellViewsDelegate() {}
+
+ // Overridden from views::TestViewsDelegate:
+ virtual views::NonClientFrameView* CreateDefaultNonClientFrameView(
+ views::Widget* widget) OVERRIDE {
+ return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(widget);
+ }
+ bool UseTransparentWindows() const OVERRIDE {
+ // Ash uses transparent window frames.
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate);
+};
+
+} // namespace
+
+ShellBrowserMainParts::ShellBrowserMainParts(
+ const content::MainFunctionParams& parameters)
+ : BrowserMainParts(),
+ devtools_delegate_(NULL) {
+}
+
+ShellBrowserMainParts::~ShellBrowserMainParts() {
+}
+
+#if !defined(OS_MACOSX)
+void ShellBrowserMainParts::PreMainMessageLoopStart() {
+}
+#endif
+
+int ShellBrowserMainParts::PreCreateThreads() {
+ return 0;
+}
+
+void ShellBrowserMainParts::PreMainMessageLoopRun() {
+ browser_context_.reset(new content::ShellBrowserContext);
+
+ // A ViewsDelegate is required.
+ if (!views::ViewsDelegate::views_delegate)
+ views::ViewsDelegate::views_delegate = new ShellViewsDelegate;
+
+ ash::shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl;
+ ash::Shell::CreateInstance(delegate);
+ ash::Shell::GetInstance()->set_browser_context(browser_context_.get());
+
+ window_watcher_.reset(new ash::shell::WindowWatcher);
+ delegate->SetWatcher(window_watcher_.get());
+
+ ash::shell::InitWindowTypeLauncher();
+
+ ash::Shell::GetRootWindow()->ShowRootWindow();
+}
+
+void ShellBrowserMainParts::PostMainMessageLoopRun() {
+ if (devtools_delegate_)
+ devtools_delegate_->Stop();
+ browser_context_.reset();
+
+ window_watcher_.reset();
+ ash::Shell::DeleteInstance();
+ aura::Env::DeleteInstance();
+}
+
+bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
+ MessageLoopForUI::current()->Run();
+ return true;
+}
+
+ui::Clipboard* ShellBrowserMainParts::GetClipboard() {
+ if (!clipboard_.get())
+ clipboard_.reset(new ui::Clipboard());
+ return clipboard_.get();
+}
+
+} // namespace shell
+} // namespace ash
diff --git a/ash/shell/content_client/shell_browser_main_parts.h b/ash/shell/content_client/shell_browser_main_parts.h
new file mode 100644
index 0000000..7a0496b
--- /dev/null
+++ b/ash/shell/content_client/shell_browser_main_parts.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SHELL_CONTENT_CLIENT_EXAMPLES_BROWSER_MAIN_PARTS_H_
+#define ASH_SHELL_CONTENT_CLIENT_EXAMPLES_BROWSER_MAIN_PARTS_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/browser_main_parts.h"
+
+namespace base {
+class Thread;
+}
+
+namespace ui {
+class Clipboard;
+}
+
+namespace content {
+class ShellBrowserContext;
+class ShellDevToolsDelegate;
+struct MainFunctionParams;
+}
+
+namespace views {
+class ViewsDelegate;
+}
+
+namespace ash {
+namespace shell {
+
+class WindowWatcher;
+
+class ShellBrowserMainParts : public content::BrowserMainParts {
+ public:
+ explicit ShellBrowserMainParts(
+ const content::MainFunctionParams& parameters);
+ virtual ~ShellBrowserMainParts();
+
+ // Overridden from content::BrowserMainParts:
+ virtual void PreEarlyInitialization() OVERRIDE {}
+ virtual void PostEarlyInitialization() OVERRIDE {}
+ virtual void PreMainMessageLoopStart() OVERRIDE;
+ virtual void PostMainMessageLoopStart() OVERRIDE {}
+ virtual void ToolkitInitialized() OVERRIDE {}
+ virtual int PreCreateThreads() OVERRIDE;
+ virtual void PreMainMessageLoopRun() OVERRIDE;
+ virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
+ virtual void PostMainMessageLoopRun() OVERRIDE;
+ virtual void PostDestroyThreads() OVERRIDE {}
+
+ ui::Clipboard* GetClipboard();
+ content::ShellDevToolsDelegate* devtools_delegate() {
+ return devtools_delegate_;
+ }
+
+ content::ShellBrowserContext* browser_context() {
+ return browser_context_.get();
+ }
+
+ private:
+ scoped_ptr<content::ShellBrowserContext> browser_context_;
+
+ scoped_ptr<ui::Clipboard> clipboard_;
+ content::ShellDevToolsDelegate* devtools_delegate_;
+ scoped_ptr<views::ViewsDelegate> views_delegate_;
+ scoped_ptr<ash::shell::WindowWatcher> window_watcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
+};
+
+} // namespace shell
+} // namespace ash
+
+#endif // ASH_SHELL_CONTENT_CLIENT_EXAMPLES_BROWSER_MAIN_PARTS_H_
diff --git a/ash/shell/content_client/shell_content_browser_client.cc b/ash/shell/content_client/shell_content_browser_client.cc
new file mode 100644
index 0000000..bae0eb5
--- /dev/null
+++ b/ash/shell/content_client/shell_content_browser_client.cc
@@ -0,0 +1,373 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/shell/content_client/shell_content_browser_client.h"
+
+#include "ash/shell/content_client/shell_browser_main_parts.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/shell/shell.h"
+#include "content/shell/shell_devtools_delegate.h"
+#include "content/shell/shell_render_view_host_observer.h"
+#include "content/shell/shell_resource_dispatcher_host_delegate.h"
+#include "content/shell/shell_switches.h"
+#include "googleurl/src/gurl.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace ash {
+namespace shell {
+
+ShellContentBrowserClient::ShellContentBrowserClient()
+ : shell_browser_main_parts_(NULL) {
+}
+
+ShellContentBrowserClient::~ShellContentBrowserClient() {
+}
+
+content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
+ const content::MainFunctionParams& parameters) {
+ shell_browser_main_parts_ = new ShellBrowserMainParts(parameters);
+ return shell_browser_main_parts_;
+}
+
+content::WebContentsView*
+ ShellContentBrowserClient::OverrideCreateWebContentsView(
+ content::WebContents* web_contents) {
+ return NULL;
+}
+
+content::WebContentsViewDelegate*
+ ShellContentBrowserClient::GetWebContentsViewDelegate(
+ content::WebContents* web_contents) {
+ return NULL;
+}
+
+void ShellContentBrowserClient::RenderViewHostCreated(
+ content::RenderViewHost* render_view_host) {
+ new content::ShellRenderViewHostObserver(render_view_host);
+}
+
+void ShellContentBrowserClient::RenderProcessHostCreated(
+ content::RenderProcessHost* host) {
+}
+
+content::WebUIControllerFactory*
+ ShellContentBrowserClient::GetWebUIControllerFactory() {
+ return NULL;
+}
+
+GURL ShellContentBrowserClient::GetEffectiveURL(
+ content::BrowserContext* browser_context, const GURL& url) {
+ return GURL();
+}
+
+bool ShellContentBrowserClient::ShouldUseProcessPerSite(
+ content::BrowserContext* browser_context, const GURL& effective_url) {
+ return false;
+}
+
+bool ShellContentBrowserClient::IsHandledURL(const GURL& url) {
+ return false;
+}
+
+bool ShellContentBrowserClient::IsSuitableHost(
+ content::RenderProcessHost* process_host,
+ const GURL& site_url) {
+ return true;
+}
+
+bool ShellContentBrowserClient::ShouldTryToUseExistingProcessHost(
+ content::BrowserContext* browser_context, const GURL& url) {
+ return false;
+}
+
+void ShellContentBrowserClient::SiteInstanceGotProcess(
+ content::SiteInstance* site_instance) {
+}
+
+void ShellContentBrowserClient::SiteInstanceDeleting(
+ content::SiteInstance* site_instance) {
+}
+
+bool ShellContentBrowserClient::ShouldSwapProcessesForNavigation(
+ const GURL& current_url,
+ const GURL& new_url) {
+ return false;
+}
+
+std::string ShellContentBrowserClient::GetCanonicalEncodingNameByAliasName(
+ const std::string& alias_name) {
+ return std::string();
+}
+
+void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
+ CommandLine* command_line, int child_process_id) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
+ command_line->AppendSwitch(switches::kDumpRenderTree);
+}
+
+std::string ShellContentBrowserClient::GetApplicationLocale() {
+ return std::string();
+}
+
+std::string ShellContentBrowserClient::GetAcceptLangs(
+ content::BrowserContext* context) {
+ return std::string();
+}
+
+SkBitmap* ShellContentBrowserClient::GetDefaultFavicon() {
+ static SkBitmap empty;
+ return &empty;
+}
+
+bool ShellContentBrowserClient::AllowAppCache(
+ const GURL& manifest_url,
+ const GURL& first_party,
+ content::ResourceContext* context) {
+ return true;
+}
+
+bool ShellContentBrowserClient::AllowGetCookie(
+ const GURL& url,
+ const GURL& first_party,
+ const net::CookieList& cookie_list,
+ content::ResourceContext* context,
+ int render_process_id,
+ int render_view_id) {
+ return true;
+}
+
+bool ShellContentBrowserClient::AllowSetCookie(
+ const GURL& url,
+ const GURL& first_party,
+ const std::string& cookie_line,
+ content::ResourceContext* context,
+ int render_process_id,
+ int render_view_id,
+ net::CookieOptions* options) {
+ return true;
+}
+
+bool ShellContentBrowserClient::AllowSaveLocalState(
+ content::ResourceContext* context) {
+ return true;
+}
+
+bool ShellContentBrowserClient::AllowWorkerDatabase(
+ const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ content::ResourceContext* context,
+ const std::vector<std::pair<int, int> >& render_views) {
+ return true;
+}
+
+bool ShellContentBrowserClient::AllowWorkerFileSystem(
+ const GURL& url,
+ content::ResourceContext* context,
+ const std::vector<std::pair<int, int> >& render_views) {
+ return true;
+}
+
+bool ShellContentBrowserClient::AllowWorkerIndexedDB(
+ const GURL& url,
+ const string16& name,
+ content::ResourceContext* context,
+ const std::vector<std::pair<int, int> >& render_views) {
+ return true;
+}
+
+content::QuotaPermissionContext*
+ ShellContentBrowserClient::CreateQuotaPermissionContext() {
+ return NULL;
+}
+
+net::URLRequestContext*
+ ShellContentBrowserClient::OverrideRequestContextForURL(
+ const GURL& url, content::ResourceContext* context) {
+ return NULL;
+}
+
+void ShellContentBrowserClient::OpenItem(const FilePath& path) {
+}
+
+void ShellContentBrowserClient::ShowItemInFolder(const FilePath& path) {
+}
+
+void ShellContentBrowserClient::AllowCertificateError(
+ int render_process_id,
+ int render_view_id,
+ int cert_error,
+ const net::SSLInfo& ssl_info,
+ const GURL& request_url,
+ bool overridable,
+ const base::Callback<void(bool)>& callback,
+ bool* cancel_request) {
+}
+
+void ShellContentBrowserClient::SelectClientCertificate(
+ int render_process_id,
+ int render_view_id,
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) {
+}
+
+void ShellContentBrowserClient::AddNewCertificate(
+ net::URLRequest* request,
+ net::X509Certificate* cert,
+ int render_process_id,
+ int render_view_id) {
+}
+
+void ShellContentBrowserClient::RequestMediaAccessPermission(
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback) {
+}
+
+content::MediaObserver* ShellContentBrowserClient::GetMediaObserver() {
+ return NULL;
+}
+
+void ShellContentBrowserClient::RequestDesktopNotificationPermission(
+ const GURL& source_origin,
+ int callback_context,
+ int render_process_id,
+ int render_view_id) {
+}
+
+WebKit::WebNotificationPresenter::Permission
+ ShellContentBrowserClient::CheckDesktopNotificationPermission(
+ const GURL& source_origin,
+ content::ResourceContext* context,
+ int render_process_id) {
+ return WebKit::WebNotificationPresenter::PermissionAllowed;
+}
+
+void ShellContentBrowserClient::ShowDesktopNotification(
+ const content::ShowDesktopNotificationHostMsgParams& params,
+ int render_process_id,
+ int render_view_id,
+ bool worker) {
+}
+
+void ShellContentBrowserClient::CancelDesktopNotification(
+ int render_process_id,
+ int render_view_id,
+ int notification_id) {
+}
+
+bool ShellContentBrowserClient::CanCreateWindow(
+ const GURL& opener_url,
+ const GURL& origin,
+ WindowContainerType container_type,
+ content::ResourceContext* context,
+ int render_process_id,
+ bool* no_javascript_access) {
+ *no_javascript_access = false;
+ return true;
+}
+
+std::string ShellContentBrowserClient::GetWorkerProcessTitle(
+ const GURL& url, content::ResourceContext* context) {
+ return std::string();
+}
+
+void ShellContentBrowserClient::ResourceDispatcherHostCreated() {
+ resource_dispatcher_host_delegate_.reset(
+ new content::ShellResourceDispatcherHostDelegate);
+ content::ResourceDispatcherHost::Get()->SetDelegate(
+ resource_dispatcher_host_delegate_.get());
+}
+
+content::SpeechRecognitionManagerDelegate*
+ ShellContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
+ return NULL;
+}
+
+ui::Clipboard* ShellContentBrowserClient::GetClipboard() {
+ return shell_browser_main_parts_->GetClipboard();
+}
+
+net::NetLog* ShellContentBrowserClient::GetNetLog() {
+ return NULL;
+}
+
+content::AccessTokenStore*
+ ShellContentBrowserClient::CreateAccessTokenStore() {
+ return NULL;
+}
+
+bool ShellContentBrowserClient::IsFastShutdownPossible() {
+ return true;
+}
+
+void ShellContentBrowserClient::OverrideWebkitPrefs(
+ content::RenderViewHost* rvh,
+ const GURL& url,
+ WebPreferences* prefs) {
+}
+
+void ShellContentBrowserClient::UpdateInspectorSetting(
+ content::RenderViewHost* rvh,
+ const std::string& key,
+ const std::string& value) {
+}
+
+void ShellContentBrowserClient::ClearInspectorSettings(
+ content::RenderViewHost* rvh) {
+}
+
+void ShellContentBrowserClient::BrowserURLHandlerCreated(
+ content::BrowserURLHandler* handler) {
+}
+
+void ShellContentBrowserClient::ClearCache(content::RenderViewHost* rvh) {
+}
+
+void ShellContentBrowserClient::ClearCookies(content::RenderViewHost* rvh) {
+}
+
+FilePath ShellContentBrowserClient::GetDefaultDownloadDirectory() {
+ return FilePath();
+}
+
+std::string ShellContentBrowserClient::GetDefaultDownloadName() {
+ return "download";
+}
+
+bool ShellContentBrowserClient::AllowSocketAPI(
+ content::BrowserContext* browser_context,
+ const GURL& url) {
+ return false;
+}
+
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+int ShellContentBrowserClient::GetCrashSignalFD(
+ const CommandLine& command_line) {
+ return -1;
+}
+#endif
+
+#if defined(OS_WIN)
+const wchar_t* ShellContentBrowserClient::GetResourceDllName() {
+ return NULL;
+}
+#endif
+
+#if defined(USE_NSS)
+crypto::CryptoModuleBlockingPasswordDelegate*
+ ShellContentBrowserClient::GetCryptoPasswordDelegate(const GURL& url) {
+ return NULL;
+}
+#endif
+
+content::ShellBrowserContext* ShellContentBrowserClient::browser_context() {
+ return shell_browser_main_parts_->browser_context();
+}
+
+} // namespace examples
+} // namespace views
diff --git a/ash/shell/content_client/shell_content_browser_client.h b/ash/shell/content_client/shell_content_browser_client.h
new file mode 100644
index 0000000..a9e70f8
--- /dev/null
+++ b/ash/shell/content_client/shell_content_browser_client.h
@@ -0,0 +1,210 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SHELL_CONTENT_CLIENT_SHELL_CONTENT_BROWSER_CLIENT_H_
+#define ASH_SHELL_CONTENT_CLIENT_SHELL_CONTENT_BROWSER_CLIENT_H_
+#pragma once
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/content_browser_client.h"
+
+namespace content {
+class ShellBrowserContext;
+class ShellBrowserMainParts;
+class ShellResourceDispatcherHostDelegate;
+}
+
+namespace ash {
+namespace shell {
+
+class ShellBrowserMainParts;
+
+class ShellContentBrowserClient : public content::ContentBrowserClient {
+ public:
+ ShellContentBrowserClient();
+ virtual ~ShellContentBrowserClient();
+
+ // Overridden from content::ContentBrowserClient:
+ virtual content::BrowserMainParts* CreateBrowserMainParts(
+ const content::MainFunctionParams& parameters) OVERRIDE;
+ virtual content::WebContentsView* OverrideCreateWebContentsView(
+ content::WebContents* web_contents) OVERRIDE;
+ virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate(
+ content::WebContents* web_contents) OVERRIDE;
+ virtual void RenderViewHostCreated(
+ content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderProcessHostCreated(
+ content::RenderProcessHost* host) OVERRIDE;
+ virtual content::WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE;
+ virtual GURL GetEffectiveURL(content::BrowserContext* browser_context,
+ const GURL& url) OVERRIDE;
+ virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
+ const GURL& effective_url) OVERRIDE;
+ virtual bool IsHandledURL(const GURL& url) OVERRIDE;
+ virtual bool IsSuitableHost(content::RenderProcessHost* process_host,
+ const GURL& site_url) OVERRIDE;
+ virtual bool ShouldTryToUseExistingProcessHost(
+ content::BrowserContext* browser_context, const GURL& url) OVERRIDE;
+ virtual void SiteInstanceGotProcess(
+ content::SiteInstance* site_instance) OVERRIDE;
+ virtual void SiteInstanceDeleting(
+ content::SiteInstance* site_instance) OVERRIDE;
+ virtual bool ShouldSwapProcessesForNavigation(const GURL& current_url,
+ const GURL& new_url) OVERRIDE;
+
+ virtual std::string GetCanonicalEncodingNameByAliasName(
+ const std::string& alias_name) OVERRIDE;
+ virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
+ int child_process_id) OVERRIDE;
+ virtual std::string GetApplicationLocale() OVERRIDE;
+ virtual std::string GetAcceptLangs(
+ content::BrowserContext* context) OVERRIDE;
+ virtual SkBitmap* GetDefaultFavicon() OVERRIDE;
+ virtual bool AllowAppCache(const GURL& manifest_url,
+ const GURL& first_party,
+ content::ResourceContext* context) OVERRIDE;
+ virtual bool AllowGetCookie(const GURL& url,
+ const GURL& first_party,
+ const net::CookieList& cookie_list,
+ content::ResourceContext* context,
+ int render_process_id,
+ int render_view_id) OVERRIDE;
+ virtual bool AllowSetCookie(const GURL& url,
+ const GURL& first_party,
+ const std::string& cookie_line,
+ content::ResourceContext* context,
+ int render_process_id,
+ int render_view_id,
+ net::CookieOptions* options) OVERRIDE;
+ virtual bool AllowSaveLocalState(
+ content::ResourceContext* context) OVERRIDE;
+ virtual bool AllowWorkerDatabase(
+ const GURL& url,
+ const string16& name,
+ const string16& display_name,
+ unsigned long estimated_size,
+ content::ResourceContext* context,
+ const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
+ virtual bool AllowWorkerFileSystem(
+ const GURL& url,
+ content::ResourceContext* context,
+ const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
+ virtual bool AllowWorkerIndexedDB(
+ const GURL& url,
+ const string16& name,
+ content::ResourceContext* context,
+ const std::vector<std::pair<int, int> >& render_views) OVERRIDE;
+ virtual net::URLRequestContext* OverrideRequestContextForURL(
+ const GURL& url, content::ResourceContext* context) OVERRIDE;
+ virtual content::QuotaPermissionContext*
+ CreateQuotaPermissionContext() OVERRIDE;
+ virtual void OpenItem(const FilePath& path) OVERRIDE;
+ virtual void ShowItemInFolder(const FilePath& path) OVERRIDE;
+ virtual void AllowCertificateError(
+ int render_process_id,
+ int render_view_id,
+ int cert_error,
+ const net::SSLInfo& ssl_info,
+ const GURL& request_url,
+ bool overridable,
+ const base::Callback<void(bool)>& callback,
+ bool* cancel_request) OVERRIDE;
+ virtual void SelectClientCertificate(
+ int render_process_id,
+ int render_view_id,
+ const net::HttpNetworkSession* network_session,
+ net::SSLCertRequestInfo* cert_request_info,
+ const base::Callback<void(net::X509Certificate*)>& callback) OVERRIDE;
+ virtual void AddNewCertificate(
+ net::URLRequest* request,
+ net::X509Certificate* cert,
+ int render_process_id,
+ int render_view_id) OVERRIDE;
+ virtual void RequestMediaAccessPermission(
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback) OVERRIDE;
+ virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
+ virtual void RequestDesktopNotificationPermission(
+ const GURL& source_origin,
+ int callback_context,
+ int render_process_id,
+ int render_view_id) OVERRIDE;
+ virtual WebKit::WebNotificationPresenter::Permission
+ CheckDesktopNotificationPermission(
+ const GURL& origin,
+ content::ResourceContext* context,
+ int render_process_id) OVERRIDE;
+ virtual void ShowDesktopNotification(
+ const content::ShowDesktopNotificationHostMsgParams& params,
+ int render_process_id,
+ int render_view_id,
+ bool worker) OVERRIDE;
+ virtual void CancelDesktopNotification(
+ int render_process_id,
+ int render_view_id,
+ int notification_id) OVERRIDE;
+ virtual bool CanCreateWindow(
+ const GURL& opener_url,
+ const GURL& origin,
+ WindowContainerType container_type,
+ content::ResourceContext* context,
+ int render_process_id,
+ bool* no_javascript_access) OVERRIDE;
+ virtual std::string GetWorkerProcessTitle(
+ const GURL& url, content::ResourceContext* context) OVERRIDE;
+ virtual void ResourceDispatcherHostCreated() OVERRIDE;
+ virtual content::SpeechRecognitionManagerDelegate*
+ GetSpeechRecognitionManagerDelegate() OVERRIDE;
+ virtual ui::Clipboard* GetClipboard() OVERRIDE;
+ virtual net::NetLog* GetNetLog() OVERRIDE;
+ virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
+ virtual bool IsFastShutdownPossible() OVERRIDE;
+ virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
+ const GURL& url,
+ WebPreferences* prefs) OVERRIDE;
+ virtual void UpdateInspectorSetting(content::RenderViewHost* rvh,
+ const std::string& key,
+ const std::string& value) OVERRIDE;
+ virtual void ClearInspectorSettings(content::RenderViewHost* rvh) OVERRIDE;
+ virtual void BrowserURLHandlerCreated(
+ content::BrowserURLHandler* handler) OVERRIDE;
+ virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
+ virtual void ClearCookies(content::RenderViewHost* rvh) OVERRIDE;
+ virtual FilePath GetDefaultDownloadDirectory() OVERRIDE;
+ virtual std::string GetDefaultDownloadName() OVERRIDE;
+ virtual bool AllowSocketAPI(content::BrowserContext* browser_context,
+ const GURL& url) OVERRIDE;
+
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ virtual int GetCrashSignalFD(const CommandLine& command_line) OVERRIDE;
+#endif
+
+#if defined(OS_WIN)
+ virtual const wchar_t* GetResourceDllName() OVERRIDE;
+#endif
+
+#if defined(USE_NSS)
+ virtual
+ crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate(
+ const GURL& url) OVERRIDE;
+#endif
+
+ content::ShellBrowserContext* browser_context();
+
+ private:
+ scoped_ptr<content::ShellResourceDispatcherHostDelegate>
+ resource_dispatcher_host_delegate_;
+
+ ShellBrowserMainParts* shell_browser_main_parts_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellContentBrowserClient);
+};
+
+} // namespace shell
+} // namespace ash
+
+#endif // ASH_SHELL_CONTENT_CLIENT_SHELL_CONTENT_BROWSER_CLIENT_H_
diff --git a/ash/shell/content_client/shell_main_delegate.cc b/ash/shell/content_client/shell_main_delegate.cc
new file mode 100644
index 0000000..660901e
--- /dev/null
+++ b/ash/shell/content_client/shell_main_delegate.cc
@@ -0,0 +1,108 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/shell/content_client/shell_main_delegate.h"
+
+#include "ash/shell/content_client/shell_content_browser_client.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "content/public/browser/browser_main_runner.h"
+#include "content/public/common/content_switches.h"
+#include "content/shell/shell_content_plugin_client.h"
+#include "content/shell/shell_content_renderer_client.h"
+#include "content/shell/shell_content_utility_client.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+
+namespace ash {
+namespace shell {
+namespace {
+
+int ShellBrowserMain(
+ const content::MainFunctionParams& main_function_params) {
+ scoped_ptr<content::BrowserMainRunner> main_runner(
+ content::BrowserMainRunner::Create());
+ int exit_code = main_runner->Initialize(main_function_params);
+ if (exit_code >= 0)
+ return exit_code;
+ exit_code = main_runner->Run();
+ main_runner->Shutdown();
+ return exit_code;
+}
+
+}
+
+ShellMainDelegate::ShellMainDelegate() {
+}
+
+ShellMainDelegate::~ShellMainDelegate() {
+}
+
+bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
+ return false;
+}
+
+void ShellMainDelegate::PreSandboxStartup() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+
+ content::SetContentClient(&content_client_);
+ InitializeShellContentClient(process_type);
+
+ InitializeResourceBundle();
+}
+
+void ShellMainDelegate::SandboxInitialized(const std::string& process_type) {
+}
+
+int ShellMainDelegate::RunProcess(
+ const std::string& process_type,
+ const content::MainFunctionParams& main_function_params) {
+ if (process_type != "")
+ return -1;
+
+ return ShellBrowserMain(main_function_params);
+}
+
+void ShellMainDelegate::ProcessExiting(const std::string& process_type) {
+}
+
+#if defined(OS_POSIX)
+content::ZygoteForkDelegate* ShellMainDelegate::ZygoteStarting() {
+ return NULL;
+}
+
+void ShellMainDelegate::ZygoteForked() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ std::string process_type =
+ command_line.GetSwitchValueASCII(switches::kProcessType);
+ InitializeShellContentClient(process_type);
+}
+#endif
+
+void ShellMainDelegate::InitializeShellContentClient(
+ const std::string& process_type) {
+ if (process_type.empty()) {
+ browser_client_.reset(new ShellContentBrowserClient);
+ content::GetContentClient()->set_browser(browser_client_.get());
+ } else if (process_type == switches::kRendererProcess) {
+ renderer_client_.reset(new content::ShellContentRendererClient);
+ content::GetContentClient()->set_renderer(renderer_client_.get());
+ } else if (process_type == switches::kPluginProcess) {
+ plugin_client_.reset(new content::ShellContentPluginClient);
+ content::GetContentClient()->set_plugin(plugin_client_.get());
+ } else if (process_type == switches::kUtilityProcess) {
+ utility_client_.reset(new content::ShellContentUtilityClient);
+ content::GetContentClient()->set_utility(utility_client_.get());
+ }
+}
+
+void ShellMainDelegate::InitializeResourceBundle() {
+ ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
+}
+
+} // namespace shell
+} // namespace ash
diff --git a/ash/shell/content_client/shell_main_delegate.h b/ash/shell/content_client/shell_main_delegate.h
new file mode 100644
index 0000000..bf04eab
--- /dev/null
+++ b/ash/shell/content_client/shell_main_delegate.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SHELL_CONTENT_CLIENT_SHELL_MAIN_DELEGATE_H_
+#define ASH_SHELL_CONTENT_CLIENT_SHELL_MAIN_DELEGATE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/shell/shell_content_client.h"
+#include "content/public/app/content_main_delegate.h"
+
+namespace content {
+class ShellContentRendererClient;
+class ShellContentPluginClient;
+class ShellContentUtilityClient;
+}
+
+namespace ash {
+namespace shell {
+
+class ShellContentBrowserClient;
+
+class ShellMainDelegate : public content::ContentMainDelegate {
+ public:
+ ShellMainDelegate();
+ virtual ~ShellMainDelegate();
+
+ virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
+ virtual void PreSandboxStartup() OVERRIDE;
+ virtual void SandboxInitialized(const std::string& process_type) OVERRIDE;
+ virtual int RunProcess(
+ const std::string& process_type,
+ const content::MainFunctionParams& main_function_params) OVERRIDE;
+ virtual void ProcessExiting(const std::string& process_type) OVERRIDE;
+#if defined(OS_MACOSX)
+ virtual bool ProcessRegistersWithSystemProcess(
+ const std::string& process_type) OVERRIDE;
+ virtual bool ShouldSendMachPort(const std::string& process_type) OVERRIDE;
+ virtual bool DelaySandboxInitialization(
+ const std::string& process_type) OVERRIDE;
+#elif defined(OS_POSIX)
+ virtual content::ZygoteForkDelegate* ZygoteStarting() OVERRIDE;
+ virtual void ZygoteForked() OVERRIDE;
+#endif // OS_MACOSX
+
+ private:
+ void InitializeShellContentClient(const std::string& process_type);
+ void InitializeResourceBundle();
+
+ scoped_ptr<ShellContentBrowserClient> browser_client_;
+ scoped_ptr<content::ShellContentRendererClient> renderer_client_;
+ scoped_ptr<content::ShellContentPluginClient> plugin_client_;
+ scoped_ptr<content::ShellContentUtilityClient> utility_client_;
+ content::ShellContentClient content_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate);
+};
+
+} // namespace shell
+} // namespace ash
+
+#endif // ASH_SHELL_CONTENT_CLIENT_SHELL_MAIN_DELEGATE_H_
diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc
index 3a5c699..303d172 100644
--- a/ash/shell/shell_main.cc
+++ b/ash/shell/shell_main.cc
@@ -2,102 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <map>
-
-#include "ash/launcher/launcher.h"
-#include "ash/launcher/launcher_delegate.h"
-#include "ash/launcher/launcher_model.h"
-#include "ash/launcher/launcher_types.h"
-#include "ash/shell.h"
-#include "ash/shell_delegate.h"
-#include "ash/shell_factory.h"
-#include "ash/shell_window_ids.h"
-#include "ash/shell/launcher_delegate_impl.h"
-#include "ash/shell/shell_delegate_impl.h"
-#include "ash/shell/shell_main_parts.h"
-#include "ash/shell/window_watcher.h"
-#include "base/at_exit.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "ui/aura/env.h"
-#include "ui/aura/client/window_types.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window_observer.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/compositor/test/compositor_test_support.h"
-#include "ui/views/test/test_views_delegate.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/widget/widget_delegate.h"
-
-namespace {
-
-class ShellViewsDelegate : public views::TestViewsDelegate {
- public:
- ShellViewsDelegate() {}
- virtual ~ShellViewsDelegate() {}
-
- // Overridden from views::TestViewsDelegate:
- virtual views::NonClientFrameView* CreateDefaultNonClientFrameView(
- views::Widget* widget) OVERRIDE {
- return ash::Shell::GetInstance()->CreateDefaultNonClientFrameView(widget);
- }
- bool UseTransparentWindows() const OVERRIDE {
- // Ash uses transparent window frames.
- return true;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate);
-};
-
-} // namespace
-
-namespace ash {
-namespace shell {
-
-void InitWindowTypeLauncher();
-
-} // namespace shell
-} // namespace ash
-
-int main(int argc, char** argv) {
- CommandLine::Init(argc, argv);
-
- // The exit manager is in charge of calling the dtors of singleton objects.
- base::AtExitManager exit_manager;
-
- ash::shell::PreMainMessageLoopStart();
-
- // Create the message-loop here before creating the root window.
- MessageLoop message_loop(MessageLoop::TYPE_UI);
- ui::CompositorTestSupport::Initialize();
-
- // A ViewsDelegate is required.
- if (!views::ViewsDelegate::views_delegate)
- views::ViewsDelegate::views_delegate = new ShellViewsDelegate;
-
- ash::shell::ShellDelegateImpl* delegate = new ash::shell::ShellDelegateImpl;
- ash::Shell::CreateInstance(delegate);
-
- scoped_ptr<ash::shell::WindowWatcher> window_watcher(
- new ash::shell::WindowWatcher);
- delegate->SetWatcher(window_watcher.get());
-
- ash::shell::InitWindowTypeLauncher();
-
- ash::Shell::GetRootWindow()->ShowRootWindow();
- MessageLoopForUI::current()->Run();
-
- window_watcher.reset();
-
- ash::Shell::DeleteInstance();
-
- aura::Env::DeleteInstance();
-
- ui::CompositorTestSupport::Terminate();
-
- return 0;
+#include "content/public/app/content_main.h"
+#include "sandbox/src/sandbox_types.h"
+#include "ash/shell/content_client/shell_main_delegate.h"
+
+#if defined(OS_WIN)
+#include "content/public/app/startup_helper_win.h"
+#endif
+
+#if defined(OS_WIN)
+int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
+ sandbox::SandboxInterfaceInfo sandbox_info = {0};
+ content::InitializeSandboxInfo(&sandbox_info);
+ ash::shell::ShellMainDelegate delegate;
+ return content::ContentMain(instance, &sandbox_info, &delegate);
+}
+#else
+int main(int argc, const char** argv) {
+ ash::shell::ShellMainDelegate delegate;
+ return content::ContentMain(argc, argv, &delegate);
}
+#endif
diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc
index c6f5427..f3abad2 100644
--- a/ash/shell/window_type_launcher.cc
+++ b/ash/shell/window_type_launcher.cc
@@ -308,8 +308,9 @@ void WindowTypeLauncher::ButtonPressed(views::Button* sender,
}
#if !defined(OS_MACOSX)
else if (sender == examples_button_) {
- views::examples::ShowExamplesWindow(views::examples::DO_NOTHING_ON_CLOSE,
- NULL);
+ views::examples::ShowExamplesWindow(
+ views::examples::DO_NOTHING_ON_CLOSE,
+ ash::Shell::GetInstance()->browser_context());
}
#endif // !defined(OS_MACOSX)
}