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

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

Issue 2884683003: mash: Remove WmWindow usage from ash/system/web_notification (Closed)
Patch Set: curlies Created 3 years, 7 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/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/resources/vector_icons/vector_icons.h" 8 #include "ash/resources/vector_icons/vector_icons.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/session/session_controller.h" 10 #include "ash/session/session_controller.h"
11 #include "ash/shelf/shelf_constants.h" 11 #include "ash/shelf/shelf_constants.h"
12 #include "ash/shelf/wm_shelf.h" 12 #include "ash/shelf/wm_shelf.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/strings/grit/ash_strings.h" 14 #include "ash/strings/grit/ash_strings.h"
15 #include "ash/system/status_area_widget.h" 15 #include "ash/system/status_area_widget.h"
16 #include "ash/system/tray/system_tray.h" 16 #include "ash/system/tray/system_tray.h"
17 #include "ash/system/tray/system_tray_delegate.h" 17 #include "ash/system/tray/system_tray_delegate.h"
18 #include "ash/system/tray/tray_bubble_wrapper.h" 18 #include "ash/system/tray/tray_bubble_wrapper.h"
19 #include "ash/system/tray/tray_constants.h" 19 #include "ash/system/tray/tray_constants.h"
20 #include "ash/system/tray/tray_container.h" 20 #include "ash/system/tray/tray_container.h"
21 #include "ash/system/tray/tray_utils.h" 21 #include "ash/system/tray/tray_utils.h"
22 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" 22 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
23 #include "ash/wm_window.h"
24 #include "base/auto_reset.h" 23 #include "base/auto_reset.h"
25 #include "base/i18n/number_formatting.h" 24 #include "base/i18n/number_formatting.h"
26 #include "base/i18n/rtl.h" 25 #include "base/i18n/rtl.h"
27 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
28 #include "base/threading/thread_task_runner_handle.h" 27 #include "base/threading/thread_task_runner_handle.h"
29 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/display/display.h" 29 #include "ui/display/display.h"
31 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
32 #include "ui/gfx/paint_vector_icon.h" 31 #include "ui/gfx/paint_vector_icon.h"
33 #include "ui/message_center/message_center_style.h" 32 #include "ui/message_center/message_center_style.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 SchedulePaint(); 259 SchedulePaint();
261 } 260 }
262 261
263 private: 262 private:
264 views::Label* view_; 263 views::Label* view_;
265 264
266 DISALLOW_COPY_AND_ASSIGN(WebNotificationLabel); 265 DISALLOW_COPY_AND_ASSIGN(WebNotificationLabel);
267 }; 266 };
268 267
269 WebNotificationTray::WebNotificationTray(WmShelf* shelf, 268 WebNotificationTray::WebNotificationTray(WmShelf* shelf,
270 WmWindow* status_area_window, 269 aura::Window* status_area_window,
271 SystemTray* system_tray) 270 SystemTray* system_tray)
272 : TrayBackgroundView(shelf), 271 : TrayBackgroundView(shelf),
273 status_area_window_(status_area_window), 272 status_area_window_(status_area_window),
274 system_tray_(system_tray), 273 system_tray_(system_tray),
275 show_message_center_on_unlock_(false), 274 show_message_center_on_unlock_(false),
276 should_update_tray_content_(false) { 275 should_update_tray_content_(false) {
277 DCHECK(shelf); 276 DCHECK(shelf);
278 DCHECK(status_area_window_); 277 DCHECK(status_area_window_);
279 DCHECK(system_tray_); 278 DCHECK(system_tray_);
280 279
281 SetInkDropMode(InkDropMode::ON); 280 SetInkDropMode(InkDropMode::ON);
282 gfx::ImageSkia bell_image = 281 gfx::ImageSkia bell_image =
283 CreateVectorIcon(kShelfNotificationsIcon, kShelfIconColor); 282 CreateVectorIcon(kShelfNotificationsIcon, kShelfIconColor);
284 bell_icon_.reset( 283 bell_icon_.reset(
285 new WebNotificationImage(bell_image, animation_container_.get(), this)); 284 new WebNotificationImage(bell_image, animation_container_.get(), this));
286 tray_container()->AddChildView(bell_icon_.get()); 285 tray_container()->AddChildView(bell_icon_.get());
287 286
288 counter_.reset(new WebNotificationLabel(animation_container_.get(), this)); 287 counter_.reset(new WebNotificationLabel(animation_container_.get(), this));
289 tray_container()->AddChildView(counter_.get()); 288 tray_container()->AddChildView(counter_.get());
290 289
291 message_center_tray_.reset(new message_center::MessageCenterTray( 290 message_center_tray_.reset(new message_center::MessageCenterTray(
292 this, message_center::MessageCenter::Get())); 291 this, message_center::MessageCenter::Get()));
293 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); 292 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf));
294 popup_collection_.reset(new message_center::MessagePopupCollection( 293 popup_collection_.reset(new message_center::MessagePopupCollection(
295 message_center(), message_center_tray_.get(), 294 message_center(), message_center_tray_.get(),
296 popup_alignment_delegate_.get())); 295 popup_alignment_delegate_.get()));
297 const display::Display& display = 296 display::Screen* screen = display::Screen::GetScreen();
298 status_area_window_->GetDisplayNearestWindow(); 297 popup_alignment_delegate_->StartObserving(
299 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(), 298 screen, screen->GetDisplayNearestWindow(status_area_window_));
300 display);
301 OnMessageCenterTrayChanged(); 299 OnMessageCenterTrayChanged();
302 300
303 tray_container()->SetMargin(kTrayMainAxisInset, kTrayCrossAxisInset); 301 tray_container()->SetMargin(kTrayMainAxisInset, kTrayCrossAxisInset);
304 } 302 }
305 303
306 WebNotificationTray::~WebNotificationTray() { 304 WebNotificationTray::~WebNotificationTray() {
307 // Release any child views that might have back pointers before ~View(). 305 // Release any child views that might have back pointers before ~View().
308 message_center_bubble_.reset(); 306 message_center_bubble_.reset();
309 popup_alignment_delegate_.reset(); 307 popup_alignment_delegate_.reset();
310 popup_collection_.reset(); 308 popup_collection_.reset();
(...skipping 20 matching lines...) Expand all
331 ? shelf()->GetIdealBounds().y() 329 ? shelf()->GetIdealBounds().y()
332 : GetBoundsInScreen().bottom(); 330 : GetBoundsInScreen().bottom();
333 message_center_bubble->SetMaxHeight(max_height); 331 message_center_bubble->SetMaxHeight(max_height);
334 332
335 if (show_settings) 333 if (show_settings)
336 message_center_bubble->SetSettingsVisible(); 334 message_center_bubble->SetSettingsVisible();
337 335
338 // For vertical shelf alignments, anchor to the WebNotificationTray, but for 336 // For vertical shelf alignments, anchor to the WebNotificationTray, but for
339 // horizontal (i.e. bottom) shelves, anchor to the system tray. 337 // horizontal (i.e. bottom) shelves, anchor to the system tray.
340 TrayBackgroundView* anchor_tray = this; 338 TrayBackgroundView* anchor_tray = this;
341 if (shelf()->IsHorizontalAlignment()) { 339 if (shelf()->IsHorizontalAlignment())
342 anchor_tray = WmShelf::ForWindow(status_area_window_) 340 anchor_tray = system_tray_;
343 ->GetStatusAreaWidget()
344 ->system_tray();
345 }
346 341
347 message_center_bubble_.reset(new WebNotificationBubbleWrapper( 342 message_center_bubble_.reset(new WebNotificationBubbleWrapper(
348 this, anchor_tray, message_center_bubble)); 343 this, anchor_tray, message_center_bubble));
349 344
350 shelf()->UpdateAutoHideState(); 345 shelf()->UpdateAutoHideState();
351 SetIsActive(true); 346 SetIsActive(true);
352 return true; 347 return true;
353 } 348 }
354 349
355 bool WebNotificationTray::ShowMessageCenter() { 350 bool WebNotificationTray::ShowMessageCenter() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 451
457 base::string16 WebNotificationTray::GetAccessibleNameForBubble() { 452 base::string16 WebNotificationTray::GetAccessibleNameForBubble() {
458 return GetAccessibleNameForTray(); 453 return GetAccessibleNameForTray();
459 } 454 }
460 455
461 void WebNotificationTray::OnBeforeBubbleWidgetInit( 456 void WebNotificationTray::OnBeforeBubbleWidgetInit(
462 views::Widget* anchor_widget, 457 views::Widget* anchor_widget,
463 views::Widget* bubble_widget, 458 views::Widget* bubble_widget,
464 views::Widget::InitParams* params) const { 459 views::Widget::InitParams* params) const {
465 // Place the bubble in the same root window as |anchor_widget|. 460 // Place the bubble in the same root window as |anchor_widget|.
466 WmWindow::Get(anchor_widget->GetNativeWindow()) 461 RootWindowController::ForWindow(anchor_widget->GetNativeWindow())
467 ->GetRootWindowController()
468 ->ConfigureWidgetInitParamsForContainer( 462 ->ConfigureWidgetInitParamsForContainer(
469 bubble_widget, kShellWindowId_SettingBubbleContainer, params); 463 bubble_widget, kShellWindowId_SettingBubbleContainer, params);
470 } 464 }
471 465
472 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { 466 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) {
473 HideBubbleWithView(bubble_view); 467 HideBubbleWithView(bubble_view);
474 } 468 }
475 469
476 bool WebNotificationTray::ShowNotifierSettings() { 470 bool WebNotificationTray::ShowNotifierSettings() {
477 if (message_center_bubble()) { 471 if (message_center_bubble()) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 602
609 message_center::MessageCenterBubble* 603 message_center::MessageCenterBubble*
610 WebNotificationTray::GetMessageCenterBubbleForTest() { 604 WebNotificationTray::GetMessageCenterBubbleForTest() {
611 if (!message_center_bubble()) 605 if (!message_center_bubble())
612 return nullptr; 606 return nullptr;
613 return static_cast<message_center::MessageCenterBubble*>( 607 return static_cast<message_center::MessageCenterBubble*>(
614 message_center_bubble()->bubble()); 608 message_center_bubble()->bubble());
615 } 609 }
616 610
617 } // namespace ash 611 } // 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