| 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/device_socket_listener.h" |
| 9 #include "athena/system/orientation_controller.h" | 10 #include "athena/system/orientation_controller.h" |
| 10 #include "athena/system/power_button_controller.h" | 11 #include "athena/system/power_button_controller.h" |
| 11 #include "athena/system/status_icon_container_view.h" | 12 #include "athena/system/status_icon_container_view.h" |
| 12 #include "athena/system/time_view.h" | 13 #include "athena/system/time_view.h" |
| 13 #include "athena/util/container_priorities.h" | 14 #include "athena/util/container_priorities.h" |
| 14 #include "athena/util/fill_layout_manager.h" | 15 #include "athena/util/fill_layout_manager.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 views::View* time_view_; | 70 views::View* time_view_; |
| 70 views::View* status_icon_view_; | 71 views::View* status_icon_view_; |
| 71 | 72 |
| 72 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); | 73 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 class SystemUIImpl : public SystemUI { | 76 class SystemUIImpl : public SystemUI { |
| 76 public: | 77 public: |
| 77 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner) | 78 SystemUIImpl(scoped_refptr<base::TaskRunner> file_task_runner) |
| 78 : orientation_controller_(new OrientationController()), | 79 : orientation_controller_(new OrientationController()), |
| 79 power_button_controller_(new PowerButtonController), | 80 power_button_controller_(new PowerButtonController), |
| 80 background_container_(NULL), | 81 background_container_(NULL), |
| 81 system_modal_container_(NULL) { | 82 system_modal_container_(NULL) { |
| 82 orientation_controller_->InitWith(blocking_task_runner); | 83 orientation_controller_->InitWith(file_task_runner); |
| 83 } | 84 } |
| 84 | 85 |
| 85 virtual ~SystemUIImpl() { | 86 virtual ~SystemUIImpl() { |
| 86 // Stops file watching now if exists. Waiting until message loop shutdon | 87 // Stops file watching now if exists. Waiting until message loop shutdon |
| 87 // leads to FilePathWatcher crash. | 88 // leads to FilePathWatcher crash. |
| 88 orientation_controller_->Shutdown(); | 89 orientation_controller_->Shutdown(); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void Init() { | 92 void Init() { |
| 92 background_container_ = ScreenManager::Get()->CreateContainer( | 93 background_container_ = ScreenManager::Get()->CreateContainer( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 | 106 |
| 106 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE { | 107 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE { |
| 107 background_controller_->SetImage(image); | 108 background_controller_->SetImage(image); |
| 108 } | 109 } |
| 109 | 110 |
| 110 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) OVERRIDE { | 111 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) OVERRIDE { |
| 111 return new SystemInfoView(color_scheme, system_modal_container_); | 112 return new SystemInfoView(color_scheme, system_modal_container_); |
| 112 } | 113 } |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 scoped_ptr<OrientationController> orientation_controller_; | 116 scoped_refptr<OrientationController> orientation_controller_; |
| 116 scoped_ptr<PowerButtonController> power_button_controller_; | 117 scoped_ptr<PowerButtonController> power_button_controller_; |
| 117 scoped_ptr<BackgroundController> background_controller_; | 118 scoped_ptr<BackgroundController> background_controller_; |
| 118 | 119 |
| 119 // The parent container for the background. | 120 // The parent container for the background. |
| 120 aura::Window* background_container_; | 121 aura::Window* background_container_; |
| 121 | 122 |
| 122 // The parent container used by the "select network" dialog. | 123 // The parent container used by the "select network" dialog. |
| 123 aura::Window* system_modal_container_; | 124 aura::Window* system_modal_container_; |
| 124 | 125 |
| 125 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); | 126 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 } // namespace | 129 } // namespace |
| 129 | 130 |
| 130 // static | 131 // static |
| 131 SystemUI* SystemUI::Create( | 132 SystemUI* SystemUI::Create(scoped_refptr<base::TaskRunner> file_task_runner) { |
| 132 scoped_refptr<base::TaskRunner> blocking_task_runner) { | 133 DeviceSocketListener::CreateSocketManager(file_task_runner); |
| 133 SystemUIImpl* system_ui = new SystemUIImpl(blocking_task_runner); | 134 SystemUIImpl* system_ui = new SystemUIImpl(file_task_runner); |
| 134 instance = system_ui; | 135 instance = system_ui; |
| 135 system_ui->Init(); | 136 system_ui->Init(); |
| 136 return instance; | 137 return instance; |
| 137 } | 138 } |
| 138 | 139 |
| 139 // static | 140 // static |
| 140 SystemUI* SystemUI::Get() { | 141 SystemUI* SystemUI::Get() { |
| 141 DCHECK(instance); | 142 DCHECK(instance); |
| 142 return instance; | 143 return instance; |
| 143 } | 144 } |
| 144 | 145 |
| 145 // static | 146 // static |
| 146 void SystemUI::Shutdown() { | 147 void SystemUI::Shutdown() { |
| 147 CHECK(instance); | 148 CHECK(instance); |
| 148 delete instance; | 149 delete instance; |
| 149 instance = NULL; | 150 instance = NULL; |
| 151 DeviceSocketListener::ShutdownSocketManager(); |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace athena | 154 } // namespace athena |
| OLD | NEW |