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/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/power_button_controller.h" | 10 #include "athena/system/power_button_controller.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 views::View* time_view_; | 69 views::View* time_view_; |
| 70 views::View* status_icon_view_; | 70 views::View* status_icon_view_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); | 72 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class SystemUIImpl : public SystemUI { | 75 class SystemUIImpl : public SystemUI { |
| 76 public: | 76 public: |
| 77 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner) | 77 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner) |
| 78 : orientation_controller_(new OrientationController()), | 78 : orientation_controller_(new OrientationController()), |
| 79 power_button_controller_(new PowerButtonController), | |
| 80 background_container_(NULL), | 79 background_container_(NULL), |
| 81 system_modal_container_(NULL) { | 80 system_modal_container_(NULL) { |
| 82 orientation_controller_->InitWith(blocking_task_runner); | 81 orientation_controller_->InitWith(blocking_task_runner); |
| 83 } | 82 } |
| 84 | 83 |
| 85 virtual ~SystemUIImpl() { | 84 virtual ~SystemUIImpl() { |
| 86 // Stops file watching now if exists. Waiting until message loop shutdon | 85 // Stops file watching now if exists. Waiting until message loop shutdon |
| 87 // leads to FilePathWatcher crash. | 86 // leads to FilePathWatcher crash. |
| 88 orientation_controller_->Shutdown(); | 87 orientation_controller_->Shutdown(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 void Init() { | 90 void Init() { |
| 92 background_container_ = ScreenManager::Get()->CreateContainer( | 91 ScreenManager* screen_manager = ScreenManager::Get(); |
| 92 background_container_ = screen_manager->CreateContainer( | |
| 93 ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND)); | 93 ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND)); |
| 94 background_container_->SetLayoutManager( | 94 background_container_->SetLayoutManager( |
| 95 new FillLayoutManager(background_container_)); | 95 new FillLayoutManager(background_container_)); |
| 96 ScreenManager::ContainerParams system_modal_params( | 96 ScreenManager::ContainerParams system_modal_params( |
| 97 "AthenaSystemModalContainer", CP_SYSTEM_MODAL); | 97 "AthenaSystemModalContainer", CP_SYSTEM_MODAL); |
| 98 system_modal_params.can_activate_children = true; | 98 system_modal_params.can_activate_children = true; |
| 99 system_modal_container_ = | 99 system_modal_container_ = |
| 100 ScreenManager::Get()->CreateContainer(system_modal_params); | 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)); | |
| 101 | 104 |
| 105 // Use |login_screen_system_modal_container_| for the power button's dialog | |
| 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. | |
|
oshima
2014/09/22 17:20:19
ideally modal dialogs should use the regular (eith
| |
| 109 power_button_controller_.reset( | |
| 110 new PowerButtonController(login_screen_system_modal_container_)); | |
| 102 background_controller_.reset( | 111 background_controller_.reset( |
| 103 new BackgroundController(background_container_)); | 112 new BackgroundController(background_container_)); |
| 104 } | 113 } |
| 105 | 114 |
| 106 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE { | 115 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE { |
| 107 background_controller_->SetImage(image); | 116 background_controller_->SetImage(image); |
| 108 } | 117 } |
| 109 | 118 |
| 110 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) OVERRIDE { | 119 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) OVERRIDE { |
| 111 return new SystemInfoView(color_scheme, system_modal_container_); | 120 return new SystemInfoView(color_scheme, system_modal_container_); |
| 112 } | 121 } |
| 113 | 122 |
| 114 private: | 123 private: |
| 115 scoped_ptr<OrientationController> orientation_controller_; | 124 scoped_ptr<OrientationController> orientation_controller_; |
| 116 scoped_ptr<PowerButtonController> power_button_controller_; | 125 scoped_ptr<PowerButtonController> power_button_controller_; |
| 117 scoped_ptr<BackgroundController> background_controller_; | 126 scoped_ptr<BackgroundController> background_controller_; |
| 118 | 127 |
| 119 // The parent container for the background. | 128 // The parent container for the background. |
| 120 aura::Window* background_container_; | 129 aura::Window* background_container_; |
| 121 | 130 |
| 122 // The parent container used by the "select network" dialog. | 131 // The parent container used by system modal dialogs. |
| 123 aura::Window* system_modal_container_; | 132 aura::Window* system_modal_container_; |
| 124 | 133 |
| 134 // The parent container used by system modal dialogs when the login screen is | |
| 135 // visible. | |
| 136 aura::Window* login_screen_system_modal_container_; | |
| 137 | |
| 125 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); | 138 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); |
| 126 }; | 139 }; |
| 127 | 140 |
| 128 } // namespace | 141 } // namespace |
| 129 | 142 |
| 130 // static | 143 // static |
| 131 SystemUI* SystemUI::Create( | 144 SystemUI* SystemUI::Create( |
| 132 scoped_refptr<base::TaskRunner> blocking_task_runner) { | 145 scoped_refptr<base::TaskRunner> blocking_task_runner) { |
| 133 SystemUIImpl* system_ui = new SystemUIImpl(blocking_task_runner); | 146 SystemUIImpl* system_ui = new SystemUIImpl(blocking_task_runner); |
| 134 instance = system_ui; | 147 instance = system_ui; |
| 135 system_ui->Init(); | 148 system_ui->Init(); |
| 136 return instance; | 149 return instance; |
| 137 } | 150 } |
| 138 | 151 |
| 139 // static | 152 // static |
| 140 SystemUI* SystemUI::Get() { | 153 SystemUI* SystemUI::Get() { |
| 141 DCHECK(instance); | 154 DCHECK(instance); |
| 142 return instance; | 155 return instance; |
| 143 } | 156 } |
| 144 | 157 |
| 145 // static | 158 // static |
| 146 void SystemUI::Shutdown() { | 159 void SystemUI::Shutdown() { |
| 147 CHECK(instance); | 160 CHECK(instance); |
| 148 delete instance; | 161 delete instance; |
| 149 instance = NULL; | 162 instance = NULL; |
| 150 } | 163 } |
| 151 | 164 |
| 152 } // namespace athena | 165 } // namespace athena |
| OLD | NEW |