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 // views::ViewsDelegate: | |
85 virtual void OnBeforeWidgetInit( | |
86 views::Widget::InitParams* params, | |
87 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { | |
88 } | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); | |
91 }; | |
92 | |
77 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { | 93 class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate { |
78 public: | 94 public: |
79 AthenaBrowserMainDelegate() {} | 95 AthenaBrowserMainDelegate() {} |
80 virtual ~AthenaBrowserMainDelegate() {} | 96 virtual ~AthenaBrowserMainDelegate() {} |
81 | 97 |
82 // extensions::ShellBrowserMainDelegate: | 98 // extensions::ShellBrowserMainDelegate: |
83 virtual void Start(content::BrowserContext* context) OVERRIDE { | 99 virtual void Start(content::BrowserContext* context) OVERRIDE { |
84 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 100 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
85 | 101 |
86 // Force showing in the experimental app-list view. | 102 // Force showing in the experimental app-list view. |
87 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); | 103 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); |
88 | 104 |
89 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( | 105 base::FilePath app_dir = base::FilePath::FromUTF8Unsafe( |
90 command_line->HasSwitch(extensions::switches::kAppShellAppPath) | 106 command_line->HasSwitch(extensions::switches::kAppShellAppPath) |
91 ? command_line->GetSwitchValueNative( | 107 ? command_line->GetSwitchValueNative( |
92 extensions::switches::kAppShellAppPath) | 108 extensions::switches::kAppShellAppPath) |
93 : kDefaultAppPath); | 109 : kDefaultAppPath); |
94 | 110 |
95 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); | 111 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); |
96 if (base::DirectoryExists(app_absolute_dir)) { | 112 if (base::DirectoryExists(app_absolute_dir)) { |
97 extensions::ShellExtensionSystem* extension_system = | 113 extensions::ShellExtensionSystem* extension_system = |
98 static_cast<extensions::ShellExtensionSystem*>( | 114 static_cast<extensions::ShellExtensionSystem*>( |
99 extensions::ExtensionSystem::Get(context)); | 115 extensions::ExtensionSystem::Get(context)); |
100 extension_system->LoadApp(app_absolute_dir); | 116 extension_system->LoadApp(app_absolute_dir); |
101 } | 117 } |
102 | 118 |
119 views::ViewsDelegate::views_delegate = &views_delegate_; | |
oshima
2014/08/01 17:22:11
can you move this to athena_launcher ?
mohsen
2014/08/01 18:44:26
Done. Please take a look...
| |
120 | |
103 athena::StartAthena( | 121 athena::StartAthena( |
104 extensions::ShellDesktopController::instance()->host()->window(), | 122 extensions::ShellDesktopController::instance()->host()->window(), |
105 new athena::ContentActivityFactory(), | 123 new athena::ContentActivityFactory(), |
106 new athena::ContentAppModelBuilder(context)); | 124 new athena::ContentAppModelBuilder(context)); |
107 athena::HomeCard::Get()->RegisterSearchProvider( | 125 athena::HomeCard::Get()->RegisterSearchProvider( |
108 new athena::UrlSearchProvider(context)); | 126 new athena::UrlSearchProvider(context)); |
109 athena::VirtualKeyboardManager::Create(context); | 127 athena::VirtualKeyboardManager::Create(context); |
110 keyboard_observer_.reset(new VirtualKeyboardObserver()); | 128 keyboard_observer_.reset(new VirtualKeyboardObserver()); |
111 | 129 |
112 CreateTestPages(context); | 130 CreateTestPages(context); |
113 CreateDebugWindow(); | 131 CreateDebugWindow(); |
114 } | 132 } |
115 | 133 |
116 virtual void Shutdown() OVERRIDE { | 134 virtual void Shutdown() OVERRIDE { |
117 keyboard_observer_.reset(); | 135 keyboard_observer_.reset(); |
118 athena::ShutdownAthena(); | 136 athena::ShutdownAthena(); |
137 | |
138 views::ViewsDelegate::views_delegate = NULL; | |
119 } | 139 } |
120 | 140 |
121 virtual extensions::ShellDesktopController* CreateDesktopController() | 141 virtual extensions::ShellDesktopController* CreateDesktopController() |
122 OVERRIDE { | 142 OVERRIDE { |
123 // TODO(mukai): create Athena's own ShellDesktopController subclass so that | 143 // TODO(mukai): create Athena's own ShellDesktopController subclass so that |
124 // it can initialize its own window manager logic. | 144 // it can initialize its own window manager logic. |
125 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); | 145 extensions::ShellDesktopController* desktop = new AthenaDesktopController(); |
126 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); | 146 desktop->SetAppWindowController(new athena::AthenaAppWindowController()); |
127 return desktop; | 147 return desktop; |
128 } | 148 } |
129 | 149 |
130 private: | 150 private: |
151 AthenaViewsDelegate views_delegate_; | |
131 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; | 152 scoped_ptr<VirtualKeyboardObserver> keyboard_observer_; |
132 | 153 |
133 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); | 154 DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate); |
134 }; | 155 }; |
135 | 156 |
136 class AthenaContentBrowserClient | 157 class AthenaContentBrowserClient |
137 : public extensions::ShellContentBrowserClient { | 158 : public extensions::ShellContentBrowserClient { |
138 public: | 159 public: |
139 AthenaContentBrowserClient() | 160 AthenaContentBrowserClient() |
140 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { | 161 : extensions::ShellContentBrowserClient(new AthenaBrowserMainDelegate()) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 | 221 |
201 int main(int argc, const char** argv) { | 222 int main(int argc, const char** argv) { |
202 AthenaMainDelegate delegate; | 223 AthenaMainDelegate delegate; |
203 content::ContentMainParams params(&delegate); | 224 content::ContentMainParams params(&delegate); |
204 | 225 |
205 params.argc = argc; | 226 params.argc = argc; |
206 params.argv = argv; | 227 params.argv = argv; |
207 | 228 |
208 return content::ContentMain(params); | 229 return content::ContentMain(params); |
209 } | 230 } |
OLD | NEW |