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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_unittest.cc » ('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 "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/login_status.h" 8 #include "ash/common/login_status.h"
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void InitView(TrayBackgroundView* tray, 89 void InitView(TrayBackgroundView* tray,
90 views::View* anchor, 90 views::View* anchor,
91 TrayBubbleView::InitParams* init_params, 91 TrayBubbleView::InitParams* init_params,
92 bool is_persistent) { 92 bool is_persistent) {
93 DCHECK(anchor); 93 DCHECK(anchor);
94 LoginStatus login_status = 94 LoginStatus login_status =
95 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); 95 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus();
96 bubble_->InitView(anchor, login_status, init_params); 96 bubble_->InitView(anchor, login_status, init_params);
97 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view())); 97 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view()));
98 // The system bubble should not have an arrow. 98 // The system bubble should not have an arrow.
99 bubble_->bubble_view()->SetArrowPaintType( 99 bubble_->bubble_view()->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
100 views::BubbleBorder::PAINT_NONE);
101 is_persistent_ = is_persistent; 100 is_persistent_ = is_persistent;
102 101
103 // If ChromeVox is enabled, focus the default item if no item is focused and 102 // If ChromeVox is enabled, focus the default item if no item is focused and
104 // there isn't a delayed close. 103 // there isn't a delayed close.
105 if (Shell::GetInstance() 104 if (Shell::GetInstance()
106 ->accessibility_delegate() 105 ->accessibility_delegate()
107 ->IsSpokenFeedbackEnabled() && 106 ->IsSpokenFeedbackEnabled() &&
108 !is_persistent) { 107 !is_persistent) {
109 bubble_->FocusDefaultIfNeeded(); 108 bubble_->FocusDefaultIfNeeded();
110 } 109 }
111 } 110 }
112 111
113 // Convenience accessors: 112 // Convenience accessors:
114 SystemTrayBubble* bubble() const { return bubble_.get(); } 113 SystemTrayBubble* bubble() const { return bubble_.get(); }
115 SystemTrayBubble::BubbleType bubble_type() const { 114 SystemTrayBubble::BubbleType bubble_type() const {
116 return bubble_->bubble_type(); 115 return bubble_->bubble_type();
117 } 116 }
118 TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } 117 TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); }
119 bool is_persistent() const { return is_persistent_; } 118 bool is_persistent() const { return is_persistent_; }
120 119
121 private: 120 private:
122 std::unique_ptr<SystemTrayBubble> bubble_; 121 std::unique_ptr<SystemTrayBubble> bubble_;
123 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_; 122 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
124 bool is_persistent_; 123 bool is_persistent_;
125 124
126 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); 125 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper);
127 }; 126 };
128 127
129
130 // SystemTray 128 // SystemTray
131 129
132 SystemTray::SystemTray(StatusAreaWidget* status_area_widget) 130 SystemTray::SystemTray(StatusAreaWidget* status_area_widget)
133 : TrayBackgroundView(status_area_widget->wm_shelf()), 131 : TrayBackgroundView(status_area_widget->wm_shelf()),
134 status_area_widget_(status_area_widget), 132 status_area_widget_(status_area_widget),
135 items_(), 133 items_(),
136 detailed_item_(nullptr), 134 detailed_item_(nullptr),
137 default_bubble_height_(0), 135 default_bubble_height_(0),
138 hide_notifications_(false), 136 hide_notifications_(false),
139 full_system_tray_menu_(false), 137 full_system_tray_menu_(false),
140 tray_accessibility_(nullptr), 138 tray_accessibility_(nullptr),
141 tray_cast_(nullptr), 139 tray_cast_(nullptr),
142 tray_date_(nullptr), 140 tray_date_(nullptr),
143 tray_update_(nullptr), 141 tray_update_(nullptr),
144 screen_capture_tray_item_(nullptr), 142 screen_capture_tray_item_(nullptr),
145 screen_share_tray_item_(nullptr) { 143 screen_share_tray_item_(nullptr) {
146 DCHECK(status_area_widget_); 144 DCHECK(status_area_widget_);
147 SetContentsBackground(); 145 SetContentsBackground();
148 } 146 }
149 147
150 SystemTray::~SystemTray() { 148 SystemTray::~SystemTray() {
151 // Destroy any child views that might have back pointers before ~View(). 149 // Destroy any child views that might have back pointers before ~View().
152 system_bubble_.reset(); 150 system_bubble_.reset();
153 notification_bubble_.reset(); 151 notification_bubble_.reset();
154 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 152 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
155 it != items_.end(); 153 it != items_.end(); ++it) {
156 ++it) {
157 (*it)->DestroyTrayView(); 154 (*it)->DestroyTrayView();
158 } 155 }
159 } 156 }
160 157
161 void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { 158 void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) {
162 TrayBackgroundView::Initialize(); 159 TrayBackgroundView::Initialize();
163 CreateItems(delegate); 160 CreateItems(delegate);
164 } 161 }
165 162
166 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { 163 void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void SystemTray::RemoveTrayItem(SystemTrayItem* item) { 233 void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
237 NOTIMPLEMENTED(); 234 NOTIMPLEMENTED();
238 } 235 }
239 236
240 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const { 237 const std::vector<SystemTrayItem*>& SystemTray::GetTrayItems() const {
241 return items_.get(); 238 return items_.get();
242 } 239 }
243 240
244 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) { 241 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) {
245 ShowDefaultViewWithOffset( 242 ShowDefaultViewWithOffset(
246 creation_type, 243 creation_type, TrayBubbleView::InitParams::kArrowDefaultOffset, false);
247 TrayBubbleView::InitParams::kArrowDefaultOffset,
248 false);
249 } 244 }
250 245
251 void SystemTray::ShowPersistentDefaultView() { 246 void SystemTray::ShowPersistentDefaultView() {
252 ShowItems(items_.get(), 247 ShowItems(items_.get(), false, false, BUBBLE_CREATE_NEW,
253 false, 248 TrayBubbleView::InitParams::kArrowDefaultOffset, true);
254 false,
255 BUBBLE_CREATE_NEW,
256 TrayBubbleView::InitParams::kArrowDefaultOffset,
257 true);
258 } 249 }
259 250
260 void SystemTray::ShowDetailedView(SystemTrayItem* item, 251 void SystemTray::ShowDetailedView(SystemTrayItem* item,
261 int close_delay, 252 int close_delay,
262 bool activate, 253 bool activate,
263 BubbleCreationType creation_type) { 254 BubbleCreationType creation_type) {
264 std::vector<SystemTrayItem*> items; 255 std::vector<SystemTrayItem*> items;
265 // The detailed view with timeout means a UI to show the current system state, 256 // The detailed view with timeout means a UI to show the current system state,
266 // like the audio level or brightness. Such UI should behave as persistent and 257 // like the audio level or brightness. Such UI should behave as persistent and
267 // keep its own logic for the appearance. 258 // keep its own logic for the appearance.
268 bool persistent = ( 259 bool persistent =
269 !activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW); 260 (!activate && close_delay > 0 && creation_type == BUBBLE_CREATE_NEW);
270 items.push_back(item); 261 items.push_back(item);
271 ShowItems( 262 ShowItems(items, true, activate, creation_type, GetTrayXOffset(item),
272 items, true, activate, creation_type, GetTrayXOffset(item), persistent); 263 persistent);
273 if (system_bubble_) 264 if (system_bubble_)
274 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); 265 system_bubble_->bubble()->StartAutoCloseTimer(close_delay);
275 } 266 }
276 267
277 void SystemTray::SetDetailedViewCloseDelay(int close_delay) { 268 void SystemTray::SetDetailedViewCloseDelay(int close_delay) {
278 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED)) 269 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DETAILED))
279 system_bubble_->bubble()->StartAutoCloseTimer(close_delay); 270 system_bubble_->bubble()->StartAutoCloseTimer(close_delay);
280 } 271 }
281 272
282 void SystemTray::HideDetailedView(SystemTrayItem* item) { 273 void SystemTray::HideDetailedView(SystemTrayItem* item) {
283 if (item != detailed_item_) 274 if (item != detailed_item_)
284 return; 275 return;
285 DestroySystemBubble(); 276 DestroySystemBubble();
286 UpdateNotificationBubble(); 277 UpdateNotificationBubble();
287 } 278 }
288 279
289 void SystemTray::ShowNotificationView(SystemTrayItem* item) { 280 void SystemTray::ShowNotificationView(SystemTrayItem* item) {
290 if (std::find(notification_items_.begin(), notification_items_.end(), item) 281 if (std::find(notification_items_.begin(), notification_items_.end(), item) !=
291 != notification_items_.end()) 282 notification_items_.end())
292 return; 283 return;
293 notification_items_.push_back(item); 284 notification_items_.push_back(item);
294 UpdateNotificationBubble(); 285 UpdateNotificationBubble();
295 } 286 }
296 287
297 void SystemTray::HideNotificationView(SystemTrayItem* item) { 288 void SystemTray::HideNotificationView(SystemTrayItem* item) {
298 std::vector<SystemTrayItem*>::iterator found_iter = 289 std::vector<SystemTrayItem*>::iterator found_iter =
299 std::find(notification_items_.begin(), notification_items_.end(), item); 290 std::find(notification_items_.begin(), notification_items_.end(), item);
300 if (found_iter == notification_items_.end()) 291 if (found_iter == notification_items_.end())
301 return; 292 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return notification_bubble_.get() != NULL; 335 return notification_bubble_.get() != NULL;
345 } 336 }
346 337
347 SystemTrayBubble* SystemTray::GetSystemBubble() { 338 SystemTrayBubble* SystemTray::GetSystemBubble() {
348 if (!system_bubble_) 339 if (!system_bubble_)
349 return NULL; 340 return NULL;
350 return system_bubble_->bubble(); 341 return system_bubble_->bubble();
351 } 342 }
352 343
353 bool SystemTray::IsAnyBubbleVisible() const { 344 bool SystemTray::IsAnyBubbleVisible() const {
354 return ((system_bubble_.get() && 345 return ((system_bubble_.get() && system_bubble_->bubble()->IsVisible()) ||
355 system_bubble_->bubble()->IsVisible()) ||
356 (notification_bubble_.get() && 346 (notification_bubble_.get() &&
357 notification_bubble_->bubble()->IsVisible())); 347 notification_bubble_->bubble()->IsVisible()));
358 } 348 }
359 349
360 bool SystemTray::IsMouseInNotificationBubble() const { 350 bool SystemTray::IsMouseInNotificationBubble() const {
361 if (!notification_bubble_) 351 if (!notification_bubble_)
362 return false; 352 return false;
363 return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains( 353 return notification_bubble_->bubble_view()->GetBoundsInScreen().Contains(
364 display::Screen::GetScreen()->GetCursorScreenPoint()); 354 display::Screen::GetScreen()->GetCursorScreenPoint());
365 } 355 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 UpdateWebNotifications(); 391 UpdateWebNotifications();
402 } 392 }
403 } 393 }
404 394
405 base::string16 SystemTray::GetAccessibleNameForTray() { 395 base::string16 SystemTray::GetAccessibleNameForTray() {
406 base::string16 time = GetAccessibleTimeString(base::Time::Now()); 396 base::string16 time = GetAccessibleTimeString(base::Time::Now());
407 base::string16 battery = base::ASCIIToUTF16(""); 397 base::string16 battery = base::ASCIIToUTF16("");
408 #if defined(OS_CHROMEOS) 398 #if defined(OS_CHROMEOS)
409 battery = PowerStatus::Get()->GetAccessibleNameString(false); 399 battery = PowerStatus::Get()->GetAccessibleNameString(false);
410 #endif 400 #endif
411 return l10n_util::GetStringFUTF16( 401 return l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION,
412 IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, time, battery); 402 time, battery);
413 } 403 }
414 404
415 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { 405 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const {
416 // Don't attempt to align the arrow if the shelf is on the left or right. 406 // Don't attempt to align the arrow if the shelf is on the left or right.
417 if (!IsHorizontalAlignment(shelf_alignment())) 407 if (!IsHorizontalAlignment(shelf_alignment()))
418 return TrayBubbleView::InitParams::kArrowDefaultOffset; 408 return TrayBubbleView::InitParams::kArrowDefaultOffset;
419 409
420 std::map<SystemTrayItem*, views::View*>::const_iterator it = 410 std::map<SystemTrayItem*, views::View*>::const_iterator it =
421 tray_item_map_.find(item); 411 tray_item_map_.find(item);
422 if (it == tray_item_map_.end()) 412 if (it == tray_item_map_.end())
(...skipping 25 matching lines...) Expand all
448 BubbleCreationType creation_type, 438 BubbleCreationType creation_type,
449 int arrow_offset, 439 int arrow_offset,
450 bool persistent) { 440 bool persistent) {
451 // No system tray bubbles in kiosk mode. 441 // No system tray bubbles in kiosk mode.
452 if (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() == 442 if (WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() ==
453 LoginStatus::KIOSK_APP) { 443 LoginStatus::KIOSK_APP) {
454 return; 444 return;
455 } 445 }
456 446
457 // Destroy any existing bubble and create a new one. 447 // Destroy any existing bubble and create a new one.
458 SystemTrayBubble::BubbleType bubble_type = detailed ? 448 SystemTrayBubble::BubbleType bubble_type =
459 SystemTrayBubble::BUBBLE_TYPE_DETAILED : 449 detailed ? SystemTrayBubble::BUBBLE_TYPE_DETAILED
460 SystemTrayBubble::BUBBLE_TYPE_DEFAULT; 450 : SystemTrayBubble::BUBBLE_TYPE_DEFAULT;
461 451
462 // Destroy the notification bubble here so that it doesn't get rebuilt 452 // Destroy the notification bubble here so that it doesn't get rebuilt
463 // while we add items to the main bubble_ (e.g. in HideNotificationView). 453 // while we add items to the main bubble_ (e.g. in HideNotificationView).
464 notification_bubble_.reset(); 454 notification_bubble_.reset();
465 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) { 455 if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) {
466 system_bubble_->bubble()->UpdateView(items, bubble_type); 456 system_bubble_->bubble()->UpdateView(items, bubble_type);
467 // If ChromeVox is enabled, focus the default item if no item is focused. 457 // If ChromeVox is enabled, focus the default item if no item is focused.
468 if (Shell::GetInstance()->accessibility_delegate()-> 458 if (Shell::GetInstance()
469 IsSpokenFeedbackEnabled()) { 459 ->accessibility_delegate()
460 ->IsSpokenFeedbackEnabled()) {
470 system_bubble_->bubble()->FocusDefaultIfNeeded(); 461 system_bubble_->bubble()->FocusDefaultIfNeeded();
471 } 462 }
472 } else { 463 } else {
473 // Cleanup the existing bubble before showing a new one. Otherwise, it's 464 // Cleanup the existing bubble before showing a new one. Otherwise, it's
474 // possible to confuse the new system bubble with the old one during 465 // possible to confuse the new system bubble with the old one during
475 // destruction, leading to subtle errors/crashes such as crbug.com/545166. 466 // destruction, leading to subtle errors/crashes such as crbug.com/545166.
476 DestroySystemBubble(); 467 DestroySystemBubble();
477 468
478 // Remember if the menu is a single property (like e.g. volume) or the 469 // Remember if the menu is a single property (like e.g. volume) or the
479 // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case 470 // full tray menu. Note that in case of the |BUBBLE_USE_EXISTING| case
480 // above, |full_system_tray_menu_| does not get changed since the fact that 471 // above, |full_system_tray_menu_| does not get changed since the fact that
481 // the menu is full (or not) doesn't change even if a "single property" 472 // the menu is full (or not) doesn't change even if a "single property"
482 // (like network) replaces most of the menu. 473 // (like network) replaces most of the menu.
483 full_system_tray_menu_ = items.size() > 1; 474 full_system_tray_menu_ = items.size() > 1;
484 // The menu width is fixed, and it is a per language setting. 475 // The menu width is fixed, and it is a per language setting.
485 int menu_width = std::max( 476 int menu_width = std::max(
486 kMinimumSystemTrayMenuWidth, 477 kMinimumSystemTrayMenuWidth,
487 WmShell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth()); 478 WmShell::Get()->system_tray_delegate()->GetSystemTrayMenuWidth());
488 479
489 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, 480 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY,
490 GetAnchorAlignment(), 481 GetAnchorAlignment(), menu_width,
491 menu_width,
492 kTrayPopupMaxWidth); 482 kTrayPopupMaxWidth);
493 init_params.can_activate = can_activate; 483 init_params.can_activate = can_activate;
494 init_params.first_item_has_no_margin = true; 484 init_params.first_item_has_no_margin = true;
495 if (detailed) { 485 if (detailed) {
496 // This is the case where a volume control or brightness control bubble 486 // This is the case where a volume control or brightness control bubble
497 // is created. 487 // is created.
498 init_params.max_height = default_bubble_height_; 488 init_params.max_height = default_bubble_height_;
499 init_params.arrow_color = kBackgroundColor; 489 init_params.arrow_color = kBackgroundColor;
500 } else { 490 } else {
501 init_params.arrow_color = kHeaderBackgroundColor; 491 init_params.arrow_color = kHeaderBackgroundColor;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 notification_bubble_.reset(); 537 notification_bubble_.reset();
548 SystemTrayBubble* notification_bubble; 538 SystemTrayBubble* notification_bubble;
549 notification_bubble = new SystemTrayBubble( 539 notification_bubble = new SystemTrayBubble(
550 this, notification_items_, SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION); 540 this, notification_items_, SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION);
551 views::View* anchor; 541 views::View* anchor;
552 TrayBubbleView::AnchorType anchor_type; 542 TrayBubbleView::AnchorType anchor_type;
553 // Tray items might want to show notifications while we are creating and 543 // Tray items might want to show notifications while we are creating and
554 // initializing the |system_bubble_| - but it might not be fully initialized 544 // initializing the |system_bubble_| - but it might not be fully initialized
555 // when coming here - this would produce a crashed like crbug.com/247416. 545 // when coming here - this would produce a crashed like crbug.com/247416.
556 // As such we check the existence of the widget here. 546 // As such we check the existence of the widget here.
557 if (system_bubble_.get() && 547 if (system_bubble_.get() && system_bubble_->bubble_view() &&
558 system_bubble_->bubble_view() &&
559 system_bubble_->bubble_view()->GetWidget()) { 548 system_bubble_->bubble_view()->GetWidget()) {
560 anchor = system_bubble_->bubble_view(); 549 anchor = system_bubble_->bubble_view();
561 anchor_type = TrayBubbleView::ANCHOR_TYPE_BUBBLE; 550 anchor_type = TrayBubbleView::ANCHOR_TYPE_BUBBLE;
562 } else { 551 } else {
563 anchor = tray_container(); 552 anchor = tray_container();
564 anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY; 553 anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY;
565 } 554 }
566 TrayBubbleView::InitParams init_params(anchor_type, 555 TrayBubbleView::InitParams init_params(anchor_type, GetAnchorAlignment(),
567 GetAnchorAlignment(),
568 kTrayPopupMinWidth, 556 kTrayPopupMinWidth,
569 kTrayPopupMaxWidth); 557 kTrayPopupMaxWidth);
570 init_params.first_item_has_no_margin = true; 558 init_params.first_item_has_no_margin = true;
571 init_params.arrow_color = kBackgroundColor; 559 init_params.arrow_color = kBackgroundColor;
572 init_params.arrow_offset = GetTrayXOffset(notification_items_[0]); 560 init_params.arrow_offset = GetTrayXOffset(notification_items_[0]);
573 notification_bubble_.reset(new SystemBubbleWrapper(notification_bubble)); 561 notification_bubble_.reset(new SystemBubbleWrapper(notification_bubble));
574 notification_bubble_->InitView(this, anchor, &init_params, false); 562 notification_bubble_->InitView(this, anchor, &init_params, false);
575 563
576 if (notification_bubble->bubble_view()->child_count() == 0) { 564 if (notification_bubble->bubble_view()->child_count() == 0) {
577 // It is possible that none of the items generated actual notifications. 565 // It is possible that none of the items generated actual notifications.
(...skipping 22 matching lines...) Expand all
600 height = 588 height =
601 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y()); 589 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y());
602 } 590 }
603 status_area_widget_->web_notification_tray()->SetSystemTrayHeight(height); 591 status_area_widget_->web_notification_tray()->SetSystemTrayHeight(height);
604 } 592 }
605 593
606 base::string16 SystemTray::GetAccessibleTimeString( 594 base::string16 SystemTray::GetAccessibleTimeString(
607 const base::Time& now) const { 595 const base::Time& now) const {
608 base::HourClockType hour_type = 596 base::HourClockType hour_type =
609 WmShell::Get()->system_tray_delegate()->GetHourClockType(); 597 WmShell::Get()->system_tray_delegate()->GetHourClockType();
610 return base::TimeFormatTimeOfDayWithHourClockType( 598 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type,
611 now, hour_type, base::kKeepAmPm); 599 base::kKeepAmPm);
612 } 600 }
613 601
614 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 602 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
615 if (alignment == shelf_alignment()) 603 if (alignment == shelf_alignment())
616 return; 604 return;
617 TrayBackgroundView::SetShelfAlignment(alignment); 605 TrayBackgroundView::SetShelfAlignment(alignment);
618 UpdateAfterShelfAlignmentChange(alignment); 606 UpdateAfterShelfAlignmentChange(alignment);
619 // Destroy any existing bubble so that it is rebuilt correctly. 607 // Destroy any existing bubble so that it is rebuilt correctly.
620 CloseSystemBubbleAndDeactivateSystemTray(); 608 CloseSystemBubbleAndDeactivateSystemTray();
621 // Rebuild any notification bubble. 609 // Rebuild any notification bubble.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { 693 void SystemTray::HideBubble(const TrayBubbleView* bubble_view) {
706 HideBubbleWithView(bubble_view); 694 HideBubbleWithView(bubble_view);
707 } 695 }
708 696
709 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { 697 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) {
710 std::map<SystemTrayItem*, views::View*>::iterator it = 698 std::map<SystemTrayItem*, views::View*>::iterator it =
711 tray_item_map_.find(item); 699 tray_item_map_.find(item);
712 return it == tray_item_map_.end() ? NULL : it->second; 700 return it == tray_item_map_.end() ? NULL : it->second;
713 } 701 }
714 702
715 TrayCast* SystemTray::GetTrayCastForTesting() const { return tray_cast_; } 703 TrayCast* SystemTray::GetTrayCastForTesting() const {
704 return tray_cast_;
705 }
716 706
717 TrayDate* SystemTray::GetTrayDateForTesting() const { return tray_date_; } 707 TrayDate* SystemTray::GetTrayDateForTesting() const {
708 return tray_date_;
709 }
718 710
719 TrayUpdate* SystemTray::GetTrayUpdateForTesting() const { 711 TrayUpdate* SystemTray::GetTrayUpdateForTesting() const {
720 return tray_update_; 712 return tray_update_;
721 } 713 }
722 714
723 bool SystemTray::PerformAction(const ui::Event& event) { 715 bool SystemTray::PerformAction(const ui::Event& event) {
724 // If we're already showing the default view, hide it; otherwise, show it 716 // If we're already showing the default view, hide it; otherwise, show it
725 // (and hide any popup that's currently shown). 717 // (and hide any popup that's currently shown).
726 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { 718 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) {
727 system_bubble_->bubble()->Close(); 719 system_bubble_->bubble()->Close();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 .work_area() 762 .work_area()
771 .height(); 763 .height();
772 if (work_area_height > 0) { 764 if (work_area_height > 0) {
773 UMA_HISTOGRAM_CUSTOM_COUNTS( 765 UMA_HISTOGRAM_CUSTOM_COUNTS(
774 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 766 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
775 100 * bubble_view->height() / work_area_height, 1, 300, 100); 767 100 * bubble_view->height() / work_area_height, 1, 300, 100);
776 } 768 }
777 } 769 }
778 770
779 } // namespace ash 771 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698