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 "athena/content/public/content_activity_factory.h" | 5 #include "athena/content/public/content_activity_factory.h" |
6 #include "athena/content/public/content_app_model_builder.h" | 6 #include "athena/content/public/content_app_model_builder.h" |
7 #include "athena/content/public/web_contents_view_delegate_creator.h" | 7 #include "athena/content/public/web_contents_view_delegate_creator.h" |
8 #include "athena/home/public/home_card.h" | 8 #include "athena/home/public/home_card.h" |
9 #include "athena/main/athena_app_window_controller.h" | 9 #include "athena/main/athena_app_window_controller.h" |
10 #include "athena/main/athena_launcher.h" | 10 #include "athena/main/athena_launcher.h" |
11 #include "athena/main/debug/debug_window.h" | 11 #include "athena/main/debug/debug_window.h" |
12 #include "athena/main/placeholder.h" | 12 #include "athena/main/placeholder.h" |
13 #include "athena/main/url_search_provider.h" | 13 #include "athena/main/url_search_provider.h" |
14 #include "athena/screen/public/screen_manager.h" | 14 #include "athena/screen/public/screen_manager.h" |
| 15 #include "athena/screen/public/screen_manager_delegate.h" |
15 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h" | 16 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h" |
16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
17 #include "base/file_util.h" | 18 #include "base/file_util.h" |
18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
19 #include "content/public/app/content_main.h" | 20 #include "content/public/app/content_main.h" |
20 #include "extensions/shell/app/shell_main_delegate.h" | 21 #include "extensions/shell/app/shell_main_delegate.h" |
21 #include "extensions/shell/browser/shell_browser_main_delegate.h" | 22 #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_content_browser_client.h" |
23 #include "extensions/shell/browser/shell_desktop_controller.h" | 24 #include "extensions/shell/browser/shell_desktop_controller.h" |
24 #include "extensions/shell/browser/shell_extension_system.h" | 25 #include "extensions/shell/browser/shell_extension_system.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 private: | 70 private: |
70 // extensions::ShellDesktopController: | 71 // extensions::ShellDesktopController: |
71 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { | 72 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { |
72 return athena::ScreenManager::CreateFocusRules(); | 73 return athena::ScreenManager::CreateFocusRules(); |
73 } | 74 } |
74 | 75 |
75 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); | 76 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); |
76 }; | 77 }; |
77 | 78 |
| 79 class AthenaScreenManagerDelegate : public athena::ScreenManagerDelegate { |
| 80 public: |
| 81 explicit AthenaScreenManagerDelegate( |
| 82 extensions::ShellDesktopController* controller) |
| 83 : controller_(controller) { |
| 84 } |
| 85 |
| 86 virtual ~AthenaScreenManagerDelegate() { |
| 87 } |
| 88 |
| 89 private: |
| 90 // athena::ScreenManagerDelegate: |
| 91 virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE { |
| 92 controller_->SetDisplayWorkAreaInsets(insets); |
| 93 } |
| 94 |
| 95 // Not owned. |
| 96 extensions::ShellDesktopController* controller_; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(AthenaScreenManagerDelegate); |
| 99 }; |
| 100 |
78 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { | 101 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { |
79 public: | 102 public: |
80 AthenaBrowserMainDelegate() {} | 103 AthenaBrowserMainDelegate() {} |
81 virtual ~AthenaBrowserMainDelegate() {} | 104 virtual ~AthenaBrowserMainDelegate() {} |
82 | 105 |
83 // extensions::ShellBrowserMainDelegate: | 106 // extensions::ShellBrowserMainDelegate: |
84 virtual void Start(content::BrowserContext* context) OVERRIDE { | 107 virtual void Start(content::BrowserContext* context) OVERRIDE { |
85 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 108 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
86 | 109 |
87 // Force showing in the experimental app-list view. | 110 // Force showing in the experimental app-list view. |
88 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); | 111 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); |
89 command_line->AppendSwitch(switches::kEnableOverlayScrollbar); | 112 command_line->AppendSwitch(switches::kEnableOverlayScrollbar); |
90 | 113 |
91 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( | 114 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
92 command_line->HasSwitch(extensions::switches::kAppShellAppPath) | 115 command_line->HasSwitch(extensions::switches::kAppShellAppPath) |
93 ? command_line->GetSwitchValueNative( | 116 ? command_line->GetSwitchValueNative( |
94 extensions::switches::kAppShellAppPath) | 117 extensions::switches::kAppShellAppPath) |
95 : kDefaultAppPath); | 118 : kDefaultAppPath); |
96 | 119 |
97 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 120 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
98 if (base::DirectoryExists(app_absolute_dir)) { | 121 if (base::DirectoryExists(app_absolute_dir)) { |
99 extensions::ShellExtensionSystem* extension_system = | 122 extensions::ShellExtensionSystem* extension_system = |
100 static_cast<extensions::ShellExtensionSystem*>( | 123 static_cast<extensions::ShellExtensionSystem*>( |
101 extensions::ExtensionSystem::Get(context)); | 124 extensions::ExtensionSystem::Get(context)); |
102 extension_system->LoadApp(app_absolute_dir); | 125 extension_system->LoadApp(app_absolute_dir); |
103 } | 126 } |
104 | 127 |
| 128 extensions::ShellDesktopController* desktop_controller = |
| 129 extensions::ShellDesktopController::instance(); |
| 130 screen_manager_delegate_.reset( |
| 131 new AthenaScreenManagerDelegate(desktop_controller)); |
| 132 |
105 athena::StartAthena( | 133 athena::StartAthena( |
106 extensions::ShellDesktopController::instance()->host()->window(), | 134 desktop_controller->host()->window(), |
| 135 screen_manager_delegate_.get(), |
107 new athena::ContentActivityFactory(), | 136 new athena::ContentActivityFactory(), |
108 new athena::ContentAppModelBuilder(context)); | 137 new athena::ContentAppModelBuilder(context)); |
109 athena::HomeCard::Get()->RegisterSearchProvider( | 138 athena::HomeCard::Get()->RegisterSearchProvider( |
110 new athena::UrlSearchProvider(context)); | 139 new athena::UrlSearchProvider(context)); |
111 athena::VirtualKeyboardManager::Create(context); | 140 athena::VirtualKeyboardManager::Create(context); |
112 keyboard_observer_.reset(new VirtualKeyboardObserver()); | 141 keyboard_observer_.reset(new VirtualKeyboardObserver()); |
113 | 142 |
114 CreateTestPages(context); | 143 CreateTestPages(context); |
115 CreateDebugWindow(); | 144 CreateDebugWindow(); |
116 } | 145 } |
117 | 146 |
118 virtual void Shutdown() OVERRIDE { | 147 virtual void Shutdown() OVERRIDE { |
119 keyboard_observer_.reset(); | 148 keyboard_observer_.reset(); |
120 athena::ShutdownAthena(); | 149 athena::ShutdownAthena(); |
121 } | 150 } |
122 | 151 |
123 virtual extensions::ShellDesktopController* CreateDesktopController() | 152 virtual extensions::ShellDesktopController* CreateDesktopController() |
124 OVERRIDE { | 153 OVERRIDE { |
125 // TODO(mukai): create Athena's own ShellDesktopController subclass so that | 154 // TODO(mukai): create Athena's own ShellDesktopController subclass so that |
126 // it can initialize its own window manager logic. | 155 // it can initialize its own window manager logic. |
127 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); | 156 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); |
128 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); | 157 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); |
129 return desktop; | 158 return desktop; |
130 } | 159 } |
131 | 160 |
132 private: | 161 private: |
133 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; | 162 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; |
| 163 scoped_ptr<AthenaScreenManagerDelegate> screen_manager_delegate_; |
134 | 164 |
135 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); | 165 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); |
136 }; | 166 }; |
137 | 167 |
138 class AthenaContentBrowserClient | 168 class AthenaContentBrowserClient |
139 : public extensions::ShellContentBrowserClient { | 169 : public extensions::ShellContentBrowserClient { |
140 public: | 170 public: |
141 AthenaContentBrowserClient() | 171 AthenaContentBrowserClient() |
142 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { | 172 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { |
143 } | 173 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 230 |
201 int main(int argc, const char** argv) { | 231 int main(int argc, const char** argv) { |
202 AthenaMainDelegate delegate; | 232 AthenaMainDelegate delegate; |
203 content::ContentMainParams params(&delegate); | 233 content::ContentMainParams params(&delegate); |
204 | 234 |
205 params.argc = argc; | 235 params.argc = argc; |
206 params.argv = argv; | 236 params.argv = argv; |
207 | 237 |
208 return content::ContentMain(params); | 238 return content::ContentMain(params); |
209 } | 239 } |
OLD | NEW |