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

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

Issue 2551443003: Justify the message center to the right of the screen (i.e. the same place as the system menu). (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | 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/common/system/web_notification/web_notification_tray.h" 5 #include "ash/common/system/web_notification/web_notification_tray.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/shelf_constants.h" 9 #include "ash/common/shelf/shelf_constants.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/shelf/wm_shelf_util.h" 11 #include "ash/common/shelf/wm_shelf_util.h"
12 #include "ash/common/system/status_area_widget.h"
12 #include "ash/common/system/tray/system_tray.h" 13 #include "ash/common/system/tray/system_tray.h"
13 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
14 #include "ash/common/system/tray/tray_bubble_wrapper.h" 15 #include "ash/common/system/tray/tray_bubble_wrapper.h"
15 #include "ash/common/system/tray/tray_constants.h" 16 #include "ash/common/system/tray/tray_constants.h"
16 #include "ash/common/system/tray/tray_utils.h" 17 #include "ash/common/system/tray/tray_utils.h"
17 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" 18 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h"
18 #include "ash/common/wm_lookup.h" 19 #include "ash/common/wm_lookup.h"
19 #include "ash/common/wm_root_window_controller.h" 20 #include "ash/common/wm_root_window_controller.h"
20 #include "ash/common/wm_shell.h" 21 #include "ash/common/wm_shell.h"
21 #include "ash/common/wm_window.h" 22 #include "ash/common/wm_window.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const int kNoUnreadIconSize = 18; 90 const int kNoUnreadIconSize = 18;
90 91
91 } // namespace 92 } // namespace
92 93
93 // Class to initialize and manage the WebNotificationBubble and 94 // Class to initialize and manage the WebNotificationBubble and
94 // TrayBubbleWrapper instances for a bubble. 95 // TrayBubbleWrapper instances for a bubble.
95 class WebNotificationBubbleWrapper { 96 class WebNotificationBubbleWrapper {
96 public: 97 public:
97 // Takes ownership of |bubble| and creates |bubble_wrapper_|. 98 // Takes ownership of |bubble| and creates |bubble_wrapper_|.
98 WebNotificationBubbleWrapper(WebNotificationTray* tray, 99 WebNotificationBubbleWrapper(WebNotificationTray* tray,
100 TrayBackgroundView* anchor_tray,
99 message_center::MessageBubbleBase* bubble) { 101 message_center::MessageBubbleBase* bubble) {
100 bubble_.reset(bubble); 102 bubble_.reset(bubble);
101 views::TrayBubbleView::AnchorAlignment anchor_alignment = 103 views::TrayBubbleView::AnchorAlignment anchor_alignment =
102 tray->GetAnchorAlignment(); 104 tray->GetAnchorAlignment();
103 views::TrayBubbleView::InitParams init_params = 105 views::TrayBubbleView::InitParams init_params =
104 bubble->GetInitParams(anchor_alignment); 106 bubble->GetInitParams(anchor_alignment);
105 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( 107 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create(
106 tray->GetBubbleAnchor(), tray, &init_params); 108 anchor_tray->GetBubbleAnchor(), tray, &init_params);
107 bubble_view->set_anchor_view_insets(tray->GetBubbleAnchorInsets()); 109 bubble_view->set_anchor_view_insets(anchor_tray->GetBubbleAnchorInsets());
108 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); 110 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view));
109 bubble->InitializeContents(bubble_view); 111 bubble->InitializeContents(bubble_view);
110 } 112 }
111 113
112 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } 114 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); }
113 115
114 // Convenience accessors. 116 // Convenience accessors.
115 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } 117 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); }
116 118
117 private: 119 private:
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Assume the status area and bubble bottoms are aligned when vertical. 368 // Assume the status area and bubble bottoms are aligned when vertical.
367 gfx::Rect bounds_in_root = 369 gfx::Rect bounds_in_root =
368 status_area_window_->GetRootWindow()->ConvertRectFromScreen( 370 status_area_window_->GetRootWindow()->ConvertRectFromScreen(
369 status_area_window_->GetBoundsInScreen()); 371 status_area_window_->GetBoundsInScreen());
370 max_height = bounds_in_root.bottom(); 372 max_height = bounds_in_root.bottom();
371 } 373 }
372 message_center_bubble->SetMaxHeight( 374 message_center_bubble->SetMaxHeight(
373 std::max(0, max_height - GetTrayConstant(TRAY_SPACING))); 375 std::max(0, max_height - GetTrayConstant(TRAY_SPACING)));
374 if (show_settings) 376 if (show_settings)
375 message_center_bubble->SetSettingsVisible(); 377 message_center_bubble->SetSettingsVisible();
376 message_center_bubble_.reset( 378
377 new WebNotificationBubbleWrapper(this, message_center_bubble)); 379 // For vertical shelf alignments, anchor to the WebNotificationTray, but for
380 // horizontal (i.e. bottom) shelves, anchor to the system tray.
381 TrayBackgroundView* anchor_tray = this;
382 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
383 anchor_tray = WmShelf::ForWindow(status_area_window_)
384 ->GetStatusAreaWidget()
385 ->system_tray();
386 }
387
388 message_center_bubble_.reset(new WebNotificationBubbleWrapper(
389 this, anchor_tray, message_center_bubble));
378 390
379 system_tray_->SetHideNotifications(true); 391 system_tray_->SetHideNotifications(true);
380 shelf()->UpdateAutoHideState(); 392 shelf()->UpdateAutoHideState();
381 SetIsActive(true); 393 SetIsActive(true);
382 return true; 394 return true;
383 } 395 }
384 396
385 bool WebNotificationTray::ShowMessageCenter() { 397 bool WebNotificationTray::ShowMessageCenter() {
386 return ShowMessageCenterInternal(false /* show_settings */); 398 return ShowMessageCenterInternal(false /* show_settings */);
387 } 399 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 671
660 message_center::MessageCenterBubble* 672 message_center::MessageCenterBubble*
661 WebNotificationTray::GetMessageCenterBubbleForTest() { 673 WebNotificationTray::GetMessageCenterBubbleForTest() {
662 if (!message_center_bubble()) 674 if (!message_center_bubble())
663 return nullptr; 675 return nullptr;
664 return static_cast<message_center::MessageCenterBubble*>( 676 return static_cast<message_center::MessageCenterBubble*>(
665 message_center_bubble()->bubble()); 677 message_center_bubble()->bubble());
666 } 678 }
667 679
668 } // namespace ash 680 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698