OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/shell/browser/shell_browser_main_parts.h" | 5 #include "apps/shell/browser/shell_browser_main_parts.h" |
6 | 6 |
7 #include "apps/shell/browser/shell_browser_context.h" | 7 #include "apps/shell/browser/shell_browser_context.h" |
8 #include "apps/shell/browser/shell_browser_main_delegate.h" | |
8 #include "apps/shell/browser/shell_desktop_controller.h" | 9 #include "apps/shell/browser/shell_desktop_controller.h" |
9 #include "apps/shell/browser/shell_extension_system.h" | 10 #include "apps/shell/browser/shell_extension_system.h" |
10 #include "apps/shell/browser/shell_extension_system_factory.h" | 11 #include "apps/shell/browser/shell_extension_system_factory.h" |
11 #include "apps/shell/browser/shell_extensions_browser_client.h" | 12 #include "apps/shell/browser/shell_extensions_browser_client.h" |
12 #include "apps/shell/common/shell_extensions_client.h" | 13 #include "apps/shell/common/shell_extensions_client.h" |
13 #include "base/command_line.h" | |
14 #include "base/file_util.h" | |
15 #include "base/files/file_path.h" | |
16 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
17 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
18 #include "content/public/common/result_codes.h" | 16 #include "content/public/common/result_codes.h" |
19 #include "content/shell/browser/shell_devtools_delegate.h" | 17 #include "content/shell/browser/shell_devtools_delegate.h" |
20 #include "content/shell/browser/shell_net_log.h" | 18 #include "content/shell/browser/shell_net_log.h" |
21 #include "extensions/browser/browser_context_keyed_service_factories.h" | 19 #include "extensions/browser/browser_context_keyed_service_factories.h" |
22 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
23 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
24 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
25 | 23 |
(...skipping 14 matching lines...) Expand all Loading... | |
40 void EnsureBrowserContextKeyedServiceFactoriesBuilt() { | 38 void EnsureBrowserContextKeyedServiceFactoriesBuilt() { |
41 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); | 39 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
42 extensions::ShellExtensionSystemFactory::GetInstance(); | 40 extensions::ShellExtensionSystemFactory::GetInstance(); |
43 } | 41 } |
44 | 42 |
45 } // namespace | 43 } // namespace |
46 | 44 |
47 namespace apps { | 45 namespace apps { |
48 | 46 |
49 ShellBrowserMainParts::ShellBrowserMainParts( | 47 ShellBrowserMainParts::ShellBrowserMainParts( |
50 const content::MainFunctionParams& parameters) | 48 const content::MainFunctionParams& parameters, |
49 ShellBrowserMainDelegate* browser_main_delegate) | |
51 : extension_system_(NULL), | 50 : extension_system_(NULL), |
52 parameters_(parameters), | 51 parameters_(parameters), |
53 run_message_loop_(true) {} | 52 run_message_loop_(true), |
53 browser_main_delegate_(browser_main_delegate) { | |
54 } | |
54 | 55 |
55 ShellBrowserMainParts::~ShellBrowserMainParts() { | 56 ShellBrowserMainParts::~ShellBrowserMainParts() { |
56 } | 57 } |
57 | 58 |
58 void ShellBrowserMainParts::PreMainMessageLoopStart() { | 59 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
59 // TODO(jamescook): Initialize touch here? | 60 // TODO(jamescook): Initialize touch here? |
60 } | 61 } |
61 | 62 |
62 void ShellBrowserMainParts::PostMainMessageLoopStart() { | 63 void ShellBrowserMainParts::PostMainMessageLoopStart() { |
63 #if defined(OS_CHROMEOS) | 64 #if defined(OS_CHROMEOS) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 // KeyedServices depend on it. | 99 // KeyedServices depend on it. |
99 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. | 100 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. |
100 CreateExtensionSystem(); | 101 CreateExtensionSystem(); |
101 | 102 |
102 ::EnsureBrowserContextKeyedServiceFactoriesBuilt(); | 103 ::EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
103 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 104 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |
104 browser_context_.get()); | 105 browser_context_.get()); |
105 | 106 |
106 devtools_delegate_.reset( | 107 devtools_delegate_.reset( |
107 new content::ShellDevToolsDelegate(browser_context_.get())); | 108 new content::ShellDevToolsDelegate(browser_context_.get())); |
108 | 109 if (parameters_.ui_task) { |
James Cook
2014/05/09 15:56:00
Just to double-check: Does app_shell_browsertests
| |
109 const std::string kAppSwitch = "app"; | |
110 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
111 if (command_line->HasSwitch(kAppSwitch)) { | |
112 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); | |
113 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | |
114 extension_system_->LoadAndLaunchApp(app_absolute_dir); | |
115 } else if (parameters_.ui_task) { | |
116 // For running browser tests. | 110 // For running browser tests. |
117 parameters_.ui_task->Run(); | 111 parameters_.ui_task->Run(); |
118 delete parameters_.ui_task; | 112 delete parameters_.ui_task; |
119 run_message_loop_ = false; | 113 run_message_loop_ = false; |
120 } else { | 114 } else { |
121 LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future"; | 115 browser_main_delegate_->Start(browser_context_.get()); |
122 } | 116 } |
123 } | 117 } |
124 | 118 |
125 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 119 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
126 if (!run_message_loop_) | 120 if (!run_message_loop_) |
127 return true; | 121 return true; |
128 // TODO(yoz): just return false here? | 122 // TODO(yoz): just return false here? |
129 base::RunLoop run_loop; | 123 base::RunLoop run_loop; |
130 run_loop.Run(); | 124 run_loop.Run(); |
131 *result_code = content::RESULT_CODE_NORMAL_EXIT; | 125 *result_code = content::RESULT_CODE_NORMAL_EXIT; |
(...skipping 27 matching lines...) Expand all Loading... | |
159 } | 153 } |
160 | 154 |
161 void ShellBrowserMainParts::CreateExtensionSystem() { | 155 void ShellBrowserMainParts::CreateExtensionSystem() { |
162 DCHECK(browser_context_); | 156 DCHECK(browser_context_); |
163 extension_system_ = static_cast<ShellExtensionSystem*>( | 157 extension_system_ = static_cast<ShellExtensionSystem*>( |
164 ExtensionSystem::Get(browser_context_.get())); | 158 ExtensionSystem::Get(browser_context_.get())); |
165 extension_system_->InitForRegularProfile(true); | 159 extension_system_->InitForRegularProfile(true); |
166 } | 160 } |
167 | 161 |
168 } // namespace apps | 162 } // namespace apps |
OLD | NEW |