diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-11 00:06:18 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-11 00:06:18 +0000 |
commit | 46c80dce6ea8ed3eaabef34a4b7b7bd564eb24be (patch) | |
tree | 47203b7e2a0305503b673b9312233dc116a4db6e /apps/shell | |
parent | 8a33b058eaca9592fd6fb06f5e55c1734069463b (diff) | |
download | chromium_src-46c80dce6ea8ed3eaabef34a4b7b7bd564eb24be.zip chromium_src-46c80dce6ea8ed3eaabef34a4b7b7bd564eb24be.tar.gz chromium_src-46c80dce6ea8ed3eaabef34a4b7b7bd564eb24be.tar.bz2 |
Minimal athena shell main
BUG=362288
Review URL: https://codereview.chromium.org/270763002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/shell')
-rw-r--r-- | apps/shell/app/shell_main_delegate.cc | 8 | ||||
-rw-r--r-- | apps/shell/app/shell_main_delegate.h | 22 | ||||
-rw-r--r-- | apps/shell/app_shell.gyp | 3 | ||||
-rw-r--r-- | apps/shell/browser/default_shell_browser_main_delegate.cc | 37 | ||||
-rw-r--r-- | apps/shell/browser/default_shell_browser_main_delegate.h | 30 | ||||
-rw-r--r-- | apps/shell/browser/shell_browser_main_delegate.h | 25 | ||||
-rw-r--r-- | apps/shell/browser/shell_browser_main_parts.cc | 22 | ||||
-rw-r--r-- | apps/shell/browser/shell_browser_main_parts.h | 7 | ||||
-rw-r--r-- | apps/shell/browser/shell_content_browser_client.cc | 8 | ||||
-rw-r--r-- | apps/shell/browser/shell_content_browser_client.h | 7 |
10 files changed, 141 insertions, 28 deletions
diff --git a/apps/shell/app/shell_main_delegate.cc b/apps/shell/app/shell_main_delegate.cc index 13706cd..b8f835d 100644 --- a/apps/shell/app/shell_main_delegate.cc +++ b/apps/shell/app/shell_main_delegate.cc @@ -4,6 +4,7 @@ #include "apps/shell/app/shell_main_delegate.h" +#include "apps/shell/browser/default_shell_browser_main_delegate.h" #include "apps/shell/browser/shell_content_browser_client.h" #include "apps/shell/common/shell_content_client.h" #include "apps/shell/renderer/shell_content_renderer_client.h" @@ -65,7 +66,8 @@ void ShellMainDelegate::PreSandboxStartup() { } content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { - browser_client_.reset(new apps::ShellContentBrowserClient); + browser_client_.reset( + new apps::ShellContentBrowserClient(CreateShellBrowserMainDelegate())); return browser_client_.get(); } @@ -75,6 +77,10 @@ ShellMainDelegate::CreateContentRendererClient() { return renderer_client_.get(); } +ShellBrowserMainDelegate* ShellMainDelegate::CreateShellBrowserMainDelegate() { + return new DefaultShellBrowserMainDelegate(); +} + // static bool ShellMainDelegate::ProcessNeedsResourceBundle( const std::string& process_type) { diff --git a/apps/shell/app/shell_main_delegate.h b/apps/shell/app/shell_main_delegate.h index 6af9395..45ba122 100644 --- a/apps/shell/app/shell_main_delegate.h +++ b/apps/shell/app/shell_main_delegate.h @@ -9,11 +9,15 @@ #include "base/memory/scoped_ptr.h" #include "content/public/app/content_main_delegate.h" -namespace apps { +namespace content { +class BrowserContext; +class ContentBrowserClient; +class ContentClient; +class ContentRendererClient; +} -class ShellContentBrowserClient; -class ShellContentClient; -class ShellContentRendererClient; +namespace apps { +class ShellBrowserMainDelegate; class ShellMainDelegate : public content::ContentMainDelegate { public: @@ -27,6 +31,10 @@ class ShellMainDelegate : public content::ContentMainDelegate { virtual content::ContentRendererClient* CreateContentRendererClient() OVERRIDE; + protected: + // The created object is owned by ShellBrowserMainParts. + virtual ShellBrowserMainDelegate* CreateShellBrowserMainDelegate(); + private: // |process_type| is zygote, renderer, utility, etc. Returns true if the // process needs data from resources.pak. @@ -35,9 +43,9 @@ class ShellMainDelegate : public content::ContentMainDelegate { // Initializes the resource bundle and resources.pak. static void InitializeResourceBundle(); - scoped_ptr<ShellContentClient> content_client_; - scoped_ptr<ShellContentBrowserClient> browser_client_; - scoped_ptr<ShellContentRendererClient> renderer_client_; + scoped_ptr<content::ContentClient> content_client_; + scoped_ptr<content::ContentBrowserClient> browser_client_; + scoped_ptr<content::ContentRendererClient> renderer_client_; DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate); }; diff --git a/apps/shell/app_shell.gyp b/apps/shell/app_shell.gyp index 3fc8152..e39da3d 100644 --- a/apps/shell/app_shell.gyp +++ b/apps/shell/app_shell.gyp @@ -97,12 +97,15 @@ 'app/shell_main_delegate.h', 'browser/api/shell/shell_api.cc', 'browser/api/shell/shell_api.h', + 'browser/default_shell_browser_main_delegate.cc', + 'browser/default_shell_browser_main_delegate.h', 'browser/shell_app_sorting.cc', 'browser/shell_app_sorting.h', 'browser/shell_app_window.cc', 'browser/shell_app_window.h', 'browser/shell_browser_context.cc', 'browser/shell_browser_context.h', + 'browser/shell_browser_main_delegate.h', 'browser/shell_browser_main_parts.cc', 'browser/shell_browser_main_parts.h', 'browser/shell_content_browser_client.cc', diff --git a/apps/shell/browser/default_shell_browser_main_delegate.cc b/apps/shell/browser/default_shell_browser_main_delegate.cc new file mode 100644 index 0000000..6f521da --- /dev/null +++ b/apps/shell/browser/default_shell_browser_main_delegate.cc @@ -0,0 +1,37 @@ +// Copyright 2014 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 "apps/shell/browser/default_shell_browser_main_delegate.h" + +#include "apps/shell/browser/shell_extension_system.h" +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/files/file_path.h" + +namespace apps { + +DefaultShellBrowserMainDelegate::DefaultShellBrowserMainDelegate() { +} + +DefaultShellBrowserMainDelegate::~DefaultShellBrowserMainDelegate() { +} + +void DefaultShellBrowserMainDelegate::Start( + content::BrowserContext* browser_context) { + const std::string kAppSwitch = "app"; + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(kAppSwitch)) { + base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); + base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); + + extensions::ShellExtensionSystem* extension_system = + static_cast<extensions::ShellExtensionSystem*>( + extensions::ExtensionSystem::Get(browser_context)); + extension_system->LoadAndLaunchApp(app_absolute_dir); + } else { + LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future"; + } +} + +} // namespace apps diff --git a/apps/shell/browser/default_shell_browser_main_delegate.h b/apps/shell/browser/default_shell_browser_main_delegate.h new file mode 100644 index 0000000..eaea3bd --- /dev/null +++ b/apps/shell/browser/default_shell_browser_main_delegate.h @@ -0,0 +1,30 @@ +// Copyright 2014 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 APPS_SHELL_BROWSER_DEFAULT_SHELL_BROWSER_MAIN_DELEGATE_H_ +#define APPS_SHELL_BROWSER_DEFAULT_SHELL_BROWSER_MAIN_DELEGATE_H_ + +#include "apps/shell/browser/shell_browser_main_delegate.h" +#include "base/compiler_specific.h" +#include "base/macros.h" + +namespace apps { + +// A ShellBrowserMainDelegate that starts an application specified +// by the "--app" command line. This is used only in the browser process. +class DefaultShellBrowserMainDelegate : public ShellBrowserMainDelegate { + public: + DefaultShellBrowserMainDelegate(); + virtual ~DefaultShellBrowserMainDelegate(); + + // ShellBrowserMainDelegate: + virtual void Start(content::BrowserContext* context) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(DefaultShellBrowserMainDelegate); +}; + +} // namespace apps + +#endif // DEFAULT_SHELL_BROWSER_MAIN_DELEGATE_H_ diff --git a/apps/shell/browser/shell_browser_main_delegate.h b/apps/shell/browser/shell_browser_main_delegate.h new file mode 100644 index 0000000..dce30b3 --- /dev/null +++ b/apps/shell/browser/shell_browser_main_delegate.h @@ -0,0 +1,25 @@ +// Copyright 2014 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 APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_DELEGATE_H_ +#define APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_DELEGATE_H_ + +namespace content { +class BrowserContext; +} + +namespace apps { + +class ShellBrowserMainDelegate { + public: + virtual ~ShellBrowserMainDelegate() {} + + // Called to start an application after all initialization processes that are + // necesary to run apps are completed. + virtual void Start(content::BrowserContext* context) = 0; +}; + +} // namespace apps + +#endif // APPS_SHELL_BROWSER_SHELL_BROWSER_MAIN_DELEGATE_H_ diff --git a/apps/shell/browser/shell_browser_main_parts.cc b/apps/shell/browser/shell_browser_main_parts.cc index be1c82d..126f86a 100644 --- a/apps/shell/browser/shell_browser_main_parts.cc +++ b/apps/shell/browser/shell_browser_main_parts.cc @@ -5,14 +5,12 @@ #include "apps/shell/browser/shell_browser_main_parts.h" #include "apps/shell/browser/shell_browser_context.h" +#include "apps/shell/browser/shell_browser_main_delegate.h" #include "apps/shell/browser/shell_desktop_controller.h" #include "apps/shell/browser/shell_extension_system.h" #include "apps/shell/browser/shell_extension_system_factory.h" #include "apps/shell/browser/shell_extensions_browser_client.h" #include "apps/shell/common/shell_extensions_client.h" -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/files/file_path.h" #include "base/run_loop.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "content/public/common/result_codes.h" @@ -47,10 +45,13 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() { namespace apps { ShellBrowserMainParts::ShellBrowserMainParts( - const content::MainFunctionParams& parameters) + const content::MainFunctionParams& parameters, + ShellBrowserMainDelegate* browser_main_delegate) : extension_system_(NULL), parameters_(parameters), - run_message_loop_(true) {} + run_message_loop_(true), + browser_main_delegate_(browser_main_delegate) { +} ShellBrowserMainParts::~ShellBrowserMainParts() { } @@ -105,20 +106,13 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { devtools_delegate_.reset( new content::ShellDevToolsDelegate(browser_context_.get())); - - const std::string kAppSwitch = "app"; - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(kAppSwitch)) { - base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); - base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); - extension_system_->LoadAndLaunchApp(app_absolute_dir); - } else if (parameters_.ui_task) { + if (parameters_.ui_task) { // For running browser tests. parameters_.ui_task->Run(); delete parameters_.ui_task; run_message_loop_ = false; } else { - LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future"; + browser_main_delegate_->Start(browser_context_.get()); } } diff --git a/apps/shell/browser/shell_browser_main_parts.h b/apps/shell/browser/shell_browser_main_parts.h index 4bc18b2..d8a2c11 100644 --- a/apps/shell/browser/shell_browser_main_parts.h +++ b/apps/shell/browser/shell_browser_main_parts.h @@ -34,6 +34,7 @@ class NetLog; namespace apps { class ShellBrowserContext; +class ShellBrowserMainDelegate; class ShellDesktopController; class ShellExtensionsClient; @@ -45,8 +46,8 @@ class ShellNetworkController; class ShellBrowserMainParts : public content::BrowserMainParts, public aura::WindowTreeHostObserver { public: - explicit ShellBrowserMainParts( - const content::MainFunctionParams& parameters); + ShellBrowserMainParts(const content::MainFunctionParams& parameters, + ShellBrowserMainDelegate* browser_main_delegate); virtual ~ShellBrowserMainParts(); ShellBrowserContext* browser_context() { @@ -96,6 +97,8 @@ class ShellBrowserMainParts : public content::BrowserMainParts, // in MainMessageLoopRun. If false, it has already been run. bool run_message_loop_; + scoped_ptr<ShellBrowserMainDelegate> browser_main_delegate_; + DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts); }; diff --git a/apps/shell/browser/shell_content_browser_client.cc b/apps/shell/browser/shell_content_browser_client.cc index ca9db4e..c61a8c89 100644 --- a/apps/shell/browser/shell_content_browser_client.cc +++ b/apps/shell/browser/shell_content_browser_client.cc @@ -34,8 +34,9 @@ ShellContentBrowserClient* g_instance = NULL; } // namespace -ShellContentBrowserClient::ShellContentBrowserClient() - : browser_main_parts_(NULL) { +ShellContentBrowserClient::ShellContentBrowserClient( + ShellBrowserMainDelegate* browser_main_delegate) + : browser_main_parts_(NULL), browser_main_delegate_(browser_main_delegate) { DCHECK(!g_instance); g_instance = this; } @@ -53,7 +54,8 @@ content::BrowserContext* ShellContentBrowserClient::GetBrowserContext() { content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { - browser_main_parts_ = new ShellBrowserMainParts(parameters); + browser_main_parts_ = + new ShellBrowserMainParts(parameters, browser_main_delegate_); return browser_main_parts_; } diff --git a/apps/shell/browser/shell_content_browser_client.h b/apps/shell/browser/shell_content_browser_client.h index 102173f..7fbe3a1 100644 --- a/apps/shell/browser/shell_content_browser_client.h +++ b/apps/shell/browser/shell_content_browser_client.h @@ -19,12 +19,14 @@ class Extension; } namespace apps { +class ShellBrowserMainDelegate; class ShellBrowserMainParts; // Content module browser process support for app_shell. class ShellContentBrowserClient : public content::ContentBrowserClient { public: - ShellContentBrowserClient(); + explicit ShellContentBrowserClient( + ShellBrowserMainDelegate* browser_main_delegate); virtual ~ShellContentBrowserClient(); // Returns the single instance. @@ -64,6 +66,9 @@ class ShellContentBrowserClient : public content::ContentBrowserClient { // Owned by content::BrowserMainLoop. ShellBrowserMainParts* browser_main_parts_; + // Owned by ShellBrowserMainParts. + ShellBrowserMainDelegate* browser_main_delegate_; + DISALLOW_COPY_AND_ASSIGN(ShellContentBrowserClient); }; |