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/system/public/system_ui.h" | 5 #include "athena/system/public/system_ui.h" |
6 | 6 |
7 #include "athena/screen/public/screen_manager.h" | 7 #include "athena/screen/public/screen_manager.h" |
8 #include "athena/system/background_controller.h" | 8 #include "athena/system/background_controller.h" |
9 #include "athena/system/orientation_controller.h" | 9 #include "athena/system/orientation_controller.h" |
10 #include "athena/system/shutdown_dialog.h" | 10 #include "athena/system/shutdown_dialog.h" |
11 #include "athena/system/status_icon_container_view.h" | 11 #include "athena/system/status_icon_container_view.h" |
12 #include "athena/system/time_view.h" | 12 #include "athena/system/time_view.h" |
13 #include "athena/util/container_priorities.h" | 13 #include "athena/util/container_priorities.h" |
14 #include "athena/util/fill_layout_manager.h" | 14 #include "athena/util/fill_layout_manager.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
19 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
20 | 20 |
21 namespace athena { | 21 namespace athena { |
22 namespace { | 22 namespace { |
23 | 23 |
24 SystemUI* instance = NULL; | 24 SystemUI* instance = NULL; |
25 | 25 |
26 // View which positions the TimeView on the left and the StatusIconView on the | 26 // View which positions the TimeView on the left and the StatusIconView on the |
27 // right. | 27 // right. |
28 class SystemInfoView : public views::View { | 28 class SystemInfoView : public views::View { |
29 public: | 29 public: |
30 SystemInfoView(SystemUI::ColorScheme color_scheme, | 30 SystemInfoView(SystemUI::ColorScheme color_scheme) |
31 aura::Window* system_modal_container) | |
32 : time_view_(new TimeView(color_scheme)), | 31 : time_view_(new TimeView(color_scheme)), |
33 status_icon_view_( | 32 status_icon_view_(new StatusIconContainerView(color_scheme)) { |
34 new StatusIconContainerView(color_scheme, system_modal_container)) { | |
35 AddChildView(time_view_); | 33 AddChildView(time_view_); |
36 AddChildView(status_icon_view_); | 34 AddChildView(status_icon_view_); |
37 } | 35 } |
38 | 36 |
39 virtual ~SystemInfoView() { | 37 virtual ~SystemInfoView() { |
40 } | 38 } |
41 | 39 |
42 // views::View: | 40 // views::View: |
43 virtual gfx::Size GetPreferredSize() const override { | 41 virtual gfx::Size GetPreferredSize() const override { |
44 // The view should be as wide as its parent view. | 42 // The view should be as wide as its parent view. |
(...skipping 24 matching lines...) Expand all Loading... |
69 views::View* time_view_; | 67 views::View* time_view_; |
70 views::View* status_icon_view_; | 68 views::View* status_icon_view_; |
71 | 69 |
72 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); | 70 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); |
73 }; | 71 }; |
74 | 72 |
75 class SystemUIImpl : public SystemUI { | 73 class SystemUIImpl : public SystemUI { |
76 public: | 74 public: |
77 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner) | 75 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner) |
78 : orientation_controller_(new OrientationController()), | 76 : orientation_controller_(new OrientationController()), |
79 background_container_(NULL), | 77 background_container_(NULL) { |
80 system_modal_container_(NULL) { | |
81 orientation_controller_->InitWith(blocking_task_runner); | 78 orientation_controller_->InitWith(blocking_task_runner); |
82 } | 79 } |
83 | 80 |
84 virtual ~SystemUIImpl() { | 81 virtual ~SystemUIImpl() { |
85 // Stops file watching now if exists. Waiting until message loop shutdon | 82 // Stops file watching now if exists. Waiting until message loop shutdon |
86 // leads to FilePathWatcher crash. | 83 // leads to FilePathWatcher crash. |
87 orientation_controller_->Shutdown(); | 84 orientation_controller_->Shutdown(); |
88 } | 85 } |
89 | 86 |
90 void Init() { | 87 void Init() { |
91 ScreenManager* screen_manager = ScreenManager::Get(); | 88 ScreenManager* screen_manager = ScreenManager::Get(); |
92 background_container_ = screen_manager->CreateContainer( | 89 background_container_ = screen_manager->CreateContainer( |
93 ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND)); | 90 ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND)); |
94 background_container_->SetLayoutManager( | 91 background_container_->SetLayoutManager( |
95 new FillLayoutManager(background_container_)); | 92 new FillLayoutManager(background_container_)); |
96 ScreenManager::ContainerParams system_modal_params( | |
97 "AthenaSystemModalContainer", CP_SYSTEM_MODAL); | |
98 system_modal_params.can_activate_children = true; | |
99 system_modal_container_ = | |
100 screen_manager->CreateContainer(system_modal_params); | |
101 login_screen_system_modal_container_ = screen_manager->CreateContainer( | |
102 ScreenManager::ContainerParams("AthenaLoginScreenSystemModalContainer", | |
103 CP_LOGIN_SCREEN_SYSTEM_MODAL)); | |
104 | 93 |
105 // Use |login_screen_system_modal_container_| for the power button's dialog | 94 shutdown_dialog_.reset(new ShutdownDialog()); |
106 // because it needs to show over the login screen. | |
107 // TODO(pkotwicz): Pick the most appropriate container based on whether the | |
108 // user has logged in. | |
109 shutdown_dialog_.reset( | |
110 new ShutdownDialog(login_screen_system_modal_container_)); | |
111 background_controller_.reset( | 95 background_controller_.reset( |
112 new BackgroundController(background_container_)); | 96 new BackgroundController(background_container_)); |
113 } | 97 } |
114 | 98 |
| 99 private: |
| 100 // SystemUI: |
115 virtual void SetBackgroundImage(const gfx::ImageSkia& image) override { | 101 virtual void SetBackgroundImage(const gfx::ImageSkia& image) override { |
116 background_controller_->SetImage(image); | 102 background_controller_->SetImage(image); |
117 } | 103 } |
118 | 104 |
119 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) override { | 105 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) override { |
120 return new SystemInfoView(color_scheme, system_modal_container_); | 106 return new SystemInfoView(color_scheme); |
121 } | 107 } |
122 | 108 |
123 private: | |
124 scoped_ptr<OrientationController> orientation_controller_; | 109 scoped_ptr<OrientationController> orientation_controller_; |
125 scoped_ptr<ShutdownDialog> shutdown_dialog_; | 110 scoped_ptr<ShutdownDialog> shutdown_dialog_; |
126 scoped_ptr<BackgroundController> background_controller_; | 111 scoped_ptr<BackgroundController> background_controller_; |
127 | 112 |
128 // The parent container for the background. | 113 // The parent container for the background. |
129 aura::Window* background_container_; | 114 aura::Window* background_container_; |
130 | 115 |
131 // The parent container used by system modal dialogs. | 116 // The parent container used by system modal dialogs. |
132 aura::Window* system_modal_container_; | 117 aura::Window* system_modal_container_; |
133 | 118 |
(...skipping 22 matching lines...) Expand all Loading... |
156 } | 141 } |
157 | 142 |
158 // static | 143 // static |
159 void SystemUI::Shutdown() { | 144 void SystemUI::Shutdown() { |
160 CHECK(instance); | 145 CHECK(instance); |
161 delete instance; | 146 delete instance; |
162 instance = NULL; | 147 instance = NULL; |
163 } | 148 } |
164 | 149 |
165 } // namespace athena | 150 } // namespace athena |
OLD | NEW |