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

Side by Side Diff: ash/common/system/tray/system_tray.cc

Issue 2761063002: Move more from WmShell to Shell (Closed)
Patch Set: merge Created 3 years, 9 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/common/system/tray/system_tray.h" 5 #include "ash/common/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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 : bubble_(bubble), is_persistent_(false) {} 122 : bubble_(bubble), is_persistent_(false) {}
123 123
124 // Initializes the bubble view and creates |bubble_wrapper_|. 124 // Initializes the bubble view and creates |bubble_wrapper_|.
125 void InitView(TrayBackgroundView* tray, 125 void InitView(TrayBackgroundView* tray,
126 views::View* anchor, 126 views::View* anchor,
127 const gfx::Insets& anchor_insets, 127 const gfx::Insets& anchor_insets,
128 TrayBubbleView::InitParams* init_params, 128 TrayBubbleView::InitParams* init_params,
129 bool is_persistent) { 129 bool is_persistent) {
130 DCHECK(anchor); 130 DCHECK(anchor);
131 LoginStatus login_status = 131 LoginStatus login_status =
132 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); 132 Shell::Get()->system_tray_delegate()->GetUserLoginStatus();
133 bubble_->InitView(anchor, login_status, init_params); 133 bubble_->InitView(anchor, login_status, init_params);
134 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets); 134 bubble_->bubble_view()->set_anchor_view_insets(anchor_insets);
135 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); 135 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view()));
136 is_persistent_ = is_persistent; 136 is_persistent_ = is_persistent;
137 137
138 // If ChromeVox is enabled, focus the default item if no item is focused and 138 // If ChromeVox is enabled, focus the default item if no item is focused and
139 // there isn't a delayed close. 139 // there isn't a delayed close.
140 if (Shell::GetInstance() 140 if (Shell::GetInstance()
141 ->accessibility_delegate() 141 ->accessibility_delegate()
142 ->IsSpokenFeedbackEnabled() && 142 ->IsSpokenFeedbackEnabled() &&
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 AddTrayItem(base::MakeUnique<PaddingTrayItem>()); 321 AddTrayItem(base::MakeUnique<PaddingTrayItem>());
322 } else { 322 } else {
323 AddTrayItem(base::WrapUnique(tray_date_)); 323 AddTrayItem(base::WrapUnique(tray_date_));
324 } 324 }
325 } 325 }
326 326
327 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) { 327 void SystemTray::AddTrayItem(std::unique_ptr<SystemTrayItem> item) {
328 SystemTrayItem* item_ptr = item.get(); 328 SystemTrayItem* item_ptr = item.get();
329 items_.push_back(std::move(item)); 329 items_.push_back(std::move(item));
330 330
331 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 331 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate();
332 views::View* tray_item = 332 views::View* tray_item =
333 item_ptr->CreateTrayView(delegate->GetUserLoginStatus()); 333 item_ptr->CreateTrayView(delegate->GetUserLoginStatus());
334 item_ptr->UpdateAfterShelfAlignmentChange(shelf_alignment()); 334 item_ptr->UpdateAfterShelfAlignmentChange(shelf_alignment());
335 335
336 if (tray_item) { 336 if (tray_item) {
337 tray_container()->AddChildViewAt(tray_item, 0); 337 tray_container()->AddChildViewAt(tray_item, 0);
338 PreferredSizeChanged(); 338 PreferredSizeChanged();
339 tray_item_map_[item_ptr] = tray_item; 339 tray_item_map_[item_ptr] = tray_item;
340 } 340 }
341 } 341 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 time, battery); 471 time, battery);
472 } 472 }
473 473
474 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, 474 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
475 bool detailed, 475 bool detailed,
476 bool can_activate, 476 bool can_activate,
477 BubbleCreationType creation_type, 477 BubbleCreationType creation_type,
478 bool persistent) { 478 bool persistent) {
479 // No system tray bubbles in kiosk mode. 479 // No system tray bubbles in kiosk mode.
480 SystemTrayDelegate* system_tray_delegate = 480 SystemTrayDelegate* system_tray_delegate =
481 WmShell::Get()->system_tray_delegate(); 481 Shell::Get()->system_tray_delegate();
482 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP || 482 if (system_tray_delegate->GetUserLoginStatus() == LoginStatus::KIOSK_APP ||
483 system_tray_delegate->GetUserLoginStatus() == 483 system_tray_delegate->GetUserLoginStatus() ==
484 LoginStatus::ARC_KIOSK_APP) { 484 LoginStatus::ARC_KIOSK_APP) {
485 return; 485 return;
486 } 486 }
487 487
488 // Destroy any existing bubble and create a new one. 488 // Destroy any existing bubble and create a new one.
489 SystemTrayBubble::BubbleType bubble_type = 489 SystemTrayBubble::BubbleType bubble_type =
490 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED 490 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED
491 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT; 491 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT;
(...skipping 17 matching lines...) Expand all
509 // the menu is full (or not) doesn't change even if a "single property" 509 // the menu is full (or not) doesn't change even if a "single property"
510 // (like network) replaces most of the menu. 510 // (like network) replaces most of the menu.
511 full_system_tray_menu_ = items.size() > 1; 511 full_system_tray_menu_ = items.size() > 1;
512 512
513 // The menu width is fixed for all languages in material design. 513 // The menu width is fixed for all languages in material design.
514 int menu_width = kTrayMenuMinimumWidthMd; 514 int menu_width = kTrayMenuMinimumWidthMd;
515 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { 515 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
516 // The menu width is fixed, and it is a per language setting. 516 // The menu width is fixed, and it is a per language setting.
517 menu_width = std::max( 517 menu_width = std::max(
518 kTrayMenuMinimumWidth, 518 kTrayMenuMinimumWidth,
519 WmShell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth()); 519 Shell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth());
520 } 520 }
521 521
522 TrayBubbleView::InitParams init_params(GetAnchorAlignment(), menu_width, 522 TrayBubbleView::InitParams init_params(GetAnchorAlignment(), menu_width,
523 kTrayPopupMaxWidth); 523 kTrayPopupMaxWidth);
524 // TODO(oshima): Change TrayBubbleView itself. 524 // TODO(oshima): Change TrayBubbleView itself.
525 init_params.can_activate = false; 525 init_params.can_activate = false;
526 if (detailed) { 526 if (detailed) {
527 // This is the case where a volume control or brightness control bubble 527 // This is the case where a volume control or brightness control bubble
528 // is created. 528 // is created.
529 init_params.max_height = default_bubble_height_; 529 init_params.max_height = default_bubble_height_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 height = 582 height =
583 std::max(0, work_area.bottom() - bubble_view->GetBoundsInScreen().y()); 583 std::max(0, work_area.bottom() - bubble_view->GetBoundsInScreen().y());
584 } 584 }
585 if (web_notification_tray_) 585 if (web_notification_tray_)
586 web_notification_tray_->SetTrayBubbleHeight(height); 586 web_notification_tray_->SetTrayBubbleHeight(height);
587 } 587 }
588 588
589 base::string16 SystemTray::GetAccessibleTimeString( 589 base::string16 SystemTray::GetAccessibleTimeString(
590 const base::Time& now) const { 590 const base::Time& now) const {
591 base::HourClockType hour_type = 591 base::HourClockType hour_type =
592 WmShell::Get()->system_tray_controller()->hour_clock_type(); 592 Shell::Get()->system_tray_controller()->hour_clock_type();
593 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, 593 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
594 base::kKeepAmPm); 594 base::kKeepAmPm);
595 } 595 }
596 596
597 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 597 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
598 if (alignment == shelf_alignment()) 598 if (alignment == shelf_alignment())
599 return; 599 return;
600 TrayBackgroundView::SetShelfAlignment(alignment); 600 TrayBackgroundView::SetShelfAlignment(alignment);
601 UpdateAfterShelfAlignmentChange(alignment); 601 UpdateAfterShelfAlignmentChange(alignment);
602 // Destroy any existing bubble so that it is rebuilt correctly. 602 // Destroy any existing bubble so that it is rebuilt correctly.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 .work_area() 780 .work_area()
781 .height(); 781 .height();
782 if (work_area_height > 0) { 782 if (work_area_height > 0) {
783 UMA_HISTOGRAM_CUSTOM_COUNTS( 783 UMA_HISTOGRAM_CUSTOM_COUNTS(
784 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 784 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
785 100 * bubble_view->height() / work_area_height, 1, 300, 100); 785 100 * bubble_view->height() / work_area_height, 1, 300, 100);
786 } 786 }
787 } 787 }
788 788
789 } // namespace ash 789 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tiles/tiles_default_view.cc ('k') | ash/common/system/tray/system_tray_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698