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

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

Issue 2072023003: mash: Break ash system tray dependencies on ash::ShelfWidget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/shelf/wm_shelf_util.h" 12 #include "ash/common/shelf/wm_shelf_util.h"
11 #include "ash/common/shell_window_ids.h" 13 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/system/tray/tray_constants.h" 14 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/system/tray/tray_utils.h" 15 #include "ash/common/system/tray/tray_utils.h"
14 #include "ash/common/wm_lookup.h" 16 #include "ash/common/wm_lookup.h"
15 #include "ash/common/wm_root_window_controller.h" 17 #include "ash/common/wm_root_window_controller.h"
16 #include "ash/common/wm_window.h" 18 #include "ash/common/wm_window.h"
17 #include "ash/shelf/shelf_layout_manager.h"
18 #include "ash/shell.h" 19 #include "ash/shell.h"
19 #include "ash/system/status_area_widget.h" 20 #include "ash/system/status_area_widget.h"
20 #include "ash/system/tray/system_tray.h" 21 #include "ash/system/tray/system_tray.h"
21 #include "ash/system/tray/tray_background_view.h" 22 #include "ash/system/tray/tray_background_view.h"
22 #include "ash/system/tray/tray_bubble_wrapper.h" 23 #include "ash/system/tray/tray_bubble_wrapper.h"
23 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" 24 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
24 #include "base/auto_reset.h" 25 #include "base/auto_reset.h"
25 #include "base/i18n/number_formatting.h" 26 #include "base/i18n/number_formatting.h"
26 #include "base/i18n/rtl.h" 27 #include "base/i18n/rtl.h"
27 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (!ShouldShowMessageCenter()) 251 if (!ShouldShowMessageCenter())
251 return false; 252 return false;
252 253
253 should_block_shelf_auto_hide_ = true; 254 should_block_shelf_auto_hide_ = true;
254 message_center::MessageCenterBubble* message_center_bubble = 255 message_center::MessageCenterBubble* message_center_bubble =
255 new message_center::MessageCenterBubble( 256 new message_center::MessageCenterBubble(
256 message_center(), 257 message_center(),
257 message_center_tray_.get(), 258 message_center_tray_.get(),
258 true); 259 true);
259 260
261 WmShelf* shelf = GetShelf();
260 int max_height; 262 int max_height;
261 if (IsHorizontalAlignment(GetShelfLayoutManager()->GetAlignment())) { 263 if (IsHorizontalAlignment(shelf->GetAlignment())) {
262 max_height = GetShelfLayoutManager()->GetIdealBounds().y(); 264 max_height = shelf->GetIdealBounds().y();
263 } else { 265 } else {
264 // Assume the status area and bubble bottoms are aligned when vertical. 266 // Assume the status area and bubble bottoms are aligned when vertical.
265 WmWindow* status_area_window = 267 WmWindow* status_area_window =
266 WmLookup::Get()->GetWindowForWidget(status_area_widget()); 268 WmLookup::Get()->GetWindowForWidget(status_area_widget());
267 gfx::Rect bounds_in_root = 269 gfx::Rect bounds_in_root =
268 status_area_window->GetRootWindow()->ConvertRectFromScreen( 270 status_area_window->GetRootWindow()->ConvertRectFromScreen(
269 status_area_window->GetBoundsInScreen()); 271 status_area_window->GetBoundsInScreen());
270 max_height = bounds_in_root.bottom(); 272 max_height = bounds_in_root.bottom();
271 } 273 }
272 message_center_bubble->SetMaxHeight( 274 message_center_bubble->SetMaxHeight(
273 std::max(0, max_height - GetTrayConstant(TRAY_SPACING))); 275 std::max(0, max_height - GetTrayConstant(TRAY_SPACING)));
274 if (show_settings) 276 if (show_settings)
275 message_center_bubble->SetSettingsVisible(); 277 message_center_bubble->SetSettingsVisible();
276 message_center_bubble_.reset( 278 message_center_bubble_.reset(
277 new WebNotificationBubbleWrapper(this, message_center_bubble)); 279 new WebNotificationBubbleWrapper(this, message_center_bubble));
278 280
279 status_area_widget()->SetHideSystemNotifications(true); 281 status_area_widget()->SetHideSystemNotifications(true);
280 GetShelfLayoutManager()->UpdateAutoHideState(); 282 shelf->UpdateAutoHideState();
281 button_->SetBubbleVisible(true); 283 button_->SetBubbleVisible(true);
282 SetDrawBackgroundAsActive(true); 284 SetDrawBackgroundAsActive(true);
283 return true; 285 return true;
284 } 286 }
285 287
286 bool WebNotificationTray::ShowMessageCenter() { 288 bool WebNotificationTray::ShowMessageCenter() {
287 return ShowMessageCenterInternal(false /* show_settings */); 289 return ShowMessageCenterInternal(false /* show_settings */);
288 } 290 }
289 291
290 void WebNotificationTray::HideMessageCenter() { 292 void WebNotificationTray::HideMessageCenter() {
291 if (!message_center_bubble()) 293 if (!message_center_bubble())
292 return; 294 return;
293 SetDrawBackgroundAsActive(false); 295 SetDrawBackgroundAsActive(false);
294 message_center_bubble_.reset(); 296 message_center_bubble_.reset();
295 should_block_shelf_auto_hide_ = false; 297 should_block_shelf_auto_hide_ = false;
296 show_message_center_on_unlock_ = false; 298 show_message_center_on_unlock_ = false;
297 status_area_widget()->SetHideSystemNotifications(false); 299 status_area_widget()->SetHideSystemNotifications(false);
298 GetShelfLayoutManager()->UpdateAutoHideState(); 300 GetShelf()->UpdateAutoHideState();
299 button_->SetBubbleVisible(false); 301 button_->SetBubbleVisible(false);
300 } 302 }
301 303
302 void WebNotificationTray::SetSystemTrayHeight(int height) { 304 void WebNotificationTray::SetSystemTrayHeight(int height) {
303 popup_alignment_delegate_->SetSystemTrayHeight(height); 305 popup_alignment_delegate_->SetSystemTrayHeight(height);
304 } 306 }
305 307
306 int WebNotificationTray::system_tray_height_for_test() const { 308 int WebNotificationTray::system_tray_height_for_test() const {
307 return popup_alignment_delegate_->system_tray_height_for_test(); 309 return popup_alignment_delegate_->system_tray_height_for_test();
308 } 310 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 526
525 message_center::MessageCenterBubble* 527 message_center::MessageCenterBubble*
526 WebNotificationTray::GetMessageCenterBubbleForTest() { 528 WebNotificationTray::GetMessageCenterBubbleForTest() {
527 if (!message_center_bubble()) 529 if (!message_center_bubble())
528 return NULL; 530 return NULL;
529 return static_cast<message_center::MessageCenterBubble*>( 531 return static_cast<message_center::MessageCenterBubble*>(
530 message_center_bubble()->bubble()); 532 message_center_bubble()->bubble());
531 } 533 }
532 534
533 } // namespace ash 535 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_details_view_unittest.cc ('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