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/main/athena_launcher.h" | 5 #include "athena/main/athena_launcher.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/content/public/content_activity_factory.h" | |
10 #include "athena/content/public/content_app_model_builder.h" | |
11 #include "athena/home/public/home_card.h" | |
9 #include "athena/home/public/home_card.h" | 12 #include "athena/home/public/home_card.h" |
10 #include "athena/input/public/input_manager.h" | 13 #include "athena/input/public/input_manager.h" |
14 #include "athena/main/debug/debug_window.h" | |
11 #include "athena/main/placeholder.h" | 15 #include "athena/main/placeholder.h" |
16 #include "athena/main/placeholder.h" | |
17 #include "athena/main/url_search_provider.h" | |
18 #include "athena/screen/public/screen_manager.h" | |
12 #include "athena/screen/public/screen_manager.h" | 19 #include "athena/screen/public/screen_manager.h" |
13 #include "athena/system/public/system_ui.h" | 20 #include "athena/system/public/system_ui.h" |
21 #include "athena/virtual_keyboard/public/virtual_keyboard_manager.h" | |
14 #include "athena/wm/public/window_manager.h" | 22 #include "athena/wm/public/window_manager.h" |
23 #include "base/command_line.h" | |
15 #include "base/memory/scoped_ptr.h" | 24 #include "base/memory/scoped_ptr.h" |
16 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "ui/app_list/app_list_switches.h" | |
17 #include "ui/aura/window_property.h" | 27 #include "ui/aura/window_property.h" |
28 #include "ui/keyboard/keyboard_controller.h" | |
29 #include "ui/keyboard/keyboard_controller_observer.h" | |
30 #include "ui/native_theme/native_theme_switches.h" | |
18 #include "ui/views/views_delegate.h" | 31 #include "ui/views/views_delegate.h" |
19 #include "ui/wm/core/visibility_controller.h" | 32 #include "ui/wm/core/visibility_controller.h" |
20 | 33 |
21 #if defined(USE_X11) | 34 #if defined(USE_X11) |
22 #include "ui/events/x/touch_factory_x11.h" | 35 #include "ui/events/x/touch_factory_x11.h" |
23 #endif | 36 #endif |
24 | 37 |
25 namespace athena { | 38 namespace athena { |
26 struct RootWindowState; | 39 struct AthenaEnvState; |
27 } | 40 } |
28 | 41 |
29 DECLARE_WINDOW_PROPERTY_TYPE(athena::RootWindowState*); | 42 DECLARE_WINDOW_PROPERTY_TYPE(athena::AthenaEnvState*); |
30 | 43 |
31 namespace athena { | 44 namespace athena { |
32 | 45 |
33 // Athena's per root window state. | 46 class VirtualKeyboardObserver; |
34 struct RootWindowState { | 47 |
48 // Athena's env state. | |
49 struct AthenaEnvState { | |
35 scoped_ptr< ::wm::VisibilityController> visibility_client; | 50 scoped_ptr< ::wm::VisibilityController> visibility_client; |
51 scoped_ptr<VirtualKeyboardObserver> virtual_keyboard_observer; | |
36 }; | 52 }; |
37 | 53 |
38 DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::RootWindowState, | 54 DEFINE_OWNED_WINDOW_PROPERTY_KEY(athena::AthenaEnvState, |
39 kRootWindowStateKey, | 55 kAthenaEnvStateKey, |
40 NULL); | 56 NULL); |
41 | 57 |
58 // This class observes the change of the virtual keyboard and distribute the | |
59 // change to appropriate modules of athena. | |
60 // TODO(oshima): move the VK bounds logic to screen manager. | |
Jun Mukai
2014/08/19 17:22:35
Note that VK depends on content layer (because VK
oshima
2014/08/19 18:05:49
What I meant is to move the observer interface to
| |
61 class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver { | |
62 public: | |
63 VirtualKeyboardObserver() { | |
64 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
65 } | |
66 | |
67 virtual ~VirtualKeyboardObserver() { | |
68 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
69 } | |
70 | |
71 private: | |
72 virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE { | |
73 HomeCard::Get()->UpdateVirtualKeyboardBounds(new_bounds); | |
74 } | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver); | |
77 }; | |
78 | |
42 class AthenaViewsDelegate : public views::ViewsDelegate { | 79 class AthenaViewsDelegate : public views::ViewsDelegate { |
43 public: | 80 public: |
44 AthenaViewsDelegate() {} | 81 AthenaViewsDelegate() {} |
45 virtual ~AthenaViewsDelegate() {} | 82 virtual ~AthenaViewsDelegate() {} |
46 | 83 |
47 private: | 84 private: |
48 // views::ViewsDelegate: | 85 // views::ViewsDelegate: |
49 virtual void OnBeforeWidgetInit( | 86 virtual void OnBeforeWidgetInit( |
50 views::Widget::InitParams* params, | 87 views::Widget::InitParams* params, |
51 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { | 88 views::internal::NativeWidgetDelegate* delegate) OVERRIDE { |
52 } | 89 } |
53 | 90 |
54 DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); | 91 DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate); |
55 }; | 92 }; |
56 | 93 |
57 void StartAthena(aura::Window* root_window, | 94 void StartAthenaEnv(aura::Window* root_window) { |
58 athena::ActivityFactory* activity_factory, | 95 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
59 athena::AppModelBuilder* app_model_builder) { | 96 |
97 // Force showing in the experimental app-list view. | |
98 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); | |
99 command_line->AppendSwitch(switches::kEnableOverlayScrollbar); | |
100 | |
60 #if defined(USE_X11) | 101 #if defined(USE_X11) |
61 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); | 102 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); |
62 #endif | 103 #endif |
63 | 104 |
64 views::ViewsDelegate::views_delegate = new AthenaViewsDelegate(); | 105 views::ViewsDelegate::views_delegate = new AthenaViewsDelegate(); |
65 | 106 |
66 RootWindowState* root_window_state = new RootWindowState; | 107 AthenaEnvState* env_state = new AthenaEnvState; |
67 root_window->SetProperty(kRootWindowStateKey, root_window_state); | |
68 | 108 |
69 root_window_state->visibility_client.reset(new ::wm::VisibilityController); | 109 // Setup VisibilityClient |
110 env_state->visibility_client.reset(new ::wm::VisibilityController); | |
111 | |
70 aura::client::SetVisibilityClient(root_window, | 112 aura::client::SetVisibilityClient(root_window, |
71 root_window_state->visibility_client.get()); | 113 env_state->visibility_client.get()); |
72 | 114 |
73 athena::SystemUI::Create( | 115 athena::SystemUI::Create( |
74 content::BrowserThread::GetMessageLoopProxyForThread( | 116 content::BrowserThread::GetMessageLoopProxyForThread( |
75 content::BrowserThread::FILE)); | 117 content::BrowserThread::FILE)); |
76 athena::InputManager::Create()->OnRootWindowCreated(root_window); | 118 athena::InputManager::Create()->OnRootWindowCreated(root_window); |
77 athena::ScreenManager::Create(root_window); | 119 athena::ScreenManager::Create(root_window); |
78 athena::WindowManager::Create(); | 120 athena::WindowManager::Create(); |
121 SetupBackgroundImage(); | |
122 | |
123 athena::ScreenManager::Get()->GetContext()->SetProperty( | |
124 kAthenaEnvStateKey, env_state); | |
125 } | |
126 | |
127 void StartAthenaSessionWithContext(content::BrowserContext* context) { | |
128 StartAthenaSession(new athena::ContentActivityFactory(), | |
129 new athena::ContentAppModelBuilder(context)); | |
130 athena::VirtualKeyboardManager::Create(context); | |
131 athena::HomeCard::Get()->RegisterSearchProvider( | |
132 new athena::UrlSearchProvider(context)); | |
133 AthenaEnvState* env_state = | |
134 athena::ScreenManager::Get()->GetContext()->GetProperty( | |
135 kAthenaEnvStateKey); | |
136 | |
137 env_state->virtual_keyboard_observer.reset(new VirtualKeyboardObserver); | |
138 CreateTestPages(context); | |
139 CreateDebugWindow(); | |
140 } | |
141 | |
142 void StartAthenaSession(athena::ActivityFactory* activity_factory, | |
Jun Mukai
2014/08/19 17:22:35
Do we need to keep this?
athena_unittests now depe
oshima
2014/08/19 18:05:49
That's not enough because test doesn't initialize
| |
143 athena::AppModelBuilder* app_model_builder) { | |
79 athena::HomeCard::Create(app_model_builder); | 144 athena::HomeCard::Create(app_model_builder); |
80 athena::ActivityManager::Create(); | 145 athena::ActivityManager::Create(); |
81 athena::ActivityFactory::RegisterActivityFactory(activity_factory); | 146 athena::ActivityFactory::RegisterActivityFactory(activity_factory); |
82 SetupBackgroundImage(); | |
83 } | 147 } |
84 | 148 |
85 void ShutdownAthena() { | 149 void ShutdownAthena() { |
86 athena::ActivityFactory::Shutdown(); | 150 athena::ActivityFactory::Shutdown(); |
87 athena::ActivityManager::Shutdown(); | 151 athena::ActivityManager::Shutdown(); |
88 athena::HomeCard::Shutdown(); | 152 athena::HomeCard::Shutdown(); |
89 athena::WindowManager::Shutdown(); | 153 athena::WindowManager::Shutdown(); |
90 athena::ScreenManager::Shutdown(); | 154 athena::ScreenManager::Shutdown(); |
91 athena::InputManager::Shutdown(); | 155 athena::InputManager::Shutdown(); |
92 athena::SystemUI::Shutdown(); | 156 athena::SystemUI::Shutdown(); |
93 | 157 |
94 delete views::ViewsDelegate::views_delegate; | 158 delete views::ViewsDelegate::views_delegate; |
95 } | 159 } |
96 | 160 |
97 } // namespace athena | 161 } // namespace athena |
OLD | NEW |