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

Side by Side Diff: ash/system/tray/system_tray.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/tray/system_tray.h ('k') | ash/system/tray/system_tray_item.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/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "ash/system/screen_security/screen_capture_tray_item.h" 33 #include "ash/system/screen_security/screen_capture_tray_item.h"
34 #include "ash/system/screen_security/screen_share_tray_item.h" 34 #include "ash/system/screen_security/screen_share_tray_item.h"
35 #include "ash/system/session/tray_session_length_limit.h" 35 #include "ash/system/session/tray_session_length_limit.h"
36 #include "ash/system/supervised/tray_supervised_user.h" 36 #include "ash/system/supervised/tray_supervised_user.h"
37 #include "ash/system/tiles/tray_tiles.h" 37 #include "ash/system/tiles/tray_tiles.h"
38 #include "ash/system/tray/system_tray_controller.h" 38 #include "ash/system/tray/system_tray_controller.h"
39 #include "ash/system/tray/system_tray_delegate.h" 39 #include "ash/system/tray/system_tray_delegate.h"
40 #include "ash/system/tray/system_tray_item.h" 40 #include "ash/system/tray/system_tray_item.h"
41 #include "ash/system/tray/tray_bubble_wrapper.h" 41 #include "ash/system/tray/tray_bubble_wrapper.h"
42 #include "ash/system/tray/tray_constants.h" 42 #include "ash/system/tray/tray_constants.h"
43 #include "ash/system/tray/tray_container.h"
43 #include "ash/system/tray_accessibility.h" 44 #include "ash/system/tray_accessibility.h"
44 #include "ash/system/tray_caps_lock.h" 45 #include "ash/system/tray_caps_lock.h"
45 #include "ash/system/tray_tracing.h" 46 #include "ash/system/tray_tracing.h"
46 #include "ash/system/update/tray_update.h" 47 #include "ash/system/update/tray_update.h"
47 #include "ash/system/user/tray_user.h" 48 #include "ash/system/user/tray_user.h"
48 #include "ash/system/web_notification/web_notification_tray.h" 49 #include "ash/system/web_notification/web_notification_tray.h"
49 #include "ash/wm/container_finder.h" 50 #include "ash/wm/container_finder.h"
50 #include "ash/wm/widget_finder.h" 51 #include "ash/wm/widget_finder.h"
51 #include "ash/wm_window.h" 52 #include "ash/wm_window.h"
52 #include "base/logging.h" 53 #include "base/logging.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 201 }
201 202
202 private: 203 private:
203 SystemTray* tray_; 204 SystemTray* tray_;
204 205
205 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); 206 DISALLOW_COPY_AND_ASSIGN(ActivationObserver);
206 }; 207 };
207 208
208 // SystemTray 209 // SystemTray
209 210
210 SystemTray::SystemTray(WmShelf* wm_shelf) : TrayBackgroundView(wm_shelf, true) { 211 SystemTray::SystemTray(WmShelf* wm_shelf) : TrayBackgroundView(wm_shelf) {
211 SetInkDropMode(InkDropMode::ON); 212 SetInkDropMode(InkDropMode::ON);
212 213
213 // Since user avatar is on the right hand side of System tray of a 214 // Since user avatar is on the right hand side of System tray of a
214 // horizontal shelf and that is sufficient to indicate separation, no 215 // horizontal shelf and that is sufficient to indicate separation, no
215 // separator is required. 216 // separator is required.
216 set_separator_visibility(false); 217 set_separator_visibility(false);
217 } 218 }
218 219
219 SystemTray::~SystemTray() { 220 SystemTray::~SystemTray() {
220 // Destroy any child views that might have back pointers before ~View(). 221 // Destroy any child views that might have back pointers before ~View().
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); 292 AddTrayItem(base::MakeUnique<PaddingTrayItem>());
292 } 293 }
293 294
294 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { 295 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) {
295 SystemTrayItem* item_ptr = item.get(); 296 SystemTrayItem* item_ptr = item.get();
296 items_.push_back(std::move(item)); 297 items_.push_back(std::move(item));
297 298
298 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 299 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
299 views::View* tray_item = 300 views::View* tray_item =
300 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); 301 item_ptr->CreateTrayView(delegate->GetUserLoginStatus());
301 item_ptr->UpdateAfterShelfAlignmentChange(shelf_alignment()); 302 item_ptr->UpdateAfterShelfAlignmentChange();
302 303
303 if (tray_item) { 304 if (tray_item) {
304 tray_container()->AddChildViewAt(tray_item, 0); 305 tray_container()->AddChildViewAt(tray_item, 0);
305 PreferredSizeChanged(); 306 PreferredSizeChanged();
306 tray_item_map_[item_ptr] = tray_item; 307 tray_item_map_[item_ptr] = tray_item;
307 } 308 }
308 } 309 }
309 310
310 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const { 311 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const {
311 std::vector<SystemTrayItem*> result; 312 std::vector<SystemTrayItem*> result;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 363
363 DestroySystemBubble(); 364 DestroySystemBubble();
364 } 365 }
365 366
366 void SystemTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { 367 void SystemTray::UpdateAfterLoginStatusChange(LoginStatus login_status) {
367 DestroySystemBubble(); 368 DestroySystemBubble();
368 369
369 for (const auto& item : items_) 370 for (const auto& item : items_)
370 item->UpdateAfterLoginStatusChange(login_status); 371 item->UpdateAfterLoginStatusChange(login_status);
371 372
372 // Items default to SHELF_ALIGNMENT_BOTTOM. Update them if the initial
373 // position of the shelf differs.
374 if (!IsHorizontalAlignment(shelf_alignment()))
375 UpdateAfterShelfAlignmentChange(shelf_alignment());
376
377 SetVisible(true); 373 SetVisible(true);
378 PreferredSizeChanged(); 374 PreferredSizeChanged();
379 } 375 }
380 376
381 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 377 void SystemTray::UpdateItemsAfterShelfAlignmentChange() {
382 for (const auto& item : items_) 378 for (const auto& item : items_)
383 item->UpdateAfterShelfAlignmentChange(alignment); 379 item->UpdateAfterShelfAlignmentChange();
384 } 380 }
385 381
386 bool SystemTray::ShouldShowShelf() const { 382 bool SystemTray::ShouldShowShelf() const {
387 return system_bubble_.get() && system_bubble_->bubble()->ShouldShowShelf(); 383 return system_bubble_.get() && system_bubble_->bubble()->ShouldShowShelf();
388 } 384 }
389 385
390 bool SystemTray::HasSystemBubble() const { 386 bool SystemTray::HasSystemBubble() const {
391 return system_bubble_.get() != NULL; 387 return system_bubble_.get() != NULL;
392 } 388 }
393 389
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 536 }
541 537
542 base::string16 SystemTray::GetAccessibleTimeString( 538 base::string16 SystemTray::GetAccessibleTimeString(
543 const base::Time& now) const { 539 const base::Time& now) const {
544 base::HourClockType hour_type = 540 base::HourClockType hour_type =
545 Shell::Get()->system_tray_controller()->hour_clock_type(); 541 Shell::Get()->system_tray_controller()->hour_clock_type();
546 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 542 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
547 base::kKeepAmPm); 543 base::kKeepAmPm);
548 } 544 }
549 545
550 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 546 void SystemTray::UpdateAfterShelfAlignmentChange() {
551 if (alignment == shelf_alignment()) 547 TrayBackgroundView::UpdateAfterShelfAlignmentChange();
552 return; 548 UpdateItemsAfterShelfAlignmentChange();
553 TrayBackgroundView::SetShelfAlignment(alignment);
554 UpdateAfterShelfAlignmentChange(alignment);
555 // Destroy any existing bubble so that it is rebuilt correctly. 549 // Destroy any existing bubble so that it is rebuilt correctly.
556 CloseSystemBubbleAndDeactivateSystemTray(); 550 CloseSystemBubbleAndDeactivateSystemTray();
557 // Rebuild any notification bubble. 551 // Rebuild any notification bubble.
558 UpdateWebNotifications(); 552 UpdateWebNotifications();
559 } 553 }
560 554
561 void SystemTray::AnchorUpdated() { 555 void SystemTray::AnchorUpdated() {
562 if (system_bubble_) { 556 if (system_bubble_) {
563 system_bubble_->bubble_view()->UpdateBubble(); 557 system_bubble_->bubble_view()->UpdateBubble();
564 UpdateBubbleViewArrow(system_bubble_->bubble_view()); 558 UpdateBubbleViewArrow(system_bubble_->bubble_view());
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 .work_area() 723 .work_area()
730 .height(); 724 .height();
731 if (work_area_height > 0) { 725 if (work_area_height > 0) {
732 UMA_HISTOGRAM_CUSTOM_COUNTS( 726 UMA_HISTOGRAM_CUSTOM_COUNTS(
733 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 727 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
734 100 * bubble_view->height() / work_area_height, 1, 300, 100); 728 100 * bubble_view->height() / work_area_height, 1, 300, 100);
735 } 729 }
736 } 730 }
737 731
738 } // namespace ash 732 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698