OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app/shell_main_delegate.h" | |
6 #include "apps/shell/browser/shell_browser_main_delegate.h" | |
7 #include "apps/shell/browser/shell_content_browser_client.h" | |
8 #include "apps/shell/browser/shell_desktop_controller.h" | |
9 #include "apps/shell/browser/shell_extension_system.h" | |
10 #include "apps/shell/common/switches.h" | |
11 #include "apps/shell/renderer/shell_renderer_main_delegate.h" | |
12 #include "athena/content/public/content_activity_factory.h" | 5 #include "athena/content/public/content_activity_factory.h" |
13 #include "athena/content/public/content_app_model_builder.h" | 6 #include "athena/content/public/content_app_model_builder.h" |
14 #include "athena/home/public/home_card.h" | 7 #include "athena/home/public/home_card.h" |
15 #include "athena/main/athena_app_window_controller.h" | 8 #include "athena/main/athena_app_window_controller.h" |
16 #include "athena/main/athena_launcher.h" | 9 #include "athena/main/athena_launcher.h" |
17 #include "athena/main/debug/debug_window.h" | 10 #include "athena/main/debug/debug_window.h" |
18 #include "athena/main/placeholder.h" | 11 #include "athena/main/placeholder.h" |
19 #include "athena/main/url_search_provider.h" | 12 #include "athena/main/url_search_provider.h" |
20 #include "athena/screen/public/screen_manager.h" | 13 #include "athena/screen/public/screen_manager.h" |
21 #include "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" | 14 #include "athena/virtual_keyboard/public/virtual_keyboard_bindings.h" |
22 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h" | 15 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h" |
23 #include "base/command_line.h" | 16 #include "base/command_line.h" |
24 #include "base/file_util.h" | 17 #include "base/file_util.h" |
25 #include "base/path_service.h" | 18 #include "base/path_service.h" |
26 #include "content/public/app/content_main.h" | 19 #include "content/public/app/content_main.h" |
| 20 #include "extensions/shell/app/shell_main_delegate.h" |
| 21 #include "extensions/shell/browser/shell_browser_main_delegate.h" |
| 22 #include "extensions/shell/browser/shell_content_browser_client.h" |
| 23 #include "extensions/shell/browser/shell_desktop_controller.h" |
| 24 #include "extensions/shell/browser/shell_extension_system.h" |
| 25 #include "extensions/shell/common/switches.h" |
| 26 #include "extensions/shell/renderer/shell_renderer_main_delegate.h" |
27 #include "ui/app_list/app_list_switches.h" | 27 #include "ui/app_list/app_list_switches.h" |
28 #include "ui/aura/window_tree_host.h" | 28 #include "ui/aura/window_tree_host.h" |
29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
30 #include "ui/keyboard/keyboard_controller.h" | 30 #include "ui/keyboard/keyboard_controller.h" |
31 #include "ui/keyboard/keyboard_controller_observer.h" | 31 #include "ui/keyboard/keyboard_controller_observer.h" |
32 #include "ui/wm/core/visibility_controller.h" | 32 #include "ui/wm/core/visibility_controller.h" |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 // We want to load the sample calculator app by default, for a while. Expecting | 36 // We want to load the sample calculator app by default, for a while. Expecting |
(...skipping 16 matching lines...) Expand all Loading... |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE { | 56 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE { |
57 athena::HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds); | 57 athena::HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds); |
58 } | 58 } |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver); | 60 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver); |
61 }; | 61 }; |
62 | 62 |
63 class AthenaDesktopController : public apps::ShellDesktopController { | 63 class AthenaDesktopController : public extensions::ShellDesktopController { |
64 public: | 64 public: |
65 AthenaDesktopController() {} | 65 AthenaDesktopController() {} |
66 virtual ~AthenaDesktopController() {} | 66 virtual ~AthenaDesktopController() {} |
67 | 67 |
68 private: | 68 private: |
69 // apps::ShellDesktopController: | 69 // extensions::ShellDesktopController: |
70 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { | 70 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { |
71 return athena::ScreenManager::CreateFocusRules(); | 71 return athena::ScreenManager::CreateFocusRules(); |
72 } | 72 } |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); | 74 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); |
75 }; | 75 }; |
76 | 76 |
77 class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate { | 77 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { |
78 public: | 78 public: |
79 AthenaBrowserMainDelegate() {} | 79 AthenaBrowserMainDelegate() {} |
80 virtual ~AthenaBrowserMainDelegate() {} | 80 virtual ~AthenaBrowserMainDelegate() {} |
81 | 81 |
82 // apps::ShellBrowserMainDelegate: | 82 // extensions::ShellBrowserMainDelegate: |
83 virtual void Start(content::BrowserContext* context) OVERRIDE { | 83 virtual void Start(content::BrowserContext* context) OVERRIDE { |
84 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 84 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
85 | 85 |
86 // Force showing in the experimental app-list view. | 86 // Force showing in the experimental app-list view. |
87 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); | 87 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); |
88 | 88 |
89 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( | 89 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
90 command_line->HasSwitch(apps::switches::kAppShellAppPath) ? | 90 command_line->HasSwitch(extensions::switches::kAppShellAppPath) |
91 command_line->GetSwitchValueNative(apps::switches::kAppShellAppPath) : | 91 ? command_line->GetSwitchValueNative( |
92 kDefaultAppPath); | 92 extensions::switches::kAppShellAppPath) |
| 93 : kDefaultAppPath); |
93 | 94 |
94 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 95 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
95 if (base::DirectoryExists(app_absolute_dir)) { | 96 if (base::DirectoryExists(app_absolute_dir)) { |
96 extensions::ShellExtensionSystem* extension_system = | 97 extensions::ShellExtensionSystem* extension_system = |
97 static_cast<extensions::ShellExtensionSystem*>( | 98 static_cast<extensions::ShellExtensionSystem*>( |
98 extensions::ExtensionSystem::Get(context)); | 99 extensions::ExtensionSystem::Get(context)); |
99 extension_system->LoadApp(app_absolute_dir); | 100 extension_system->LoadApp(app_absolute_dir); |
100 } | 101 } |
101 | 102 |
102 athena::StartAthena( | 103 athena::StartAthena( |
103 apps::ShellDesktopController::instance()->host()->window(), | 104 extensions::ShellDesktopController::instance()->host()->window(), |
104 new athena::ContentActivityFactory(), | 105 new athena::ContentActivityFactory(), |
105 new athena::ContentAppModelBuilder(context)); | 106 new athena::ContentAppModelBuilder(context)); |
106 athena::HomeCard::Get()->RegisterSearchProvider( | 107 athena::HomeCard::Get()->RegisterSearchProvider( |
107 new athena::UrlSearchProvider(context)); | 108 new athena::UrlSearchProvider(context)); |
108 athena::VirtualKeyboardManager::Create(context); | 109 athena::VirtualKeyboardManager::Create(context); |
109 keyboard_observer_.reset(new VirtualKeyboardObserver()); | 110 keyboard_observer_.reset(new VirtualKeyboardObserver()); |
110 | 111 |
111 CreateTestPages(context); | 112 CreateTestPages(context); |
112 CreateDebugWindow(); | 113 CreateDebugWindow(); |
113 } | 114 } |
114 | 115 |
115 virtual void Shutdown() OVERRIDE { | 116 virtual void Shutdown() OVERRIDE { |
116 keyboard_observer_.reset(); | 117 keyboard_observer_.reset(); |
117 athena::ShutdownAthena(); | 118 athena::ShutdownAthena(); |
118 } | 119 } |
119 | 120 |
120 virtual apps::ShellDesktopController* CreateDesktopController() OVERRIDE { | 121 virtual extensions::ShellDesktopController* CreateDesktopController() |
| 122 OVERRIDE { |
121 // TODO(mukai): create Athena's own ShellDesktopController subclass so that | 123 // TODO(mukai): create Athena's own ShellDesktopController subclass so that |
122 // it can initialize its own window manager logic. | 124 // it can initialize its own window manager logic. |
123 apps::ShellDesktopController* desktop = new AthenaDesktopController(); | 125 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); |
124 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); | 126 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); |
125 return desktop; | 127 return desktop; |
126 } | 128 } |
127 | 129 |
128 private: | 130 private: |
129 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; | 131 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; |
130 | 132 |
131 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); | 133 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); |
132 }; | 134 }; |
133 | 135 |
134 class AthenaContentBrowserClient : public apps::ShellContentBrowserClient { | 136 class AthenaContentBrowserClient |
| 137 : public extensions::ShellContentBrowserClient { |
135 public: | 138 public: |
136 AthenaContentBrowserClient() | 139 AthenaContentBrowserClient() |
137 : apps::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) {} | 140 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { |
| 141 } |
138 virtual ~AthenaContentBrowserClient() {} | 142 virtual ~AthenaContentBrowserClient() {} |
139 | 143 |
140 // content::ContentBrowserClient: | 144 // content::ContentBrowserClient: |
141 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate( | 145 virtual content::WebContentsViewDelegate* GetWebContentsViewDelegate( |
142 content::WebContents* web_contents) OVERRIDE { | 146 content::WebContents* web_contents) OVERRIDE { |
143 // TODO(oshima): Implement athena's WebContentsViewDelegate. | 147 // TODO(oshima): Implement athena's WebContentsViewDelegate. |
144 return NULL; | 148 return NULL; |
145 } | 149 } |
146 | 150 |
147 private: | 151 private: |
148 DISALLOW_COPY_AND_ASSIGN(AthenaContentBrowserClient); | 152 DISALLOW_COPY_AND_ASSIGN(AthenaContentBrowserClient); |
149 }; | 153 }; |
150 | 154 |
151 class AthenaRendererMainDelegate : public apps::ShellRendererMainDelegate { | 155 class AthenaRendererMainDelegate |
| 156 : public extensions::ShellRendererMainDelegate { |
152 public: | 157 public: |
153 AthenaRendererMainDelegate() {} | 158 AthenaRendererMainDelegate() {} |
154 virtual ~AthenaRendererMainDelegate() {} | 159 virtual ~AthenaRendererMainDelegate() {} |
155 | 160 |
156 private: | 161 private: |
157 // apps::ShellRendererMainDelegate: | 162 // extensions::ShellRendererMainDelegate: |
158 virtual void OnThreadStarted(content::RenderThread* thread) OVERRIDE {} | 163 virtual void OnThreadStarted(content::RenderThread* thread) OVERRIDE {} |
159 | 164 |
160 virtual void OnViewCreated(content::RenderView* render_view) OVERRIDE { | 165 virtual void OnViewCreated(content::RenderView* render_view) OVERRIDE { |
161 athena::VirtualKeyboardBindings::Create(render_view); | 166 athena::VirtualKeyboardBindings::Create(render_view); |
162 } | 167 } |
163 | 168 |
164 DISALLOW_COPY_AND_ASSIGN(AthenaRendererMainDelegate); | 169 DISALLOW_COPY_AND_ASSIGN(AthenaRendererMainDelegate); |
165 }; | 170 }; |
166 | 171 |
167 class AthenaMainDelegate : public apps::ShellMainDelegate { | 172 class AthenaMainDelegate : public extensions::ShellMainDelegate { |
168 public: | 173 public: |
169 AthenaMainDelegate() {} | 174 AthenaMainDelegate() {} |
170 virtual ~AthenaMainDelegate() {} | 175 virtual ~AthenaMainDelegate() {} |
171 | 176 |
172 private: | 177 private: |
173 // apps::ShellMainDelegate: | 178 // extensions::ShellMainDelegate: |
174 virtual content::ContentBrowserClient* CreateShellContentBrowserClient() | 179 virtual content::ContentBrowserClient* CreateShellContentBrowserClient() |
175 OVERRIDE { | 180 OVERRIDE { |
176 return new AthenaContentBrowserClient(); | 181 return new AthenaContentBrowserClient(); |
177 } | 182 } |
178 | 183 |
179 virtual scoped_ptr<apps::ShellRendererMainDelegate> | 184 virtual scoped_ptr<extensions::ShellRendererMainDelegate> |
180 CreateShellRendererMainDelegate() OVERRIDE { | 185 CreateShellRendererMainDelegate() OVERRIDE { |
181 return scoped_ptr<apps::ShellRendererMainDelegate>( | 186 return scoped_ptr<extensions::ShellRendererMainDelegate>( |
182 new AthenaRendererMainDelegate()); | 187 new AthenaRendererMainDelegate()); |
183 } | 188 } |
184 | 189 |
185 virtual void InitializeResourceBundle() OVERRIDE { | 190 virtual void InitializeResourceBundle() OVERRIDE { |
186 base::FilePath pak_dir; | 191 base::FilePath pak_dir; |
187 PathService::Get(base::DIR_MODULE, &pak_dir); | 192 PathService::Get(base::DIR_MODULE, &pak_dir); |
188 base::FilePath pak_file = | 193 base::FilePath pak_file = |
189 pak_dir.Append(FILE_PATH_LITERAL("athena_resources.pak")); | 194 pak_dir.Append(FILE_PATH_LITERAL("athena_resources.pak")); |
190 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 195 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
191 } | 196 } |
192 | 197 |
193 DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate); | 198 DISALLOW_COPY_AND_ASSIGN(AthenaMainDelegate); |
194 }; | 199 }; |
195 | 200 |
196 int main(int argc, const char** argv) { | 201 int main(int argc, const char** argv) { |
197 AthenaMainDelegate delegate; | 202 AthenaMainDelegate delegate; |
198 content::ContentMainParams params(&delegate); | 203 content::ContentMainParams params(&delegate); |
199 | 204 |
200 params.argc = argc; | 205 params.argc = argc; |
201 params.argv = argv; | 206 params.argv = argv; |
202 | 207 |
203 return content::ContentMain(params); | 208 return content::ContentMain(params); |
204 } | 209 } |
OLD | NEW |