summaryrefslogtreecommitdiffstats
path: root/extensions/shell/app
diff options
context:
space:
mode:
authoryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 03:39:36 +0000
committeryoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 03:39:36 +0000
commit7685f64a35b6d029f7d11ce752dc126163d9474e (patch)
tree0cb10d4ed10d781bc6de27672bbcc8528134baab /extensions/shell/app
parentaf97fe7d55c6310aacf1585bdbd8d38e3bc4c080 (diff)
downloadchromium_src-7685f64a35b6d029f7d11ce752dc126163d9474e.zip
chromium_src-7685f64a35b6d029f7d11ce752dc126163d9474e.tar.gz
chromium_src-7685f64a35b6d029f7d11ce752dc126163d9474e.tar.bz2
Move apps/shell to extensions/shell.
This does: - Move files - Fix up all namespaces in these files to be extensions, not apps - Clean up DEPS files This does not: - Change the name of the build targets (app_shell, app_shell_browsertests) BUG=394987 TBR=ben@chromium.org Review URL: https://codereview.chromium.org/412713002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/shell/app')
-rw-r--r--extensions/shell/app/DEPS7
-rw-r--r--extensions/shell/app/README5
-rw-r--r--extensions/shell/app/shell_main.cc32
-rw-r--r--extensions/shell/app/shell_main_delegate.cc109
-rw-r--r--extensions/shell/app/shell_main_delegate.h60
5 files changed, 213 insertions, 0 deletions
diff --git a/extensions/shell/app/DEPS b/extensions/shell/app/DEPS
new file mode 100644
index 0000000..b9b52a1
--- /dev/null
+++ b/extensions/shell/app/DEPS
@@ -0,0 +1,7 @@
+include_rules = [
+ "+extensions/shell",
+ "+chromeos",
+ "+content/public/app",
+ "+content/public/browser",
+ "+sandbox",
+]
diff --git a/extensions/shell/app/README b/extensions/shell/app/README
new file mode 100644
index 0000000..9dbba28
--- /dev/null
+++ b/extensions/shell/app/README
@@ -0,0 +1,5 @@
+"Application support" for the app_shell executable.
+
+This directory has nothing to do with the apps/extensions themselves.
+
+See content/shell/app for a similar example.
diff --git a/extensions/shell/app/shell_main.cc b/extensions/shell/app/shell_main.cc
new file mode 100644
index 0000000..a58ab82
--- /dev/null
+++ b/extensions/shell/app/shell_main.cc
@@ -0,0 +1,32 @@
+// 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 "content/public/app/content_main.h"
+#include "extensions/shell/app/shell_main_delegate.h"
+
+#if defined(OS_WIN)
+#include "content/public/app/startup_helper_win.h"
+#include "sandbox/win/src/sandbox_types.h"
+#endif
+
+#if defined(OS_WIN)
+int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
+#else
+int main(int argc, const char** argv) {
+#endif
+ extensions::ShellMainDelegate delegate;
+ content::ContentMainParams params(&delegate);
+
+#if defined(OS_WIN)
+ sandbox::SandboxInterfaceInfo sandbox_info = {0};
+ content::InitializeSandboxInfo(&sandbox_info);
+ params.instance = instance;
+ params.sandbox_info = &sandbox_info;
+#else
+ params.argc = argc;
+ params.argv = argv;
+#endif
+
+ return content::ContentMain(params);
+}
diff --git a/extensions/shell/app/shell_main_delegate.cc b/extensions/shell/app/shell_main_delegate.cc
new file mode 100644
index 0000000..b3b6ceb
--- /dev/null
+++ b/extensions/shell/app/shell_main_delegate.cc
@@ -0,0 +1,109 @@
+// 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 "extensions/shell/app/shell_main_delegate.h"
+
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "content/public/browser/browser_main_runner.h"
+#include "content/public/common/content_switches.h"
+#include "extensions/common/extension_paths.h"
+#include "extensions/shell/browser/default_shell_browser_main_delegate.h"
+#include "extensions/shell/browser/shell_content_browser_client.h"
+#include "extensions/shell/common/shell_content_client.h"
+#include "extensions/shell/renderer/shell_content_renderer_client.h"
+#include "extensions/shell/renderer/shell_renderer_main_delegate.h"
+#include "ui/base/resource/resource_bundle.h"
+
+#if defined(OS_CHROMEOS)
+#include "chromeos/chromeos_paths.h"
+#endif
+
+namespace {
+
+void InitLogging() {
+ base::FilePath log_filename;
+ PathService::Get(base::DIR_EXE, &log_filename);
+ log_filename = log_filename.AppendASCII("app_shell.log");
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_ALL;
+ settings.log_file = log_filename.value().c_str();
+ settings.delete_old = logging::DELETE_OLD_LOG_FILE;
+ logging::InitLogging(settings);
+ logging::SetLogItems(true, true, true, true);
+}
+
+} // namespace
+
+namespace extensions {
+
+ShellMainDelegate::ShellMainDelegate() {
+}
+
+ShellMainDelegate::~ShellMainDelegate() {
+}
+
+bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
+ InitLogging();
+ content_client_.reset(new ShellContentClient);
+ SetContentClient(content_client_.get());
+
+#if defined(OS_CHROMEOS)
+ chromeos::RegisterPathProvider();
+#endif
+ extensions::RegisterPathProvider();
+ return false;
+}
+
+void ShellMainDelegate::PreSandboxStartup() {
+ std::string process_type =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kProcessType);
+ if (ProcessNeedsResourceBundle(process_type))
+ InitializeResourceBundle();
+}
+
+content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
+ browser_client_.reset(CreateShellContentBrowserClient());
+ return browser_client_.get();
+}
+
+content::ContentBrowserClient*
+ShellMainDelegate::CreateShellContentBrowserClient() {
+ return new ShellContentBrowserClient(new DefaultShellBrowserMainDelegate());
+}
+
+content::ContentRendererClient*
+ShellMainDelegate::CreateContentRendererClient() {
+ renderer_client_.reset(
+ new ShellContentRendererClient(CreateShellRendererMainDelegate()));
+ return renderer_client_.get();
+}
+
+scoped_ptr<ShellRendererMainDelegate>
+ShellMainDelegate::CreateShellRendererMainDelegate() {
+ return scoped_ptr<ShellRendererMainDelegate>();
+}
+
+void ShellMainDelegate::InitializeResourceBundle() {
+ base::FilePath pak_dir;
+ PathService::Get(base::DIR_MODULE, &pak_dir);
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(
+ pak_dir.AppendASCII("app_shell.pak"));
+}
+
+// static
+bool ShellMainDelegate::ProcessNeedsResourceBundle(
+ const std::string& process_type) {
+ // The browser process has no process type flag, but needs resources.
+ // On Linux the zygote process opens the resources for the renderers.
+ return process_type.empty() ||
+ process_type == switches::kZygoteProcess ||
+ process_type == switches::kRendererProcess ||
+ process_type == switches::kUtilityProcess;
+}
+
+} // namespace extensions
diff --git a/extensions/shell/app/shell_main_delegate.h b/extensions/shell/app/shell_main_delegate.h
new file mode 100644
index 0000000..7e120f4
--- /dev/null
+++ b/extensions/shell/app/shell_main_delegate.h
@@ -0,0 +1,60 @@
+// 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 EXTENSIONS_SHELL_APP_SHELL_MAIN_DELEGATE_H_
+#define EXTENSIONS_SHELL_APP_SHELL_MAIN_DELEGATE_H_
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/app/content_main_delegate.h"
+
+namespace content {
+class BrowserContext;
+class ContentBrowserClient;
+class ContentClient;
+class ContentRendererClient;
+}
+
+namespace extensions {
+class ShellBrowserMainDelegate;
+class ShellRendererMainDelegate;
+
+class ShellMainDelegate : public content::ContentMainDelegate {
+ public:
+ ShellMainDelegate();
+ virtual ~ShellMainDelegate();
+
+ // ContentMainDelegate implementation:
+ virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
+ virtual void PreSandboxStartup() OVERRIDE;
+ virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
+ virtual content::ContentRendererClient* CreateContentRendererClient()
+ OVERRIDE;
+
+ protected:
+ // The created object is owned by this object.
+ virtual content::ContentBrowserClient* CreateShellContentBrowserClient();
+
+ // The returned object is owned by ShellContentRendererClient.
+ virtual scoped_ptr<ShellRendererMainDelegate>
+ CreateShellRendererMainDelegate();
+
+ // Initializes the resource bundle and resources.pak.
+ virtual void InitializeResourceBundle();
+
+ private:
+ // |process_type| is zygote, renderer, utility, etc. Returns true if the
+ // process needs data from resources.pak.
+ static bool ProcessNeedsResourceBundle(const std::string& process_type);
+
+ scoped_ptr<content::ContentClient> content_client_;
+ scoped_ptr<content::ContentBrowserClient> browser_client_;
+ scoped_ptr<content::ContentRendererClient> renderer_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_SHELL_APP_SHELL_MAIN_DELEGATE_H_