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