Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: athena/system/system_ui_impl.cc

Issue 715053003: Introduce system_info as an independent container. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « athena/system/public/system_ui.h ('k') | athena/util/athena_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/athena_constants.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"
16 #include "athena/wm/public/window_manager.h"
17 #include "athena/wm/public/window_manager_observer.h"
15 #include "base/logging.h" 18 #include "base/logging.h"
16 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
18 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/compositor/scoped_layer_animation_settings.h"
23 #include "ui/gfx/animation/tween.h"
24 #include "ui/gfx/transform.h"
19 #include "ui/views/view.h" 25 #include "ui/views/view.h"
26 #include "ui/views/widget/widget.h"
27 #include "ui/views/widget/widget_observer.h"
28 #include "ui/wm/core/visibility_controller.h"
29 #include "ui/wm/core/window_animations.h"
oshima 2014/11/12 22:38:10 nit: can you cleanup includes?
Jun Mukai 2014/11/13 01:15:49 Done.
20 30
21 namespace athena { 31 namespace athena {
22 namespace { 32 namespace {
23 33
24 SystemUI* instance = nullptr; 34 SystemUI* instance = nullptr;
25 35
26 // View which positions the TimeView on the left and the StatusIconView on the 36 // View which positions the TimeView on the left and the StatusIconView on the
27 // right. 37 // right.
28 class SystemInfoView : public views::View { 38 class SystemInfoView : public views::View {
29 public: 39 public:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 Layout(); 72 Layout();
63 } 73 }
64 74
65 private: 75 private:
66 views::View* time_view_; 76 views::View* time_view_;
67 views::View* status_icon_view_; 77 views::View* status_icon_view_;
68 78
69 DISALLOW_COPY_AND_ASSIGN(SystemInfoView); 79 DISALLOW_COPY_AND_ASSIGN(SystemInfoView);
70 }; 80 };
71 81
72 class SystemUIImpl : public SystemUI { 82 class SystemUIImpl : public SystemUI, public WindowManagerObserver {
73 public: 83 public:
74 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner) 84 SystemUIImpl(scoped_refptr<base::TaskRunner> blocking_task_runner)
75 : orientation_controller_(new OrientationController()), 85 : orientation_controller_(new OrientationController()),
76 background_container_(nullptr) { 86 background_container_(nullptr),
87 system_info_widget_(nullptr) {
77 orientation_controller_->InitWith(blocking_task_runner); 88 orientation_controller_->InitWith(blocking_task_runner);
89 WindowManager::Get()->AddObserver(this);
78 } 90 }
79 91
80 ~SystemUIImpl() override { 92 ~SystemUIImpl() override {
93 WindowManager::Get()->RemoveObserver(this);
94
81 // Stops file watching now if exists. Waiting until message loop shutdon 95 // Stops file watching now if exists. Waiting until message loop shutdon
82 // leads to FilePathWatcher crash. 96 // leads to FilePathWatcher crash.
83 orientation_controller_->Shutdown(); 97 orientation_controller_->Shutdown();
84 } 98 }
85 99
86 void Init() { 100 void Init() {
87 ScreenManager* screen_manager = ScreenManager::Get(); 101 ScreenManager* screen_manager = ScreenManager::Get();
88 background_container_ = screen_manager->CreateContainer( 102 background_container_ = screen_manager->CreateContainer(
89 ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND)); 103 ScreenManager::ContainerParams("AthenaBackground", CP_BACKGROUND));
90 background_container_->SetLayoutManager( 104 background_container_->SetLayoutManager(
91 new FillLayoutManager(background_container_)); 105 new FillLayoutManager(background_container_));
92 106
93 shutdown_dialog_.reset(new ShutdownDialog()); 107 shutdown_dialog_.reset(new ShutdownDialog());
94 background_controller_.reset( 108 background_controller_.reset(
95 new BackgroundController(background_container_)); 109 new BackgroundController(background_container_));
96 } 110 }
97 111
98 private: 112 private:
99 // SystemUI: 113 // SystemUI:
100 virtual void SetBackgroundImage(const gfx::ImageSkia& image) override { 114 void SetBackgroundImage(const gfx::ImageSkia& image) override {
101 background_controller_->SetImage(image); 115 background_controller_->SetImage(image);
102 } 116 }
103 117
104 virtual views::View* CreateSystemInfoView(ColorScheme color_scheme) override { 118 // WindowManagerObserver:
105 return new SystemInfoView(color_scheme); 119 void OnOverviewModeEnter() override {
120 DCHECK(!system_info_widget_);
121
122 ScreenManager* screen_manager = ScreenManager::Get();
123 aura::Window* container = screen_manager->CreateContainer(
124 ScreenManager::ContainerParams("SystemInfo", CP_SYSTEM_INFO));
125 wm::SetChildWindowVisibilityChangesAnimated(container);
126
127 system_info_widget_ = new views::Widget();
128 views::Widget::InitParams widget_params(
129 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
130 widget_params.parent = container;
131 widget_params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
132 widget_params.bounds =
133 gfx::Rect(0, 0, container->bounds().width(), kSystemUIHeight);
134 system_info_widget_->Init(widget_params);
135 system_info_widget_->SetContentsView(
136 new SystemInfoView(SystemUI::COLOR_SCHEME_LIGHT));
137
138 wm::SetWindowVisibilityAnimationType(
139 system_info_widget_->GetNativeWindow(),
140 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
141 wm::SetWindowVisibilityAnimationVerticalPosition(
142 system_info_widget_->GetNativeWindow(), -kSystemUIHeight);
143
144 system_info_widget_->Show();
106 } 145 }
107 146
147 void OnOverviewModeExit() override {
148 // Deleting the container deletes its child windows which deletes
149 // |system_info_widget_|.
150 delete system_info_widget_->GetNativeWindow()->parent();
151 system_info_widget_ = nullptr;
152 }
153
154 void OnSplitViewModeEnter() override {}
155
156 void OnSplitViewModeExit() override {}
157
108 scoped_ptr<OrientationController> orientation_controller_; 158 scoped_ptr<OrientationController> orientation_controller_;
109 scoped_ptr<ShutdownDialog> shutdown_dialog_; 159 scoped_ptr<ShutdownDialog> shutdown_dialog_;
110 scoped_ptr<BackgroundController> background_controller_; 160 scoped_ptr<BackgroundController> background_controller_;
111 161
112 // The parent container for the background. 162 // The parent container for the background.
113 aura::Window* background_container_; 163 aura::Window* background_container_;
114 164
115 // The parent container used by system modal dialogs. 165 views::Widget* system_info_widget_;
116 aura::Window* system_modal_container_;
117
118 // The parent container used by system modal dialogs when the login screen is
119 // visible.
120 aura::Window* login_screen_system_modal_container_;
121 166
122 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl); 167 DISALLOW_COPY_AND_ASSIGN(SystemUIImpl);
123 }; 168 };
124 169
125 } // namespace 170 } // namespace
126 171
127 // static 172 // static
128 SystemUI* SystemUI::Create( 173 SystemUI* SystemUI::Create(
129 scoped_refptr<base::TaskRunner> blocking_task_runner) { 174 scoped_refptr<base::TaskRunner> blocking_task_runner) {
130 SystemUIImpl* system_ui = new SystemUIImpl(blocking_task_runner); 175 SystemUIImpl* system_ui = new SystemUIImpl(blocking_task_runner);
131 instance = system_ui; 176 instance = system_ui;
132 system_ui->Init(); 177 system_ui->Init();
133 return instance; 178 return instance;
134 } 179 }
135 180
136 // static 181 // static
137 SystemUI* SystemUI::Get() { 182 SystemUI* SystemUI::Get() {
138 DCHECK(instance); 183 DCHECK(instance);
139 return instance; 184 return instance;
140 } 185 }
141 186
142 // static 187 // static
143 void SystemUI::Shutdown() { 188 void SystemUI::Shutdown() {
144 CHECK(instance); 189 CHECK(instance);
145 delete instance; 190 delete instance;
146 instance = nullptr; 191 instance = nullptr;
147 } 192 }
148 193
149 } // namespace athena 194 } // namespace athena
OLDNEW
« no previous file with comments | « athena/system/public/system_ui.h ('k') | athena/util/athena_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698