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

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

Issue 2668033004: [ash] Fix message center maximum height for vertical shelf alignments. (Closed)
Patch Set: Created 3 years, 10 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 | « 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"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { 351 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) {
352 if (!ShouldShowMessageCenter()) 352 if (!ShouldShowMessageCenter())
353 return false; 353 return false;
354 354
355 should_block_shelf_auto_hide_ = true; 355 should_block_shelf_auto_hide_ = true;
356 message_center::MessageCenterBubble* message_center_bubble = 356 message_center::MessageCenterBubble* message_center_bubble =
357 new message_center::MessageCenterBubble(message_center(), 357 new message_center::MessageCenterBubble(message_center(),
358 message_center_tray_.get()); 358 message_center_tray_.get());
359 359
360 int max_height; 360 // In the horizontal case, message center starts from the top of the shelf.
361 if (IsHorizontalAlignment(shelf_alignment())) { 361 // In the vertical case, it starts from the bottom of WebNotificationTray.
362 int max_height = GetBoundsInScreen().bottom();
363 if (IsHorizontalAlignment(shelf_alignment()))
yoshiki 2017/02/02 03:25:23 nit: how about using a ternary conditional operato
Eliot Courtney 2017/02/02 03:40:07 Done.
362 max_height = shelf()->GetIdealBounds().y(); 364 max_height = shelf()->GetIdealBounds().y();
363 } else { 365 message_center_bubble->SetMaxHeight(max_height);
364 // Assume the status area and bubble bottoms are aligned when vertical. 366
365 gfx::Rect bounds_in_root =
366 status_area_window_->GetRootWindow()->ConvertRectFromScreen(
367 status_area_window_->GetBoundsInScreen());
368 max_height = bounds_in_root.bottom();
369 }
370 message_center_bubble->SetMaxHeight(
371 std::max(0, max_height - GetTrayConstant(TRAY_SPACING)));
372 if (show_settings) 367 if (show_settings)
373 message_center_bubble->SetSettingsVisible(); 368 message_center_bubble->SetSettingsVisible();
374 369
375 // For vertical shelf alignments, anchor to the WebNotificationTray, but for 370 // For vertical shelf alignments, anchor to the WebNotificationTray, but for
376 // horizontal (i.e. bottom) shelves, anchor to the system tray. 371 // horizontal (i.e. bottom) shelves, anchor to the system tray.
377 TrayBackgroundView* anchor_tray = this; 372 TrayBackgroundView* anchor_tray = this;
378 if (IsHorizontalAlignment(shelf_alignment())) { 373 if (IsHorizontalAlignment(shelf_alignment())) {
379 anchor_tray = WmShelf::ForWindow(status_area_window_) 374 anchor_tray = WmShelf::ForWindow(status_area_window_)
380 ->GetStatusAreaWidget() 375 ->GetStatusAreaWidget()
381 ->system_tray(); 376 ->system_tray();
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 658
664 message_center::MessageCenterBubble* 659 message_center::MessageCenterBubble*
665 WebNotificationTray::GetMessageCenterBubbleForTest() { 660 WebNotificationTray::GetMessageCenterBubbleForTest() {
666 if (!message_center_bubble()) 661 if (!message_center_bubble())
667 return nullptr; 662 return nullptr;
668 return static_cast<message_center::MessageCenterBubble*>( 663 return static_cast<message_center::MessageCenterBubble*>(
669 message_center_bubble()->bubble()); 664 message_center_bubble()->bubble());
670 } 665 }
671 666
672 } // namespace ash 667 } // 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