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

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
« no previous file with comments | « ash/system/status_area_widget.h ('k') | ash/system/status_area_widget_delegate.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 (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/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/wm_shelf.h" 9 #include "ash/shelf/wm_shelf.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/ime_menu/ime_menu_tray.h" 11 #include "ash/system/ime_menu/ime_menu_tray.h"
12 #include "ash/system/overview/overview_button_tray.h" 12 #include "ash/system/overview/overview_button_tray.h"
13 #include "ash/system/palette/palette_tray.h" 13 #include "ash/system/palette/palette_tray.h"
14 #include "ash/system/palette/palette_utils.h" 14 #include "ash/system/palette/palette_utils.h"
15 #include "ash/system/session/logout_button_tray.h" 15 #include "ash/system/session/logout_button_tray.h"
16 #include "ash/system/status_area_widget_delegate.h" 16 #include "ash/system/status_area_widget_delegate.h"
17 #include "ash/system/tray/system_tray.h" 17 #include "ash/system/tray/system_tray.h"
18 #include "ash/system/tray/system_tray_delegate.h" 18 #include "ash/system/tray/system_tray_delegate.h"
19 #include "ash/system/virtual_keyboard/virtual_keyboard_tray.h" 19 #include "ash/system/virtual_keyboard/virtual_keyboard_tray.h"
20 #include "ash/system/web_notification/web_notification_tray.h" 20 #include "ash/system/web_notification/web_notification_tray.h"
21 #include "ash/wm_window.h" 21 #include "ash/wm_window.h"
22 #include "base/i18n/time_formatting.h" 22 #include "base/i18n/time_formatting.h"
23 #include "ui/display/display.h" 23 #include "ui/display/display.h"
24 #include "ui/native_theme/native_theme_dark_aura.h" 24 #include "ui/native_theme/native_theme_dark_aura.h"
25 25
26 namespace ash { 26 namespace ash {
27 27
28 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container, 28 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container,
29 WmShelf* wm_shelf) 29 WmShelf* wm_shelf)
30 : status_area_widget_delegate_(new StatusAreaWidgetDelegate), 30 : status_area_widget_delegate_(new StatusAreaWidgetDelegate(wm_shelf)),
31 overview_button_tray_(nullptr), 31 overview_button_tray_(nullptr),
32 system_tray_(nullptr), 32 system_tray_(nullptr),
33 web_notification_tray_(nullptr), 33 web_notification_tray_(nullptr),
34 logout_button_tray_(nullptr), 34 logout_button_tray_(nullptr),
35 palette_tray_(nullptr), 35 palette_tray_(nullptr),
36 virtual_keyboard_tray_(nullptr), 36 virtual_keyboard_tray_(nullptr),
37 ime_menu_tray_(nullptr), 37 ime_menu_tray_(nullptr),
38 login_status_(LoginStatus::NOT_LOGGED_IN), 38 login_status_(LoginStatus::NOT_LOGGED_IN),
39 wm_shelf_(wm_shelf) { 39 wm_shelf_(wm_shelf) {
40 views::Widget::InitParams params( 40 views::Widget::InitParams params(
(...skipping 18 matching lines...) Expand all
59 AddPaletteTray(); 59 AddPaletteTray();
60 AddVirtualKeyboardTray(); 60 AddVirtualKeyboardTray();
61 AddImeMenuTray(); 61 AddImeMenuTray();
62 AddLogoutButtonTray(); 62 AddLogoutButtonTray();
63 63
64 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 64 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
65 DCHECK(delegate); 65 DCHECK(delegate);
66 // Initialize after all trays have been created. 66 // Initialize after all trays have been created.
67 system_tray_->InitializeTrayItems(delegate, web_notification_tray_); 67 system_tray_->InitializeTrayItems(delegate, web_notification_tray_);
68 web_notification_tray_->Initialize(); 68 web_notification_tray_->Initialize();
69 logout_button_tray_->Initialize();
70 if (palette_tray_) 69 if (palette_tray_)
71 palette_tray_->Initialize(); 70 palette_tray_->Initialize();
72 virtual_keyboard_tray_->Initialize(); 71 virtual_keyboard_tray_->Initialize();
73 ime_menu_tray_->Initialize(); 72 ime_menu_tray_->Initialize();
74 overview_button_tray_->Initialize(); 73 overview_button_tray_->Initialize();
75 SetShelfAlignment(system_tray_->shelf_alignment()); 74 UpdateAfterShelfAlignmentChange();
76 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); 75 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus());
77 } 76 }
78 77
79 void StatusAreaWidget::Shutdown() { 78 void StatusAreaWidget::Shutdown() {
80 system_tray_->Shutdown(); 79 system_tray_->Shutdown();
81 // Destroy the trays early, causing them to be removed from the view 80 // Destroy the trays early, causing them to be removed from the view
82 // hierarchy. Do not used scoped pointers since we don't want to destroy them 81 // hierarchy. Do not used scoped pointers since we don't want to destroy them
83 // in the destructor if Shutdown() is not called (e.g. in tests). 82 // in the destructor if Shutdown() is not called (e.g. in tests).
84 // Failure to remove the tray views causes layout crashes during shutdown, 83 // Failure to remove the tray views causes layout crashes during shutdown,
85 // for example http://crbug.com/700122. 84 // for example http://crbug.com/700122.
(...skipping 11 matching lines...) Expand all
97 delete palette_tray_; 96 delete palette_tray_;
98 palette_tray_ = nullptr; 97 palette_tray_ = nullptr;
99 delete logout_button_tray_; 98 delete logout_button_tray_;
100 logout_button_tray_ = nullptr; 99 logout_button_tray_ = nullptr;
101 delete overview_button_tray_; 100 delete overview_button_tray_;
102 overview_button_tray_ = nullptr; 101 overview_button_tray_ = nullptr;
103 // All child tray views have been removed. 102 // All child tray views have been removed.
104 DCHECK_EQ(0, GetContentsView()->child_count()); 103 DCHECK_EQ(0, GetContentsView()->child_count());
105 } 104 }
106 105
107 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 106 void StatusAreaWidget::UpdateAfterShelfAlignmentChange() {
108 status_area_widget_delegate_->set_alignment(alignment);
109 if (system_tray_) 107 if (system_tray_)
110 system_tray_->SetShelfAlignment(alignment); 108 system_tray_->UpdateAfterShelfAlignmentChange();
111 if (web_notification_tray_) 109 if (web_notification_tray_)
112 web_notification_tray_->SetShelfAlignment(alignment); 110 web_notification_tray_->UpdateAfterShelfAlignmentChange();
113 if (logout_button_tray_) 111 if (logout_button_tray_)
114 logout_button_tray_->SetShelfAlignment(alignment); 112 logout_button_tray_->UpdateAfterShelfAlignmentChange();
115 if (virtual_keyboard_tray_) 113 if (virtual_keyboard_tray_)
116 virtual_keyboard_tray_->SetShelfAlignment(alignment); 114 virtual_keyboard_tray_->UpdateAfterShelfAlignmentChange();
117 if (ime_menu_tray_) 115 if (ime_menu_tray_)
118 ime_menu_tray_->SetShelfAlignment(alignment); 116 ime_menu_tray_->UpdateAfterShelfAlignmentChange();
119 if (palette_tray_) 117 if (palette_tray_)
120 palette_tray_->SetShelfAlignment(alignment); 118 palette_tray_->UpdateAfterShelfAlignmentChange();
121 if (overview_button_tray_) 119 if (overview_button_tray_)
122 overview_button_tray_->SetShelfAlignment(alignment); 120 overview_button_tray_->UpdateAfterShelfAlignmentChange();
123 status_area_widget_delegate_->UpdateLayout(); 121 status_area_widget_delegate_->UpdateLayout();
124 } 122 }
125 123
126 void StatusAreaWidget::UpdateAfterLoginStatusChange(LoginStatus login_status) { 124 void StatusAreaWidget::UpdateAfterLoginStatusChange(LoginStatus login_status) {
127 if (login_status_ == login_status) 125 if (login_status_ == login_status)
128 return; 126 return;
129 login_status_ = login_status; 127 login_status_ = login_status;
130 if (system_tray_) 128 if (system_tray_)
131 system_tray_->UpdateAfterLoginStatusChange(login_status); 129 system_tray_->UpdateAfterLoginStatusChange(login_status);
132 if (web_notification_tray_) 130 if (web_notification_tray_)
133 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 131 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
134 if (logout_button_tray_) 132 if (logout_button_tray_)
135 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); 133 logout_button_tray_->UpdateAfterLoginStatusChange();
136 if (overview_button_tray_) 134 if (overview_button_tray_)
137 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); 135 overview_button_tray_->UpdateAfterLoginStatusChange(login_status);
138 } 136 }
139 137
140 bool StatusAreaWidget::ShouldShowShelf() const { 138 bool StatusAreaWidget::ShouldShowShelf() const {
141 if ((system_tray_ && system_tray_->ShouldShowShelf()) || 139 if ((system_tray_ && system_tray_->ShouldShowShelf()) ||
142 (web_notification_tray_ && 140 (web_notification_tray_ &&
143 web_notification_tray_->ShouldBlockShelfAutoHide())) 141 web_notification_tray_->ShouldBlockShelfAutoHide()))
144 return true; 142 return true;
145 143
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { 175 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
178 Widget::OnNativeWidgetActivationChanged(active); 176 Widget::OnNativeWidgetActivationChanged(active);
179 if (active) 177 if (active)
180 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); 178 status_area_widget_delegate_->SetPaneFocusAndFocusDefault();
181 } 179 }
182 180
183 void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) { 181 void StatusAreaWidget::UpdateShelfItemBackground(SkColor color) {
184 web_notification_tray_->UpdateShelfItemBackground(color); 182 web_notification_tray_->UpdateShelfItemBackground(color);
185 system_tray_->UpdateShelfItemBackground(color); 183 system_tray_->UpdateShelfItemBackground(color);
186 virtual_keyboard_tray_->UpdateShelfItemBackground(color); 184 virtual_keyboard_tray_->UpdateShelfItemBackground(color);
187 logout_button_tray_->UpdateShelfItemBackground(color);
188 ime_menu_tray_->UpdateShelfItemBackground(color); 185 ime_menu_tray_->UpdateShelfItemBackground(color);
189 if (palette_tray_) 186 if (palette_tray_)
190 palette_tray_->UpdateShelfItemBackground(color); 187 palette_tray_->UpdateShelfItemBackground(color);
191 overview_button_tray_->UpdateShelfItemBackground(color); 188 overview_button_tray_->UpdateShelfItemBackground(color);
192 } 189 }
193 190
194 void StatusAreaWidget::AddSystemTray() { 191 void StatusAreaWidget::AddSystemTray() {
195 system_tray_ = new SystemTray(wm_shelf_); 192 system_tray_ = new SystemTray(wm_shelf_);
196 status_area_widget_delegate_->AddTray(system_tray_); 193 status_area_widget_delegate_->AddTray(system_tray_);
197 } 194 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ime_menu_tray_ = new ImeMenuTray(wm_shelf_); 227 ime_menu_tray_ = new ImeMenuTray(wm_shelf_);
231 status_area_widget_delegate_->AddTray(ime_menu_tray_); 228 status_area_widget_delegate_->AddTray(ime_menu_tray_);
232 } 229 }
233 230
234 void StatusAreaWidget::AddOverviewButtonTray() { 231 void StatusAreaWidget::AddOverviewButtonTray() {
235 overview_button_tray_ = new OverviewButtonTray(wm_shelf_); 232 overview_button_tray_ = new OverviewButtonTray(wm_shelf_);
236 status_area_widget_delegate_->AddTray(overview_button_tray_); 233 status_area_widget_delegate_->AddTray(overview_button_tray_);
237 } 234 }
238 235
239 } // namespace ash 236 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget.h ('k') | ash/system/status_area_widget_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698