Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: apps/shell/browser/shell_browser_main_parts.cc

Issue 412713002: Move apps/shell to extensions/shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 40% Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « apps/shell/browser/shell_browser_main_parts.h ('k') | apps/shell/browser/shell_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "apps/shell/browser/shell_browser_main_parts.h"
6
7 #include "apps/shell/browser/shell_browser_context.h"
8 #include "apps/shell/browser/shell_browser_main_delegate.h"
9 #include "apps/shell/browser/shell_desktop_controller.h"
10 #include "apps/shell/browser/shell_extension_system.h"
11 #include "apps/shell/browser/shell_extension_system_factory.h"
12 #include "apps/shell/browser/shell_extensions_browser_client.h"
13 #include "apps/shell/browser/shell_omaha_query_params_delegate.h"
14 #include "apps/shell/common/shell_extensions_client.h"
15 #include "apps/shell/common/switches.h"
16 #include "base/command_line.h"
17 #include "base/run_loop.h"
18 #include "components/keyed_service/content/browser_context_dependency_manager.h"
19 #include "components/omaha_query_params/omaha_query_params.h"
20 #include "content/public/common/result_codes.h"
21 #include "content/shell/browser/shell_devtools_delegate.h"
22 #include "content/shell/browser/shell_net_log.h"
23 #include "extensions/browser/browser_context_keyed_service_factories.h"
24 #include "extensions/browser/extension_system.h"
25 #include "ui/aura/window_tree_host.h"
26 #include "ui/base/ime/input_method_initializer.h"
27 #include "ui/base/resource/resource_bundle.h"
28
29 #if defined(OS_CHROMEOS)
30 #include "apps/shell/browser/shell_network_controller_chromeos.h"
31 #include "chromeos/dbus/dbus_thread_manager.h"
32 #endif
33
34 using content::BrowserContext;
35 using extensions::Extension;
36 using extensions::ExtensionSystem;
37 using extensions::ShellExtensionSystem;
38
39 namespace {
40
41 // Register additional KeyedService factories here. See
42 // ChromeBrowserMainExtraPartsProfiles for details.
43 void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
44 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
45 extensions::ShellExtensionSystemFactory::GetInstance();
46 }
47
48 } // namespace
49
50 namespace apps {
51
52 ShellBrowserMainParts::ShellBrowserMainParts(
53 const content::MainFunctionParams& parameters,
54 ShellBrowserMainDelegate* browser_main_delegate)
55 : extension_system_(NULL),
56 parameters_(parameters),
57 run_message_loop_(true),
58 browser_main_delegate_(browser_main_delegate) {
59 }
60
61 ShellBrowserMainParts::~ShellBrowserMainParts() {
62 }
63
64 void ShellBrowserMainParts::PreMainMessageLoopStart() {
65 // TODO(jamescook): Initialize touch here?
66 }
67
68 void ShellBrowserMainParts::PostMainMessageLoopStart() {
69 #if defined(OS_CHROMEOS)
70 chromeos::DBusThreadManager::Initialize();
71 network_controller_.reset(new ShellNetworkController(
72 base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
73 switches::kAppShellPreferredNetwork)));
74 #else
75 // Non-Chrome OS platforms are for developer convenience, so use a test IME.
76 ui::InitializeInputMethodForTesting();
77 #endif
78 }
79
80 void ShellBrowserMainParts::PreEarlyInitialization() {
81 }
82
83 int ShellBrowserMainParts::PreCreateThreads() {
84 // TODO(jamescook): Initialize chromeos::CrosSettings here?
85
86 // Return no error.
87 return 0;
88 }
89
90 void ShellBrowserMainParts::PreMainMessageLoopRun() {
91 // Initialize our "profile" equivalent.
92 browser_context_.reset(new ShellBrowserContext);
93
94 desktop_controller_.reset(browser_main_delegate_->CreateDesktopController());
95 desktop_controller_->CreateRootWindow();
96
97 // NOTE: Much of this is culled from chrome/test/base/chrome_test_suite.cc
98 // TODO(jamescook): Initialize chromeos::UserManager.
99 net_log_.reset(new content::ShellNetLog("app_shell"));
100
101 extensions_client_.reset(new ShellExtensionsClient());
102 extensions::ExtensionsClient::Set(extensions_client_.get());
103
104 extensions_browser_client_.reset(
105 new extensions::ShellExtensionsBrowserClient(browser_context_.get()));
106 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
107
108 omaha_query_params_delegate_.reset(
109 new extensions::ShellOmahaQueryParamsDelegate);
110 omaha_query_params::OmahaQueryParams::SetDelegate(
111 omaha_query_params_delegate_.get());
112
113 // Create our custom ExtensionSystem first because other
114 // KeyedServices depend on it.
115 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt.
116 CreateExtensionSystem();
117
118 ::EnsureBrowserContextKeyedServiceFactoriesBuilt();
119 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
120 browser_context_.get());
121
122 devtools_delegate_.reset(
123 new content::ShellDevToolsDelegate(browser_context_.get()));
124 if (parameters_.ui_task) {
125 // For running browser tests.
126 parameters_.ui_task->Run();
127 delete parameters_.ui_task;
128 run_message_loop_ = false;
129 } else {
130 browser_main_delegate_->Start(browser_context_.get());
131 }
132 }
133
134 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
135 if (!run_message_loop_)
136 return true;
137 // TODO(yoz): just return false here?
138 base::RunLoop run_loop;
139 run_loop.Run();
140 *result_code = content::RESULT_CODE_NORMAL_EXIT;
141 return true;
142 }
143
144 void ShellBrowserMainParts::PostMainMessageLoopRun() {
145 browser_main_delegate_->Shutdown();
146
147 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
148 browser_context_.get());
149 extension_system_ = NULL;
150 extensions::ExtensionsBrowserClient::Set(NULL);
151 extensions_browser_client_.reset();
152 browser_context_.reset();
153
154 desktop_controller_.reset();
155 }
156
157 void ShellBrowserMainParts::PostDestroyThreads() {
158 #if defined(OS_CHROMEOS)
159 network_controller_.reset();
160 chromeos::DBusThreadManager::Shutdown();
161 #endif
162 }
163
164 void ShellBrowserMainParts::CreateExtensionSystem() {
165 DCHECK(browser_context_);
166 extension_system_ = static_cast<ShellExtensionSystem*>(
167 ExtensionSystem::Get(browser_context_.get()));
168 extension_system_->InitForRegularProfile(true);
169 }
170
171 } // namespace apps
OLDNEW
« no previous file with comments | « apps/shell/browser/shell_browser_main_parts.h ('k') | apps/shell/browser/shell_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698