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

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
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 21 matching lines...) Expand all
32 #include "ash/system/screen_security/screen_capture_tray_item.h" 32 #include "ash/system/screen_security/screen_capture_tray_item.h"
33 #include "ash/system/screen_security/screen_share_tray_item.h" 33 #include "ash/system/screen_security/screen_share_tray_item.h"
34 #include "ash/system/session/tray_session_length_limit.h" 34 #include "ash/system/session/tray_session_length_limit.h"
35 #include "ash/system/supervised/tray_supervised_user.h" 35 #include "ash/system/supervised/tray_supervised_user.h"
36 #include "ash/system/tiles/tray_tiles.h" 36 #include "ash/system/tiles/tray_tiles.h"
37 #include "ash/system/tray/system_tray_controller.h" 37 #include "ash/system/tray/system_tray_controller.h"
38 #include "ash/system/tray/system_tray_delegate.h" 38 #include "ash/system/tray/system_tray_delegate.h"
39 #include "ash/system/tray/system_tray_item.h" 39 #include "ash/system/tray/system_tray_item.h"
40 #include "ash/system/tray/tray_bubble_wrapper.h" 40 #include "ash/system/tray/tray_bubble_wrapper.h"
41 #include "ash/system/tray/tray_constants.h" 41 #include "ash/system/tray/tray_constants.h"
42 #include "ash/system/tray/tray_container.h"
42 #include "ash/system/tray_accessibility.h" 43 #include "ash/system/tray_accessibility.h"
43 #include "ash/system/tray_caps_lock.h" 44 #include "ash/system/tray_caps_lock.h"
44 #include "ash/system/tray_tracing.h" 45 #include "ash/system/tray_tracing.h"
45 #include "ash/system/update/tray_update.h" 46 #include "ash/system/update/tray_update.h"
46 #include "ash/system/user/tray_user.h" 47 #include "ash/system/user/tray_user.h"
47 #include "ash/system/web_notification/web_notification_tray.h" 48 #include "ash/system/web_notification/web_notification_tray.h"
48 #include "ash/wm/container_finder.h" 49 #include "ash/wm/container_finder.h"
49 #include "ash/wm/widget_finder.h" 50 #include "ash/wm/widget_finder.h"
50 #include "ash/wm_shell.h" 51 #include "ash/wm_shell.h"
51 #include "ash/wm_window.h" 52 #include "ash/wm_window.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 private: 205 private:
205 SystemTray* tray_; 206 SystemTray* tray_;
206 207
207 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); 208 DISALLOW_COPY_AND_ASSIGN(ActivationObserver);
208 }; 209 };
209 210
210 // SystemTray 211 // SystemTray
211 212
212 SystemTray::SystemTray(WmShelf* wm_shelf) 213 SystemTray::SystemTray(WmShelf* wm_shelf)
213 : TrayBackgroundView(wm_shelf, true), 214 : TrayBackgroundView(wm_shelf),
214 web_notification_tray_(nullptr), 215 web_notification_tray_(nullptr),
215 detailed_item_(nullptr), 216 detailed_item_(nullptr),
216 default_bubble_height_(0), 217 default_bubble_height_(0),
217 full_system_tray_menu_(false), 218 full_system_tray_menu_(false),
218 tray_accessibility_(nullptr), 219 tray_accessibility_(nullptr),
219 tray_audio_(nullptr), 220 tray_audio_(nullptr),
220 tray_cast_(nullptr), 221 tray_cast_(nullptr),
221 tray_network_(nullptr), 222 tray_network_(nullptr),
222 tray_tiles_(nullptr), 223 tray_tiles_(nullptr),
223 tray_system_info_(nullptr), 224 tray_system_info_(nullptr),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); 308 AddTrayItem(base::MakeUnique<PaddingTrayItem>());
308 } 309 }
309 310
310 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { 311 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) {
311 SystemTrayItem* item_ptr = item.get(); 312 SystemTrayItem* item_ptr = item.get();
312 items_.push_back(std::move(item)); 313 items_.push_back(std::move(item));
313 314
314 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); 315 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
315 views::View* tray_item = 316 views::View* tray_item =
316 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); 317 item_ptr->CreateTrayView(delegate->GetUserLoginStatus());
317 item_ptr->UpdateAfterShelfAlignmentChange(shelf_alignment()); 318 item_ptr->UpdateAfterShelfAlignmentChange();
318 319
319 if (tray_item) { 320 if (tray_item) {
320 tray_container()->AddChildViewAt(tray_item, 0); 321 tray_container()->AddChildViewAt(tray_item, 0);
321 PreferredSizeChanged(); 322 PreferredSizeChanged();
322 tray_item_map_[item_ptr] = tray_item; 323 tray_item_map_[item_ptr] = tray_item;
323 } 324 }
324 } 325 }
325 326
326 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const { 327 std::vector<SystemTrayItem*> SystemTray::GetTrayItems() const {
327 std::vector<SystemTrayItem*> result; 328 std::vector<SystemTrayItem*> result;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 379
379 DestroySystemBubble(); 380 DestroySystemBubble();
380 } 381 }
381 382
382 void SystemTray::UpdateAfterLoginStatusChange(LoginStatus login_status) { 383 void SystemTray::UpdateAfterLoginStatusChange(LoginStatus login_status) {
383 DestroySystemBubble(); 384 DestroySystemBubble();
384 385
385 for (const auto& item : items_) 386 for (const auto& item : items_)
386 item->UpdateAfterLoginStatusChange(login_status); 387 item->UpdateAfterLoginStatusChange(login_status);
387 388
388 // Items default to SHELF_ALIGNMENT_BOTTOM. Update them if the initial
James Cook 2017/04/17 16:54:35 Do things still work OK if you log in with a shelf
mohsen 2017/04/19 22:59:07 As far as I can tell, UpdateAfterShelfAlignmentCha
389 // position of the shelf differs.
390 if (!IsHorizontalAlignment(shelf_alignment()))
391 UpdateAfterShelfAlignmentChange(shelf_alignment());
392
393 SetVisible(true); 389 SetVisible(true);
394 PreferredSizeChanged(); 390 PreferredSizeChanged();
395 } 391 }
396 392
397 void SystemTray::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 393 void SystemTray::UpdateItemsAfterShelfAlignmentChange() {
398 for (const auto& item : items_) 394 for (const auto& item : items_)
399 item->UpdateAfterShelfAlignmentChange(alignment); 395 item->UpdateAfterShelfAlignmentChange();
400 } 396 }
401 397
402 bool SystemTray::ShouldShowShelf() const { 398 bool SystemTray::ShouldShowShelf() const {
403 return system_bubble_.get() && system_bubble_->bubble()->ShouldShowShelf(); 399 return system_bubble_.get() && system_bubble_->bubble()->ShouldShowShelf();
404 } 400 }
405 401
406 bool SystemTray::HasSystemBubble() const { 402 bool SystemTray::HasSystemBubble() const {
407 return system_bubble_.get() != NULL; 403 return system_bubble_.get() != NULL;
408 } 404 }
409 405
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 552 }
557 553
558 base::string16 SystemTray::GetAccessibleTimeString( 554 base::string16 SystemTray::GetAccessibleTimeString(
559 const base::Time& now) const { 555 const base::Time& now) const {
560 base::HourClockType hour_type = 556 base::HourClockType hour_type =
561 Shell::Get()->system_tray_controller()->hour_clock_type(); 557 Shell::Get()->system_tray_controller()->hour_clock_type();
562 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 558 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
563 base::kKeepAmPm); 559 base::kKeepAmPm);
564 } 560 }
565 561
566 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 562 void SystemTray::UpdateAfterShelfAlignmentChange() {
567 if (alignment == shelf_alignment()) 563 TrayBackgroundView::UpdateAfterShelfAlignmentChange();
568 return; 564 UpdateItemsAfterShelfAlignmentChange();
569 TrayBackgroundView::SetShelfAlignment(alignment);
570 UpdateAfterShelfAlignmentChange(alignment);
571 // Destroy any existing bubble so that it is rebuilt correctly. 565 // Destroy any existing bubble so that it is rebuilt correctly.
572 CloseSystemBubbleAndDeactivateSystemTray(); 566 CloseSystemBubbleAndDeactivateSystemTray();
573 // Rebuild any notification bubble. 567 // Rebuild any notification bubble.
574 UpdateWebNotifications(); 568 UpdateWebNotifications();
575 } 569 }
576 570
577 void SystemTray::AnchorUpdated() { 571 void SystemTray::AnchorUpdated() {
578 if (system_bubble_) { 572 if (system_bubble_) {
579 system_bubble_->bubble_view()->UpdateBubble(); 573 system_bubble_->bubble_view()->UpdateBubble();
580 UpdateBubbleViewArrow(system_bubble_->bubble_view()); 574 UpdateBubbleViewArrow(system_bubble_->bubble_view());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 .work_area() 737 .work_area()
744 .height(); 738 .height();
745 if (work_area_height > 0) { 739 if (work_area_height > 0) {
746 UMA_HISTOGRAM_CUSTOM_COUNTS( 740 UMA_HISTOGRAM_CUSTOM_COUNTS(
747 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 741 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
748 100 * bubble_view->height() / work_area_height, 1, 300, 100); 742 100 * bubble_view->height() / work_area_height, 1, 300, 100);
749 } 743 }
750 } 744 }
751 745
752 } // namespace ash 746 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698