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

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

Issue 1877543002: Revise the shelf alignment locking mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and cleanup tests. Created 4 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
« no previous file with comments | « ash/system/user/tray_user.cc ('k') | ash/test/shelf_test_api.h » ('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/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"
11 #include "ash/shelf/shelf_util.h"
11 #include "ash/shelf/shelf_widget.h" 12 #include "ash/shelf/shelf_widget.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
13 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
14 #include "ash/system/status_area_widget.h" 15 #include "ash/system/status_area_widget.h"
15 #include "ash/system/tray/system_tray.h" 16 #include "ash/system/tray/system_tray.h"
16 #include "ash/system/tray/tray_background_view.h" 17 #include "ash/system/tray/tray_background_view.h"
17 #include "ash/system/tray/tray_bubble_wrapper.h" 18 #include "ash/system/tray/tray_bubble_wrapper.h"
18 #include "ash/system/tray/tray_constants.h" 19 #include "ash/system/tray/tray_constants.h"
19 #include "ash/system/tray/tray_utils.h" 20 #include "ash/system/tray/tray_utils.h"
20 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" 21 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (!ShouldShowMessageCenter()) 212 if (!ShouldShowMessageCenter())
212 return false; 213 return false;
213 214
214 should_block_shelf_auto_hide_ = true; 215 should_block_shelf_auto_hide_ = true;
215 message_center::MessageCenterBubble* message_center_bubble = 216 message_center::MessageCenterBubble* message_center_bubble =
216 new message_center::MessageCenterBubble( 217 new message_center::MessageCenterBubble(
217 message_center(), 218 message_center(),
218 message_center_tray_.get(), 219 message_center_tray_.get(),
219 true); 220 true);
220 221
221 int max_height = 0; 222 // Assume the status area and bubble bottoms are aligned when vertical.
222 aura::Window* status_area_window = status_area_widget()->GetNativeView(); 223 aura::Window* status_area_window = status_area_widget()->GetNativeView();
223 switch (GetShelfLayoutManager()->GetAlignment()) { 224 const int max_height =
224 case SHELF_ALIGNMENT_BOTTOM: { 225 IsHorizontalAlignment(GetShelfLayoutManager()->GetAlignment())
225 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); 226 ? GetShelfLayoutManager()->GetIdealBounds().y()
226 max_height = shelf_bounds.y(); 227 : status_area_window->GetBoundsInRootWindow().bottom();
227 break;
228 }
229 case SHELF_ALIGNMENT_LEFT:
230 case SHELF_ALIGNMENT_RIGHT: {
231 // Assume that the bottom line of the status area widget and the bubble
232 // are aligned.
233 max_height = status_area_window->GetBoundsInRootWindow().bottom();
234 break;
235 }
236 }
237 228
238 message_center_bubble->SetMaxHeight(std::max(0, 229 message_center_bubble->SetMaxHeight(std::max(0, max_height - kTraySpacing));
239 max_height - kTraySpacing));
240 if (show_settings) 230 if (show_settings)
241 message_center_bubble->SetSettingsVisible(); 231 message_center_bubble->SetSettingsVisible();
242 message_center_bubble_.reset( 232 message_center_bubble_.reset(
243 new WebNotificationBubbleWrapper(this, message_center_bubble)); 233 new WebNotificationBubbleWrapper(this, message_center_bubble));
244 234
245 status_area_widget()->SetHideSystemNotifications(true); 235 status_area_widget()->SetHideSystemNotifications(true);
246 GetShelfLayoutManager()->UpdateAutoHideState(); 236 GetShelfLayoutManager()->UpdateAutoHideState();
247 button_->SetBubbleVisible(true); 237 button_->SetBubbleVisible(true);
248 SetDrawBackgroundAsActive(true); 238 SetDrawBackgroundAsActive(true);
249 return true; 239 return true;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 478
489 message_center::MessageCenterBubble* 479 message_center::MessageCenterBubble*
490 WebNotificationTray::GetMessageCenterBubbleForTest() { 480 WebNotificationTray::GetMessageCenterBubbleForTest() {
491 if (!message_center_bubble()) 481 if (!message_center_bubble())
492 return NULL; 482 return NULL;
493 return static_cast<message_center::MessageCenterBubble*>( 483 return static_cast<message_center::MessageCenterBubble*>(
494 message_center_bubble()->bubble()); 484 message_center_bubble()->bubble());
495 } 485 }
496 486
497 } // namespace ash 487 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/tray_user.cc ('k') | ash/test/shelf_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698