Chromium Code Reviews| 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/home/public/home_card.h" | 7 #include "athena/home/public/home_card.h" |
| 8 #include "athena/main/athena_app_window_controller.h" | 8 #include "athena/main/athena_app_window_controller.h" |
| 9 #include "athena/main/athena_launcher.h" | 9 #include "athena/main/athena_launcher.h" |
| 10 #include "athena/main/debug/debug_window.h" | 10 #include "athena/main/debug/debug_window.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "extensions/shell/browser/shell_content_browser_client.h" | 22 #include "extensions/shell/browser/shell_content_browser_client.h" |
| 23 #include "extensions/shell/browser/shell_desktop_controller.h" | 23 #include "extensions/shell/browser/shell_desktop_controller.h" |
| 24 #include "extensions/shell/browser/shell_extension_system.h" | 24 #include "extensions/shell/browser/shell_extension_system.h" |
| 25 #include "extensions/shell/common/switches.h" | 25 #include "extensions/shell/common/switches.h" |
| 26 #include "extensions/shell/renderer/shell_renderer_main_delegate.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/views/views_delegate.h" | |
| 32 #include "ui/wm/core/visibility_controller.h" | 33 #include "ui/wm/core/visibility_controller.h" |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 // We want to load the sample calculator app by default, for a while. Expecting | 37 // We want to load the sample calculator app by default, for a while. Expecting |
| 37 // to run athena_main at src/ | 38 // to run athena_main at src/ |
| 38 const char kDefaultAppPath[] = | 39 const char kDefaultAppPath[] = |
| 39 "chrome/common/extensions/docs/examples/apps/calculator/app"; | 40 "chrome/common/extensions/docs/examples/apps/calculator/app"; |
| 40 } // namespace | 41 } // namespace |
| 41 | 42 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 // extensions::ShellDesktopController: | 70 // extensions::ShellDesktopController: |
| 70 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { | 71 virtual wm::FocusRules* CreateFocusRules() OVERRIDE { |
| 71 return athena::ScreenManager::CreateFocusRules(); | 72 return athena::ScreenManager::CreateFocusRules(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); | 75 DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController); |
| 75 }; | 76 }; |
| 76 | 77 |
| 78 class AthenaViewsDelegate : public views::ViewsDelegate { | |
| 79 public: | |
| 80 AthenaViewsDelegate() {} | |
| 81 virtual ~AthenaViewsDelegate() {} | |
| 82 | |
| 83 private: | |
| 84 virtual void OnBeforeWidgetInit( | |
|
sadrul
2014/07/25 20:43:14
// views::ViewsDelegate:
mohsen
2014/07/30 22:49:46
Done.
| |
| 85 views::Widget::InitParams* params, | |
| 86 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { | |
| 87 } | |
| 88 | |
| 89 DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); | |
| 90 }; | |
| 91 | |
| 77 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { | 92 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { |
| 78 public: | 93 public: |
| 79 AthenaBrowserMainDelegate() {} | 94 AthenaBrowserMainDelegate() {} |
| 80 virtual ~AthenaBrowserMainDelegate() {} | 95 virtual ~AthenaBrowserMainDelegate() {} |
| 81 | 96 |
| 82 // extensions::ShellBrowserMainDelegate: | 97 // extensions::ShellBrowserMainDelegate: |
| 83 virtual void Start(content::BrowserContext* context) OVERRIDE { | 98 virtual void Start(content::BrowserContext* context) OVERRIDE { |
| 84 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 99 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 85 | 100 |
| 86 // Force showing in the experimental app-list view. | 101 // Force showing in the experimental app-list view. |
| 87 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); | 102 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); |
| 88 | 103 |
| 89 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( | 104 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
| 90 command_line->HasSwitch(extensions::switches::kAppShellAppPath) | 105 command_line->HasSwitch(extensions::switches::kAppShellAppPath) |
| 91 ? command_line->GetSwitchValueNative( | 106 ? command_line->GetSwitchValueNative( |
| 92 extensions::switches::kAppShellAppPath) | 107 extensions::switches::kAppShellAppPath) |
| 93 : kDefaultAppPath); | 108 : kDefaultAppPath); |
| 94 | 109 |
| 95 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 110 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
| 96 if (base::DirectoryExists(app_absolute_dir)) { | 111 if (base::DirectoryExists(app_absolute_dir)) { |
| 97 extensions::ShellExtensionSystem* extension_system = | 112 extensions::ShellExtensionSystem* extension_system = |
| 98 static_cast<extensions::ShellExtensionSystem*>( | 113 static_cast<extensions::ShellExtensionSystem*>( |
| 99 extensions::ExtensionSystem::Get(context)); | 114 extensions::ExtensionSystem::Get(context)); |
| 100 extension_system->LoadApp(app_absolute_dir); | 115 extension_system->LoadApp(app_absolute_dir); |
| 101 } | 116 } |
| 102 | 117 |
| 118 views::ViewsDelegate::views_delegate = &views_delegate_; | |
| 119 | |
| 103 athena::StartAthena( | 120 athena::StartAthena( |
| 104 extensions::ShellDesktopController::instance()->host()->window(), | 121 extensions::ShellDesktopController::instance()->host()->window(), |
| 105 new athena::ContentActivityFactory(), | 122 new athena::ContentActivityFactory(), |
| 106 new athena::ContentAppModelBuilder(context)); | 123 new athena::ContentAppModelBuilder(context)); |
| 107 athena::HomeCard::Get()->RegisterSearchProvider( | 124 athena::HomeCard::Get()->RegisterSearchProvider( |
| 108 new athena::UrlSearchProvider(context)); | 125 new athena::UrlSearchProvider(context)); |
| 109 athena::VirtualKeyboardManager::Create(context); | 126 athena::VirtualKeyboardManager::Create(context); |
| 110 keyboard_observer_.reset(new VirtualKeyboardObserver()); | 127 keyboard_observer_.reset(new VirtualKeyboardObserver()); |
| 111 | 128 |
| 112 CreateTestPages(context); | 129 CreateTestPages(context); |
| 113 CreateDebugWindow(); | 130 CreateDebugWindow(); |
| 114 } | 131 } |
| 115 | 132 |
| 116 virtual void Shutdown() OVERRIDE { | 133 virtual void Shutdown() OVERRIDE { |
| 117 keyboard_observer_.reset(); | 134 keyboard_observer_.reset(); |
| 118 athena::ShutdownAthena(); | 135 athena::ShutdownAthena(); |
| 136 | |
| 137 views::ViewsDelegate::views_delegate = NULL; | |
| 119 } | 138 } |
| 120 | 139 |
| 121 virtual extensions::ShellDesktopController* CreateDesktopController() | 140 virtual extensions::ShellDesktopController* CreateDesktopController() |
| 122 OVERRIDE { | 141 OVERRIDE { |
| 123 // TODO(mukai): create Athena's own ShellDesktopController subclass so that | 142 // TODO(mukai): create Athena's own ShellDesktopController subclass so that |
| 124 // it can initialize its own window manager logic. | 143 // it can initialize its own window manager logic. |
| 125 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); | 144 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); |
| 126 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); | 145 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); |
| 127 return desktop; | 146 return desktop; |
| 128 } | 147 } |
| 129 | 148 |
| 130 private: | 149 private: |
| 150 AthenaViewsDelegate views_delegate_; | |
| 131 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; | 151 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; |
| 132 | 152 |
| 133 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); | 153 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); |
| 134 }; | 154 }; |
| 135 | 155 |
| 136 class AthenaContentBrowserClient | 156 class AthenaContentBrowserClient |
| 137 : public extensions::ShellContentBrowserClient { | 157 : public extensions::ShellContentBrowserClient { |
| 138 public: | 158 public: |
| 139 AthenaContentBrowserClient() | 159 AthenaContentBrowserClient() |
| 140 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { | 160 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 | 220 |
| 201 int main(int argc, const char** argv) { | 221 int main(int argc, const char** argv) { |
| 202 AthenaMainDelegate delegate; | 222 AthenaMainDelegate delegate; |
| 203 content::ContentMainParams params(&delegate); | 223 content::ContentMainParams params(&delegate); |
| 204 | 224 |
| 205 params.argc = argc; | 225 params.argc = argc; |
| 206 params.argv = argv; | 226 params.argv = argv; |
| 207 | 227 |
| 208 return content::ContentMain(params); | 228 return content::ContentMain(params); |
| 209 } | 229 } |
| OLD | NEW |