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

Side by Side Diff: ash/system/web_notification/web_notification_tray.cc

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_layout_manager_observer.h" 10 #include "ash/shelf/shelf_layout_manager_observer.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 namespace ash { 57 namespace ash {
58 namespace { 58 namespace {
59 59
60 // Menu commands 60 // Menu commands
61 const int kToggleQuietMode = 0; 61 const int kToggleQuietMode = 0;
62 const int kEnableQuietModeDay = 2; 62 const int kEnableQuietModeDay = 2;
63 63
64 } 64 }
65 65
66 namespace internal {
67 namespace { 66 namespace {
68 67
69 const SkColor kWebNotificationColorNoUnread = SkColorSetA(SK_ColorWHITE, 128); 68 const SkColor kWebNotificationColorNoUnread = SkColorSetA(SK_ColorWHITE, 128);
70 const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE; 69 const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE;
71 70
72 } 71 }
73 72
74 // Observes the change of work area (including temporary change by auto-hide) 73 // Observes the change of work area (including temporary change by auto-hide)
75 // and notifies MessagePopupCollection. 74 // and notifies MessagePopupCollection.
76 class WorkAreaObserver : public ShelfLayoutManagerObserver, 75 class WorkAreaObserver : public ShelfLayoutManagerObserver,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 bubble->InitializeContents(bubble_view); 225 bubble->InitializeContents(bubble_view);
227 } 226 }
228 227
229 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } 228 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); }
230 229
231 // Convenience accessors. 230 // Convenience accessors.
232 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } 231 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); }
233 232
234 private: 233 private:
235 scoped_ptr<message_center::MessageBubbleBase> bubble_; 234 scoped_ptr<message_center::MessageBubbleBase> bubble_;
236 scoped_ptr<internal::TrayBubbleWrapper> bubble_wrapper_; 235 scoped_ptr<TrayBubbleWrapper> bubble_wrapper_;
237 236
238 DISALLOW_COPY_AND_ASSIGN(WebNotificationBubbleWrapper); 237 DISALLOW_COPY_AND_ASSIGN(WebNotificationBubbleWrapper);
239 }; 238 };
240 239
241 class WebNotificationButton : public views::CustomButton { 240 class WebNotificationButton : public views::CustomButton {
242 public: 241 public:
243 WebNotificationButton(views::ButtonListener* listener) 242 WebNotificationButton(views::ButtonListener* listener)
244 : views::CustomButton(listener), 243 : views::CustomButton(listener),
245 is_bubble_visible_(false), 244 is_bubble_visible_(false),
246 unread_count_(0) { 245 unread_count_(0) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 289 }
291 290
292 bool is_bubble_visible_; 291 bool is_bubble_visible_;
293 int unread_count_; 292 int unread_count_;
294 293
295 views::Label* unread_label_; 294 views::Label* unread_label_;
296 295
297 DISALLOW_COPY_AND_ASSIGN(WebNotificationButton); 296 DISALLOW_COPY_AND_ASSIGN(WebNotificationButton);
298 }; 297 };
299 298
300 } // namespace internal 299 WebNotificationTray::WebNotificationTray(StatusAreaWidget* status_area_widget)
301
302 WebNotificationTray::WebNotificationTray(
303 internal::StatusAreaWidget* status_area_widget)
304 : TrayBackgroundView(status_area_widget), 300 : TrayBackgroundView(status_area_widget),
305 button_(NULL), 301 button_(NULL),
306 show_message_center_on_unlock_(false), 302 show_message_center_on_unlock_(false),
307 should_update_tray_content_(false), 303 should_update_tray_content_(false),
308 should_block_shelf_auto_hide_(false) { 304 should_block_shelf_auto_hide_(false) {
309 button_ = new internal::WebNotificationButton(this); 305 button_ = new WebNotificationButton(this);
310 button_->set_triggerable_event_flags( 306 button_->set_triggerable_event_flags(
311 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON); 307 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON);
312 tray_container()->AddChildView(button_); 308 tray_container()->AddChildView(button_);
313 SetContentsBackground(); 309 SetContentsBackground();
314 tray_container()->SetBorder(views::Border::NullBorder()); 310 tray_container()->SetBorder(views::Border::NullBorder());
315 SetVisible(false); 311 SetVisible(false);
316 message_center_tray_.reset(new message_center::MessageCenterTray( 312 message_center_tray_.reset(new message_center::MessageCenterTray(
317 this, 313 this,
318 message_center::MessageCenter::Get())); 314 message_center::MessageCenter::Get()));
319 popup_collection_.reset(new message_center::MessagePopupCollection( 315 popup_collection_.reset(new message_center::MessagePopupCollection(
320 ash::Shell::GetContainer( 316 ash::Shell::GetContainer(
321 status_area_widget->GetNativeView()->GetRootWindow(), 317 status_area_widget->GetNativeView()->GetRootWindow(),
322 internal::kShellWindowId_StatusContainer), 318 kShellWindowId_StatusContainer),
323 message_center(), 319 message_center(),
324 message_center_tray_.get(), 320 message_center_tray_.get(),
325 ash::switches::UseAlternateShelfLayout())); 321 ash::switches::UseAlternateShelfLayout()));
326 work_area_observer_.reset(new internal::WorkAreaObserver()); 322 work_area_observer_.reset(new WorkAreaObserver());
327 work_area_observer_->StartObserving( 323 work_area_observer_->StartObserving(
328 popup_collection_.get(), 324 popup_collection_.get(),
329 status_area_widget->GetNativeView()->GetRootWindow()); 325 status_area_widget->GetNativeView()->GetRootWindow());
330 OnMessageCenterTrayChanged(); 326 OnMessageCenterTrayChanged();
331 } 327 }
332 328
333 WebNotificationTray::~WebNotificationTray() { 329 WebNotificationTray::~WebNotificationTray() {
334 // Release any child views that might have back pointers before ~View(). 330 // Release any child views that might have back pointers before ~View().
335 message_center_bubble_.reset(); 331 message_center_bubble_.reset();
336 popup_collection_.reset(); 332 popup_collection_.reset();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 369 }
374 default: 370 default:
375 NOTREACHED(); 371 NOTREACHED();
376 } 372 }
377 373
378 message_center_bubble->SetMaxHeight(std::max(0, 374 message_center_bubble->SetMaxHeight(std::max(0,
379 max_height - GetTraySpacing())); 375 max_height - GetTraySpacing()));
380 if (show_settings) 376 if (show_settings)
381 message_center_bubble->SetSettingsVisible(); 377 message_center_bubble->SetSettingsVisible();
382 message_center_bubble_.reset( 378 message_center_bubble_.reset(
383 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); 379 new WebNotificationBubbleWrapper(this, message_center_bubble));
384 380
385 status_area_widget()->SetHideSystemNotifications(true); 381 status_area_widget()->SetHideSystemNotifications(true);
386 GetShelfLayoutManager()->UpdateAutoHideState(); 382 GetShelfLayoutManager()->UpdateAutoHideState();
387 button_->SetBubbleVisible(true); 383 button_->SetBubbleVisible(true);
388 SetDrawBackgroundAsActive(true); 384 SetDrawBackgroundAsActive(true);
389 return true; 385 return true;
390 } 386 }
391 387
392 bool WebNotificationTray::ShowMessageCenter() { 388 bool WebNotificationTray::ShowMessageCenter() {
393 return ShowMessageCenterInternal(false /* show_settings */); 389 return ShowMessageCenterInternal(false /* show_settings */);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 445 }
450 446
451 void WebNotificationTray::UpdateAfterLoginStatusChange( 447 void WebNotificationTray::UpdateAfterLoginStatusChange(
452 user::LoginStatus login_status) { 448 user::LoginStatus login_status) {
453 OnMessageCenterTrayChanged(); 449 OnMessageCenterTrayChanged();
454 } 450 }
455 451
456 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { 452 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) {
457 if (alignment == shelf_alignment()) 453 if (alignment == shelf_alignment())
458 return; 454 return;
459 internal::TrayBackgroundView::SetShelfAlignment(alignment); 455 TrayBackgroundView::SetShelfAlignment(alignment);
460 tray_container()->SetBorder(views::Border::NullBorder()); 456 tray_container()->SetBorder(views::Border::NullBorder());
461 // Destroy any existing bubble so that it will be rebuilt correctly. 457 // Destroy any existing bubble so that it will be rebuilt correctly.
462 message_center_tray_->HideMessageCenterBubble(); 458 message_center_tray_->HideMessageCenterBubble();
463 message_center_tray_->HidePopupBubble(); 459 message_center_tray_->HidePopupBubble();
464 } 460 }
465 461
466 void WebNotificationTray::AnchorUpdated() { 462 void WebNotificationTray::AnchorUpdated() {
467 if (message_center_bubble()) { 463 if (message_center_bubble()) {
468 message_center_bubble()->bubble_view()->UpdateBubble(); 464 message_center_bubble()->bubble_view()->UpdateBubble();
469 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); 465 UpdateBubbleViewArrow(message_center_bubble()->bubble_view());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 616
621 message_center::MessageCenterBubble* 617 message_center::MessageCenterBubble*
622 WebNotificationTray::GetMessageCenterBubbleForTest() { 618 WebNotificationTray::GetMessageCenterBubbleForTest() {
623 if (!message_center_bubble()) 619 if (!message_center_bubble())
624 return NULL; 620 return NULL;
625 return static_cast<message_center::MessageCenterBubble*>( 621 return static_cast<message_center::MessageCenterBubble*>(
626 message_center_bubble()->bubble()); 622 message_center_bubble()->bubble());
627 } 623 }
628 624
629 } // namespace ash 625 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | ash/system/web_notification/web_notification_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698