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

Side by Side Diff: ash/system/status_area_widget.cc

Issue 2807693002: Make LogoutButtonTray a regular View (Closed)
Patch Set: Rebased Created 3 years, 8 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/system/status_area_widget.h" 5 #include "ash/system/status_area_widget.h"
6 6
7 #include "ash/material_design/material_design_controller.h" 7 #include "ash/material_design/material_design_controller.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/wm_shelf.h" 10 #include "ash/shelf/wm_shelf.h"
(...skipping 10 matching lines...) Expand all
21 #include "ash/system/web_notification/web_notification_tray.h" 21 #include "ash/system/web_notification/web_notification_tray.h"
22 #include "ash/wm_window.h" 22 #include "ash/wm_window.h"
23 #include "base/i18n/time_formatting.h" 23 #include "base/i18n/time_formatting.h"
24 #include "ui/display/display.h" 24 #include "ui/display/display.h"
25 #include "ui/native_theme/native_theme_dark_aura.h" 25 #include "ui/native_theme/native_theme_dark_aura.h"
26 26
27 namespace ash { 27 namespace ash {
28 28
29 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container, 29 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container,
30 WmShelf* wm_shelf) 30 WmShelf* wm_shelf)
31 : status_area_widget_delegate_(new StatusAreaWidgetDelegate), 31 : status_area_widget_delegate_(new StatusAreaWidgetDelegate(wm_shelf)),
32 overview_button_tray_(nullptr), 32 overview_button_tray_(nullptr),
33 system_tray_(nullptr), 33 system_tray_(nullptr),
34 web_notification_tray_(nullptr), 34 web_notification_tray_(nullptr),
35 logout_button_tray_(nullptr), 35 logout_button_tray_(nullptr),
36 palette_tray_(nullptr), 36 palette_tray_(nullptr),
37 virtual_keyboard_tray_(nullptr), 37 virtual_keyboard_tray_(nullptr),
38 ime_menu_tray_(nullptr), 38 ime_menu_tray_(nullptr),
39 login_status_(LoginStatus::NOT_LOGGED_IN), 39 login_status_(LoginStatus::NOT_LOGGED_IN),
40 wm_shelf_(wm_shelf) { 40 wm_shelf_(wm_shelf) {
41 views::Widget::InitParams params( 41 views::Widget::InitParams params(
(...skipping 18 matching lines...) Expand all
60 AddPaletteTray(); 60 AddPaletteTray();
61 AddVirtualKeyboardTray(); 61 AddVirtualKeyboardTray();
62 AddImeMenuTray(); 62 AddImeMenuTray();
63 AddLogoutButtonTray(); 63 AddLogoutButtonTray();
64 64
65 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 65 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
66 DCHECK(delegate); 66 DCHECK(delegate);
67 // Initialize after all trays have been created. 67 // Initialize after all trays have been created.
68 system_tray_->InitializeTrayItems(delegate, web_notification_tray_); 68 system_tray_->InitializeTrayItems(delegate, web_notification_tray_);
69 web_notification_tray_->Initialize(); 69 web_notification_tray_->Initialize();
70 logout_button_tray_->Initialize();
71 if (palette_tray_) 70 if (palette_tray_)
72 palette_tray_->Initialize(); 71 palette_tray_->Initialize();
73 virtual_keyboard_tray_->Initialize(); 72 virtual_keyboard_tray_->Initialize();
74 ime_menu_tray_->Initialize(); 73 ime_menu_tray_->Initialize();
75 overview_button_tray_->Initialize(); 74 overview_button_tray_->Initialize();
76 SetShelfAlignment(system_tray_->shelf_alignment()); 75 UpdateAfterShelfAlignmentChange();
77 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); 76 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus());
78 } 77 }
79 78
80 void StatusAreaWidget::Shutdown() { 79 void StatusAreaWidget::Shutdown() {
81 system_tray_->Shutdown(); 80 system_tray_->Shutdown();
82 // Destroy the trays early, causing them to be removed from the view 81 // Destroy the trays early, causing them to be removed from the view
83 // hierarchy. Do not used scoped pointers since we don't want to destroy them 82 // hierarchy. Do not used scoped pointers since we don't want to destroy them
84 // in the destructor if Shutdown() is not called (e.g. in tests). 83 // in the destructor if Shutdown() is not called (e.g. in tests).
85 // Failure to remove the tray views causes layout crashes during shutdown, 84 // Failure to remove the tray views causes layout crashes during shutdown,
86 // for example http://crbug.com/700122. 85 // for example http://crbug.com/700122.
(...skipping 11 matching lines...) Expand all
98 delete palette_tray_; 97 delete palette_tray_;
99 palette_tray_ = nullptr; 98 palette_tray_ = nullptr;
100 delete logout_button_tray_; 99 delete logout_button_tray_;
101 logout_button_tray_ = nullptr; 100 logout_button_tray_ = nullptr;
102 delete overview_button_tray_; 101 delete overview_button_tray_;
103 overview_button_tray_ = nullptr; 102 overview_button_tray_ = nullptr;
104 // All child tray views have been removed. 103 // All child tray views have been removed.
105 DCHECK_EQ(0, GetContentsView()->child_count()); 104 DCHECK_EQ(0, GetContentsView()->child_count());
106 } 105 }
107 106
108 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 107 void StatusAreaWidget::UpdateAfterShelfAlignmentChange() {
109 status_area_widget_delegate_->set_alignment(alignment);
110 if (system_tray_) 108 if (system_tray_)
111 system_tray_->SetShelfAlignment(alignment); 109 system_tray_->UpdateAfterShelfAlignmentChange();
112 if (web_notification_tray_) 110 if (web_notification_tray_)
113 web_notification_tray_->SetShelfAlignment(alignment); 111 web_notification_tray_->UpdateAfterShelfAlignmentChange();
114 if (logout_button_tray_) 112 if (logout_button_tray_)
115 logout_button_tray_->SetShelfAlignment(alignment); 113 logout_button_tray_->UpdateAfterShelfAlignmentChange();
116 if (virtual_keyboard_tray_) 114 if (virtual_keyboard_tray_)
117 virtual_keyboard_tray_->SetShelfAlignment(alignment); 115 virtual_keyboard_tray_->UpdateAfterShelfAlignmentChange();
118 if (ime_menu_tray_) 116 if (ime_menu_tray_)
119 ime_menu_tray_->SetShelfAlignment(alignment); 117 ime_menu_tray_->UpdateAfterShelfAlignmentChange();
120 if (palette_tray_) 118 if (palette_tray_)
121 palette_tray_->SetShelfAlignment(alignment); 119 palette_tray_->UpdateAfterShelfAlignmentChange();
122 if (overview_button_tray_) 120 if (overview_button_tray_)
123 overview_button_tray_->SetShelfAlignment(alignment); 121 overview_button_tray_->UpdateAfterShelfAlignmentChange();
124 status_area_widget_delegate_->UpdateLayout(); 122 status_area_widget_delegate_->UpdateLayout();
125 } 123 }
126 124
127 void StatusAreaWidget::UpdateAfterLoginStatusChange(LoginStatus login_status) { 125 void StatusAreaWidget::UpdateAfterLoginStatusChange(LoginStatus login_status) {
128 if (login_status_ == login_status) 126 if (login_status_ == login_status)
129 return; 127 return;
130 login_status_ = login_status; 128 login_status_ = login_status;
131 if (system_tray_) 129 if (system_tray_)
132 system_tray_->UpdateAfterLoginStatusChange(login_status); 130 system_tray_->UpdateAfterLoginStatusChange(login_status);
133 if (web_notification_tray_) 131 if (web_notification_tray_)
134 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 132 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
135 if (logout_button_tray_) 133 if (logout_button_tray_)
136 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); 134 logout_button_tray_->UpdateAfterLoginStatusChange();
137 if (overview_button_tray_) 135 if (overview_button_tray_)
138 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); 136 overview_button_tray_->UpdateAfterLoginStatusChange(login_status);
139 } 137 }
140 138
141 bool StatusAreaWidget::ShouldShowShelf() const { 139 bool StatusAreaWidget::ShouldShowShelf() const {
142 if ((system_tray_ && system_tray_->ShouldShowShelf()) || 140 if ((system_tray_ && system_tray_->ShouldShowShelf()) ||
143 (web_notification_tray_ && 141 (web_notification_tray_ &&
144 web_notification_tray_->ShouldBlockShelfAutoHide())) 142 web_notification_tray_->ShouldBlockShelfAutoHide()))
145 return true; 143 return true;
146 144
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { 178 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
181 Widget::OnNativeWidgetActivationChanged(active); 179 Widget::OnNativeWidgetActivationChanged(active);
182 if (active) 180 if (active)
183 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); 181 status_area_widget_delegate_->SetPaneFocusAndFocusDefault();
184 } 182 }
185 183
186 void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) { 184 void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) {
187 web_notification_tray_->UpdateShelfItemBackground(color); 185 web_notification_tray_->UpdateShelfItemBackground(color);
188 system_tray_->UpdateShelfItemBackground(color); 186 system_tray_->UpdateShelfItemBackground(color);
189 virtual_keyboard_tray_->UpdateShelfItemBackground(color); 187 virtual_keyboard_tray_->UpdateShelfItemBackground(color);
190 logout_button_tray_->UpdateShelfItemBackground(color);
191 ime_menu_tray_->UpdateShelfItemBackground(color); 188 ime_menu_tray_->UpdateShelfItemBackground(color);
192 if (palette_tray_) 189 if (palette_tray_)
193 palette_tray_->UpdateShelfItemBackground(color); 190 palette_tray_->UpdateShelfItemBackground(color);
194 overview_button_tray_->UpdateShelfItemBackground(color); 191 overview_button_tray_->UpdateShelfItemBackground(color);
195 } 192 }
196 193
197 void StatusAreaWidget::AddSystemTray() { 194 void StatusAreaWidget::AddSystemTray() {
198 system_tray_ = new SystemTray(wm_shelf_); 195 system_tray_ = new SystemTray(wm_shelf_);
199 status_area_widget_delegate_->AddTray(system_tray_); 196 status_area_widget_delegate_->AddTray(system_tray_);
200 } 197 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); 230 ime_menu_tray_ = new ImeMenuTray(wm_shelf_);
234 status_area_widget_delegate_->AddTray(ime_menu_tray_); 231 status_area_widget_delegate_->AddTray(ime_menu_tray_);
235 } 232 }
236 233
237 void StatusAreaWidget::AddOverviewButtonTray() { 234 void StatusAreaWidget::AddOverviewButtonTray() {
238 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); 235 overview_button_tray_ = new OverviewButtonTray(wm_shelf_);
239 status_area_widget_delegate_->AddTray(overview_button_tray_); 236 status_area_widget_delegate_->AddTray(overview_button_tray_);
240 } 237 }
241 238
242 } // namespace ash 239 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698