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

Side by Side Diff: ash/system/web_notification/web_notification_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
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/web_notification/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } // namespace message_center 59 } // namespace message_center
60 60
61 #endif // defined(OS_CHROMEOS) 61 #endif // defined(OS_CHROMEOS)
62 62
63 namespace ash { 63 namespace ash {
64 namespace { 64 namespace {
65 65
66 // Menu commands 66 // Menu commands
67 const int kToggleQuietMode = 0; 67 const int kToggleQuietMode = 0;
68 const int kEnableQuietModeDay = 2; 68 const int kEnableQuietModeDay = 2;
69
70 } 69 }
71 70
72 namespace { 71 namespace {
73 72
74 const SkColor kWebNotificationColorNoUnread = 73 const SkColor kWebNotificationColorNoUnread =
75 SkColorSetARGB(128, 255, 255, 255); 74 SkColorSetARGB(128, 255, 255, 255);
76 const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE; 75 const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE;
77 const int kNoUnreadIconSize = 18; 76 const int kNoUnreadIconSize = 18;
78 } 77 }
79 78
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 205
207 WebNotificationTray::WebNotificationTray(StatusAreaWidget* status_area_widget) 206 WebNotificationTray::WebNotificationTray(StatusAreaWidget* status_area_widget)
208 : TrayBackgroundView(status_area_widget->wm_shelf()), 207 : TrayBackgroundView(status_area_widget->wm_shelf()),
209 status_area_widget_(status_area_widget), 208 status_area_widget_(status_area_widget),
210 button_(NULL), 209 button_(NULL),
211 show_message_center_on_unlock_(false), 210 show_message_center_on_unlock_(false),
212 should_update_tray_content_(false), 211 should_update_tray_content_(false),
213 should_block_shelf_auto_hide_(false) { 212 should_block_shelf_auto_hide_(false) {
214 DCHECK(status_area_widget_); 213 DCHECK(status_area_widget_);
215 button_ = new WebNotificationButton(this); 214 button_ = new WebNotificationButton(this);
216 button_->set_triggerable_event_flags( 215 button_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON |
217 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON); 216 ui::EF_RIGHT_MOUSE_BUTTON);
218 tray_container()->AddChildView(button_); 217 tray_container()->AddChildView(button_);
219 button_->SetFocusBehavior(FocusBehavior::NEVER); 218 button_->SetFocusBehavior(FocusBehavior::NEVER);
220 SetContentsBackground(); 219 SetContentsBackground();
221 tray_container()->SetBorder(views::Border::NullBorder()); 220 tray_container()->SetBorder(views::Border::NullBorder());
222 message_center_tray_.reset(new message_center::MessageCenterTray( 221 message_center_tray_.reset(new message_center::MessageCenterTray(
223 this, 222 this, message_center::MessageCenter::Get()));
224 message_center::MessageCenter::Get()));
225 WmShelf* shelf = WmLookup::Get() 223 WmShelf* shelf = WmLookup::Get()
226 ->GetWindowForWidget(status_area_widget) 224 ->GetWindowForWidget(status_area_widget)
227 ->GetRootWindowController() 225 ->GetRootWindowController()
228 ->GetShelf(); 226 ->GetShelf();
229 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); 227 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf));
230 popup_collection_.reset(new message_center::MessagePopupCollection( 228 popup_collection_.reset(new message_center::MessagePopupCollection(
231 message_center(), 229 message_center(), message_center_tray_.get(),
232 message_center_tray_.get(),
233 popup_alignment_delegate_.get())); 230 popup_alignment_delegate_.get()));
234 const display::Display& display = WmLookup::Get() 231 const display::Display& display = WmLookup::Get()
235 ->GetWindowForWidget(status_area_widget) 232 ->GetWindowForWidget(status_area_widget)
236 ->GetDisplayNearestWindow(); 233 ->GetDisplayNearestWindow();
237 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(), 234 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(),
238 display); 235 display);
239 OnMessageCenterTrayChanged(); 236 OnMessageCenterTrayChanged();
240 } 237 }
241 238
242 WebNotificationTray::~WebNotificationTray() { 239 WebNotificationTray::~WebNotificationTray() {
243 // Release any child views that might have back pointers before ~View(). 240 // Release any child views that might have back pointers before ~View().
244 message_center_bubble_.reset(); 241 message_center_bubble_.reset();
245 popup_alignment_delegate_.reset(); 242 popup_alignment_delegate_.reset();
246 popup_collection_.reset(); 243 popup_collection_.reset();
247 } 244 }
248 245
249 // Public methods. 246 // Public methods.
250 247
251 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { 248 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) {
252 if (!ShouldShowMessageCenter()) 249 if (!ShouldShowMessageCenter())
253 return false; 250 return false;
254 251
255 should_block_shelf_auto_hide_ = true; 252 should_block_shelf_auto_hide_ = true;
256 message_center::MessageCenterBubble* message_center_bubble = 253 message_center::MessageCenterBubble* message_center_bubble =
257 new message_center::MessageCenterBubble( 254 new message_center::MessageCenterBubble(message_center(),
258 message_center(), 255 message_center_tray_.get(), true);
259 message_center_tray_.get(),
260 true);
261 256
262 int max_height; 257 int max_height;
263 if (IsHorizontalAlignment(shelf()->GetAlignment())) { 258 if (IsHorizontalAlignment(shelf()->GetAlignment())) {
264 max_height = shelf()->GetIdealBounds().y(); 259 max_height = shelf()->GetIdealBounds().y();
265 } else { 260 } else {
266 // Assume the status area and bubble bottoms are aligned when vertical. 261 // Assume the status area and bubble bottoms are aligned when vertical.
267 WmWindow* status_area_window = 262 WmWindow* status_area_window =
268 WmLookup::Get()->GetWindowForWidget(status_area_widget_); 263 WmLookup::Get()->GetWindowForWidget(status_area_widget_);
269 gfx::Rect bounds_in_root = 264 gfx::Rect bounds_in_root =
270 status_area_window->GetRootWindow()->ConvertRectFromScreen( 265 status_area_window->GetRootWindow()->ConvertRectFromScreen(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 359 }
365 360
366 void WebNotificationTray::AnchorUpdated() { 361 void WebNotificationTray::AnchorUpdated() {
367 if (message_center_bubble()) { 362 if (message_center_bubble()) {
368 message_center_bubble()->bubble_view()->UpdateBubble(); 363 message_center_bubble()->bubble_view()->UpdateBubble();
369 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); 364 UpdateBubbleViewArrow(message_center_bubble()->bubble_view());
370 } 365 }
371 } 366 }
372 367
373 base::string16 WebNotificationTray::GetAccessibleNameForTray() { 368 base::string16 WebNotificationTray::GetAccessibleNameForTray() {
374 return l10n_util::GetStringUTF16( 369 return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_ACCESSIBLE_NAME);
375 IDS_MESSAGE_CENTER_ACCESSIBLE_NAME);
376 } 370 }
377 371
378 void WebNotificationTray::HideBubbleWithView( 372 void WebNotificationTray::HideBubbleWithView(
379 const views::TrayBubbleView* bubble_view) { 373 const views::TrayBubbleView* bubble_view) {
380 if (message_center_bubble() && 374 if (message_center_bubble() &&
381 bubble_view == message_center_bubble()->bubble_view()) { 375 bubble_view == message_center_bubble()->bubble_view()) {
382 message_center_tray_->HideMessageCenterBubble(); 376 message_center_tray_->HideMessageCenterBubble();
383 } else if (popup_collection_.get()) { 377 } else if (popup_collection_.get()) {
384 message_center_tray_->HidePopupBubble(); 378 message_center_tray_->HidePopupBubble();
385 } 379 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 bubble_widget, kShellWindowId_SettingBubbleContainer, params); 419 bubble_widget, kShellWindowId_SettingBubbleContainer, params);
426 } 420 }
427 421
428 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { 422 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) {
429 HideBubbleWithView(bubble_view); 423 HideBubbleWithView(bubble_view);
430 } 424 }
431 425
432 bool WebNotificationTray::ShowNotifierSettings() { 426 bool WebNotificationTray::ShowNotifierSettings() {
433 if (message_center_bubble()) { 427 if (message_center_bubble()) {
434 static_cast<message_center::MessageCenterBubble*>( 428 static_cast<message_center::MessageCenterBubble*>(
435 message_center_bubble()->bubble())->SetSettingsVisible(); 429 message_center_bubble()->bubble())
430 ->SetSettingsVisible();
436 return true; 431 return true;
437 } 432 }
438 return ShowMessageCenterInternal(true /* show_settings */); 433 return ShowMessageCenterInternal(true /* show_settings */);
439 } 434 }
440 435
441 bool WebNotificationTray::IsContextMenuEnabled() const { 436 bool WebNotificationTray::IsContextMenuEnabled() const {
442 return IsLoggedIn(); 437 return IsLoggedIn();
443 } 438 }
444 439
445 message_center::MessageCenterTray* WebNotificationTray::GetMessageCenterTray() { 440 message_center::MessageCenterTray* WebNotificationTray::GetMessageCenterTray() {
(...skipping 15 matching lines...) Expand all
461 ui::Accelerator* accelerator) { 456 ui::Accelerator* accelerator) {
462 return false; 457 return false;
463 } 458 }
464 459
465 void WebNotificationTray::ExecuteCommand(int command_id, int event_flags) { 460 void WebNotificationTray::ExecuteCommand(int command_id, int event_flags) {
466 if (command_id == kToggleQuietMode) { 461 if (command_id == kToggleQuietMode) {
467 bool in_quiet_mode = message_center()->IsQuietMode(); 462 bool in_quiet_mode = message_center()->IsQuietMode();
468 message_center()->SetQuietMode(!in_quiet_mode); 463 message_center()->SetQuietMode(!in_quiet_mode);
469 return; 464 return;
470 } 465 }
471 base::TimeDelta expires_in = command_id == kEnableQuietModeDay ? 466 base::TimeDelta expires_in = command_id == kEnableQuietModeDay
472 base::TimeDelta::FromDays(1): 467 ? base::TimeDelta::FromDays(1)
473 base::TimeDelta::FromHours(1); 468 : base::TimeDelta::FromHours(1);
474 message_center()->EnterQuietModeWithExpire(expires_in); 469 message_center()->EnterQuietModeWithExpire(expires_in);
475 } 470 }
476 471
477 void WebNotificationTray::ButtonPressed(views::Button* sender, 472 void WebNotificationTray::ButtonPressed(views::Button* sender,
478 const ui::Event& event) { 473 const ui::Event& event) {
479 DCHECK_EQ(button_, sender); 474 DCHECK_EQ(button_, sender);
480 PerformAction(event); 475 PerformAction(event);
481 } 476 }
482 477
483 void WebNotificationTray::OnMessageCenterTrayChanged() { 478 void WebNotificationTray::OnMessageCenterTrayChanged() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 533
539 message_center::MessageCenterBubble* 534 message_center::MessageCenterBubble*
540 WebNotificationTray::GetMessageCenterBubbleForTest() { 535 WebNotificationTray::GetMessageCenterBubbleForTest() {
541 if (!message_center_bubble()) 536 if (!message_center_bubble())
542 return NULL; 537 return NULL;
543 return static_cast<message_center::MessageCenterBubble*>( 538 return static_cast<message_center::MessageCenterBubble*>(
544 message_center_bubble()->bubble()); 539 message_center_bubble()->bubble());
545 } 540 }
546 541
547 } // namespace ash 542 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698