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/browser_context_keyed_service_factories.h" |
7 #include "apps/shell/browser/shell_apps_client.h" | 8 #include "apps/shell/browser/shell_apps_client.h" |
8 #include "apps/shell/browser/shell_browser_context.h" | 9 #include "apps/shell/browser/shell_browser_context.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/browser/web_view_window.h" | 13 #include "apps/shell/browser/web_view_window.h" |
13 #include "apps/shell/common/shell_extensions_client.h" | 14 #include "apps/shell/common/shell_extensions_client.h" |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/file_util.h" | 16 #include "base/file_util.h" |
16 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
17 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 19 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
19 #include "content/public/common/result_codes.h" | 20 #include "content/public/common/result_codes.h" |
20 #include "content/shell/browser/shell_devtools_delegate.h" | 21 #include "content/shell/browser/shell_devtools_delegate.h" |
21 #include "content/shell/browser/shell_net_log.h" | 22 #include "content/shell/browser/shell_net_log.h" |
| 23 #include "extensions/browser/context_keyed_service_factories.h" |
22 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
23 #include "extensions/browser/renderer_startup_helper.h" | |
24 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
25 #include "ui/aura/test/test_screen.h" | 26 #include "ui/aura/test/test_screen.h" |
26 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
27 #include "ui/aura/window_tree_host.h" | 28 #include "ui/aura/window_tree_host.h" |
28 #include "ui/base/ime/input_method_initializer.h" | 29 #include "ui/base/ime/input_method_initializer.h" |
29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
30 #include "ui/gfx/screen.h" | 31 #include "ui/gfx/screen.h" |
31 #include "ui/views/test/test_views_delegate.h" | 32 #include "ui/views/test/test_views_delegate.h" |
32 #include "ui/views/views_delegate.h" | 33 #include "ui/views/views_delegate.h" |
33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
34 #include "ui/wm/test/wm_test_helper.h" | 35 #include "ui/wm/test/wm_test_helper.h" |
35 | 36 |
36 using content::BrowserContext; | 37 using content::BrowserContext; |
37 using extensions::Extension; | 38 using extensions::Extension; |
38 using extensions::ExtensionSystem; | 39 using extensions::ExtensionSystem; |
39 using extensions::ShellExtensionSystem; | 40 using extensions::ShellExtensionSystem; |
40 | 41 |
41 namespace apps { | |
42 namespace { | 42 namespace { |
43 | 43 |
44 // Register additional KeyedService factories here. See | 44 // Register additional KeyedService factories here. See |
45 // ChromeBrowserMainExtraPartsProfiles for details. | 45 // ChromeBrowserMainExtraPartsProfiles for details. |
46 void EnsureBrowserContextKeyedServiceFactoriesBuilt() { | 46 void EnsureBrowserContextKeyedServiceFactoriesBuilt() { |
47 extensions::RendererStartupHelperFactory::GetInstance(); | 47 apps::EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
| 48 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
48 extensions::ShellExtensionSystemFactory::GetInstance(); | 49 extensions::ShellExtensionSystemFactory::GetInstance(); |
49 } | 50 } |
50 | 51 |
51 // A ViewsDelegate to attach new unparented windows to app_shell's root window. | 52 // A ViewsDelegate to attach new unparented windows to app_shell's root window. |
52 class ShellViewsDelegate : public views::TestViewsDelegate { | 53 class ShellViewsDelegate : public views::TestViewsDelegate { |
53 public: | 54 public: |
54 explicit ShellViewsDelegate(aura::Window* root_window) | 55 explicit ShellViewsDelegate(aura::Window* root_window) |
55 : root_window_(root_window) {} | 56 : root_window_(root_window) {} |
56 virtual ~ShellViewsDelegate() {} | 57 virtual ~ShellViewsDelegate() {} |
57 | 58 |
58 // views::ViewsDelegate implementation. | 59 // views::ViewsDelegate implementation. |
59 virtual void OnBeforeWidgetInit( | 60 virtual void OnBeforeWidgetInit( |
60 views::Widget::InitParams* params, | 61 views::Widget::InitParams* params, |
61 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { | 62 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { |
62 if (!params->parent) | 63 if (!params->parent) |
63 params->parent = root_window_; | 64 params->parent = root_window_; |
64 } | 65 } |
65 | 66 |
66 private: | 67 private: |
67 aura::Window* root_window_; | 68 aura::Window* root_window_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegate); |
70 }; | 71 }; |
71 | 72 |
72 } // namespace | 73 } // namespace |
73 | 74 |
| 75 namespace apps { |
| 76 |
74 ShellBrowserMainParts::ShellBrowserMainParts( | 77 ShellBrowserMainParts::ShellBrowserMainParts( |
75 const content::MainFunctionParams& parameters) | 78 const content::MainFunctionParams& parameters) |
76 : extension_system_(NULL) { | 79 : extension_system_(NULL) { |
77 } | 80 } |
78 | 81 |
79 ShellBrowserMainParts::~ShellBrowserMainParts() { | 82 ShellBrowserMainParts::~ShellBrowserMainParts() { |
80 } | 83 } |
81 | 84 |
82 void ShellBrowserMainParts::PreMainMessageLoopStart() { | 85 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
83 // TODO(jamescook): Initialize touch here? | 86 // TODO(jamescook): Initialize touch here? |
(...skipping 30 matching lines...) Expand all Loading... |
114 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | 117 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
115 | 118 |
116 apps_client_.reset(new ShellAppsClient(browser_context_.get())); | 119 apps_client_.reset(new ShellAppsClient(browser_context_.get())); |
117 AppsClient::Set(apps_client_.get()); | 120 AppsClient::Set(apps_client_.get()); |
118 | 121 |
119 // Create our custom ExtensionSystem first because other | 122 // Create our custom ExtensionSystem first because other |
120 // KeyedServices depend on it. | 123 // KeyedServices depend on it. |
121 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. | 124 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. |
122 CreateExtensionSystem(); | 125 CreateExtensionSystem(); |
123 | 126 |
124 EnsureBrowserContextKeyedServiceFactoriesBuilt(); | 127 ::EnsureBrowserContextKeyedServiceFactoriesBuilt(); |
125 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 128 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |
126 browser_context_.get()); | 129 browser_context_.get()); |
127 | 130 |
128 devtools_delegate_.reset( | 131 devtools_delegate_.reset( |
129 new content::ShellDevToolsDelegate(browser_context_.get())); | 132 new content::ShellDevToolsDelegate(browser_context_.get())); |
130 | 133 |
131 CreateRootWindow(); | 134 CreateRootWindow(); |
132 CreateViewsDelegate(); | 135 CreateViewsDelegate(); |
133 | 136 |
134 const std::string kAppSwitch = "app"; | 137 const std::string kAppSwitch = "app"; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 211 } |
209 | 212 |
210 void ShellBrowserMainParts::CreateExtensionSystem() { | 213 void ShellBrowserMainParts::CreateExtensionSystem() { |
211 DCHECK(browser_context_); | 214 DCHECK(browser_context_); |
212 extension_system_ = static_cast<ShellExtensionSystem*>( | 215 extension_system_ = static_cast<ShellExtensionSystem*>( |
213 ExtensionSystem::Get(browser_context_.get())); | 216 ExtensionSystem::Get(browser_context_.get())); |
214 extension_system_->InitForRegularProfile(true); | 217 extension_system_->InitForRegularProfile(true); |
215 } | 218 } |
216 | 219 |
217 } // namespace apps | 220 } // namespace apps |
OLD | NEW |