| 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/shell_browser_main_parts.h" | 5 #include "apps/shell/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "apps/shell/shell_browser_context.h" | 7 #include "apps/shell/shell_browser_context.h" |
| 8 #include "apps/shell/shell_extension_system.h" | 8 #include "apps/shell/shell_extension_system.h" |
| 9 #include "apps/shell/shell_extensions_browser_client.h" | 9 #include "apps/shell/shell_extensions_browser_client.h" |
| 10 #include "apps/shell/shell_extensions_client.h" | 10 #include "apps/shell/shell_extensions_client.h" |
| 11 #include "apps/shell/web_view_window.h" | 11 #include "apps/shell/web_view_window.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "chrome/browser/extensions/extension_system_factory.h" | 16 #include "chrome/browser/extensions/extension_system_factory.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/extensions/extension_file_util.h" | |
| 19 #include "chromeos/chromeos_paths.h" | 18 #include "chromeos/chromeos_paths.h" |
| 20 #include "content/public/common/result_codes.h" | 19 #include "content/public/common/result_codes.h" |
| 21 #include "extensions/common/extension_paths.h" | 20 #include "extensions/common/extension_paths.h" |
| 22 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
| 23 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
| 24 #include "ui/aura/test/test_screen.h" | 23 #include "ui/aura/test/test_screen.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
| 27 #include "ui/wm/test/wm_test_helper.h" | 26 #include "ui/wm/test/wm_test_helper.h" |
| 28 | 27 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 86 |
| 88 // TODO(jamescook): Create the rest of the services using | 87 // TODO(jamescook): Create the rest of the services using |
| 89 // BrowserContextDependencyManager::CreateBrowserContextServices. | 88 // BrowserContextDependencyManager::CreateBrowserContextServices. |
| 90 | 89 |
| 91 CreateRootWindow(); | 90 CreateRootWindow(); |
| 92 | 91 |
| 93 const std::string kAppSwitch = "app"; | 92 const std::string kAppSwitch = "app"; |
| 94 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 93 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 95 if (command_line->HasSwitch(kAppSwitch)) { | 94 if (command_line->HasSwitch(kAppSwitch)) { |
| 96 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); | 95 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); |
| 97 LoadAndLaunchApp(app_dir); | 96 extension_system_->LoadAndLaunchApp(app_dir); |
| 98 } else { | 97 } else { |
| 99 // TODO(jamescook): For demo purposes create a window with a WebView just | 98 // TODO(jamescook): For demo purposes create a window with a WebView just |
| 100 // to ensure that the content module is properly initialized. | 99 // to ensure that the content module is properly initialized. |
| 101 ShowWebViewWindow(browser_context_.get(), | 100 ShowWebViewWindow(browser_context_.get(), |
| 102 wm_test_helper_->root_window()->window()); | 101 wm_test_helper_->root_window()->window()); |
| 103 } | 102 } |
| 104 } | 103 } |
| 105 | 104 |
| 106 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 105 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 107 base::RunLoop run_loop; | 106 base::RunLoop run_loop; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 DCHECK(browser_context_); | 151 DCHECK(browser_context_); |
| 153 extension_system_ = | 152 extension_system_ = |
| 154 new extensions::ShellExtensionSystem(browser_context_.get()); | 153 new extensions::ShellExtensionSystem(browser_context_.get()); |
| 155 extensions::ExtensionSystemFactory::GetInstance()->SetCustomInstance( | 154 extensions::ExtensionSystemFactory::GetInstance()->SetCustomInstance( |
| 156 extension_system_); | 155 extension_system_); |
| 157 // Must occur after setting the instance above, as it will end up calling | 156 // Must occur after setting the instance above, as it will end up calling |
| 158 // ExtensionSystem::Get(). | 157 // ExtensionSystem::Get(). |
| 159 extension_system_->InitForRegularProfile(true); | 158 extension_system_->InitForRegularProfile(true); |
| 160 } | 159 } |
| 161 | 160 |
| 162 bool ShellBrowserMainParts::LoadAndLaunchApp(const base::FilePath& app_dir) { | |
| 163 DCHECK(extension_system_); | |
| 164 std::string load_error; | |
| 165 scoped_refptr<Extension> extension = | |
| 166 extension_file_util::LoadExtension(app_dir, | |
| 167 extensions::Manifest::COMMAND_LINE, | |
| 168 Extension::NO_FLAGS, | |
| 169 &load_error); | |
| 170 if (!extension) { | |
| 171 LOG(ERROR) << "Loading extension at " << app_dir.value() | |
| 172 << " failed with: " << load_error; | |
| 173 return false; | |
| 174 } | |
| 175 | |
| 176 // TODO(jamescook): Add to ExtensionRegistry. | |
| 177 // TODO(jamescook): Set ExtensionSystem ready. | |
| 178 // TODO(jamescook): Send NOTIFICATION_EXTENSION_LOADED. | |
| 179 return true; | |
| 180 } | |
| 181 | |
| 182 } // namespace apps | 161 } // namespace apps |
| OLD | NEW |