| OLD | NEW |
| 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/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/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shelf/wm_shelf_observer.h" |
| 12 #include "ash/common/shelf/wm_shelf_util.h" | 13 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/shell_window_ids.h" | 14 #include "ash/common/shell_window_ids.h" |
| 14 #include "ash/common/system/tray/system_tray.h" | 15 #include "ash/common/system/tray/system_tray.h" |
| 15 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
| 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 17 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
| 17 #include "ash/common/system/tray/tray_constants.h" | 18 #include "ash/common/system/tray/tray_constants.h" |
| 18 #include "ash/common/system/tray/tray_utils.h" | 19 #include "ash/common/system/tray/tray_utils.h" |
| 19 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" | 20 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" |
| 20 #include "ash/common/wm_lookup.h" | 21 #include "ash/common/wm_lookup.h" |
| 21 #include "ash/common/wm_root_window_controller.h" | 22 #include "ash/common/wm_root_window_controller.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 int unread_count_; | 199 int unread_count_; |
| 199 | 200 |
| 200 views::ImageView no_unread_icon_; | 201 views::ImageView no_unread_icon_; |
| 201 views::Label unread_label_; | 202 views::Label unread_label_; |
| 202 | 203 |
| 203 DISALLOW_COPY_AND_ASSIGN(WebNotificationButton); | 204 DISALLOW_COPY_AND_ASSIGN(WebNotificationButton); |
| 204 }; | 205 }; |
| 205 | 206 |
| 206 WebNotificationTray::WebNotificationTray(WmShelf* shelf, | 207 WebNotificationTray::WebNotificationTray(WmShelf* shelf, |
| 207 WmWindow* status_area_window, | 208 WmWindow* status_area_window, |
| 208 SystemTray* system_tray) | 209 SystemTray* system_tray, |
| 209 : TrayBackgroundView(shelf), | 210 WmShelfObserver* wm_shelf_observer) |
| 211 : TrayBackgroundView(shelf, wm_shelf_observer), |
| 210 status_area_window_(status_area_window), | 212 status_area_window_(status_area_window), |
| 211 system_tray_(system_tray), | 213 system_tray_(system_tray), |
| 212 button_(nullptr), | 214 button_(nullptr), |
| 213 show_message_center_on_unlock_(false), | 215 show_message_center_on_unlock_(false), |
| 214 should_update_tray_content_(false), | 216 should_update_tray_content_(false), |
| 215 should_block_shelf_auto_hide_(false) { | 217 should_block_shelf_auto_hide_(false) { |
| 216 DCHECK(shelf); | 218 DCHECK(shelf); |
| 217 DCHECK(status_area_window_); | 219 DCHECK(status_area_window_); |
| 218 DCHECK(system_tray_); | 220 DCHECK(system_tray_); |
| 219 button_ = new WebNotificationButton(this); | 221 button_ = new WebNotificationButton(this); |
| 220 button_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 222 button_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 221 ui::EF_RIGHT_MOUSE_BUTTON); | 223 ui::EF_RIGHT_MOUSE_BUTTON); |
| 222 tray_container()->AddChildView(button_); | 224 tray_container()->AddChildView(button_); |
| 223 button_->SetFocusBehavior(FocusBehavior::NEVER); | 225 button_->SetFocusBehavior(FocusBehavior::NEVER); |
| 224 SetContentsBackground(); | 226 SetContentsBackground(); |
| 225 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 226 message_center_tray_.reset(new message_center::MessageCenterTray( | 227 message_center_tray_.reset(new message_center::MessageCenterTray( |
| 227 this, message_center::MessageCenter::Get())); | 228 this, message_center::MessageCenter::Get())); |
| 228 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); | 229 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); |
| 229 popup_collection_.reset(new message_center::MessagePopupCollection( | 230 popup_collection_.reset(new message_center::MessagePopupCollection( |
| 230 message_center(), message_center_tray_.get(), | 231 message_center(), message_center_tray_.get(), |
| 231 popup_alignment_delegate_.get())); | 232 popup_alignment_delegate_.get())); |
| 232 const display::Display& display = | 233 const display::Display& display = |
| 233 status_area_window_->GetDisplayNearestWindow(); | 234 status_area_window_->GetDisplayNearestWindow(); |
| 234 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(), | 235 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(), |
| 235 display); | 236 display); |
| 236 OnMessageCenterTrayChanged(); | 237 OnMessageCenterTrayChanged(); |
| 238 SetSeparatorVisibility(true); |
| 237 } | 239 } |
| 238 | 240 |
| 239 WebNotificationTray::~WebNotificationTray() { | 241 WebNotificationTray::~WebNotificationTray() { |
| 240 // Release any child views that might have back pointers before ~View(). | 242 // Release any child views that might have back pointers before ~View(). |
| 241 message_center_bubble_.reset(); | 243 message_center_bubble_.reset(); |
| 242 popup_alignment_delegate_.reset(); | 244 popup_alignment_delegate_.reset(); |
| 243 popup_collection_.reset(); | 245 popup_collection_.reset(); |
| 244 } | 246 } |
| 245 | 247 |
| 246 // Public methods. | 248 // Public methods. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 void WebNotificationTray::UpdateAfterLoginStatusChange( | 344 void WebNotificationTray::UpdateAfterLoginStatusChange( |
| 343 LoginStatus login_status) { | 345 LoginStatus login_status) { |
| 344 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); | 346 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); |
| 345 OnMessageCenterTrayChanged(); | 347 OnMessageCenterTrayChanged(); |
| 346 } | 348 } |
| 347 | 349 |
| 348 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { | 350 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 349 if (alignment == shelf_alignment()) | 351 if (alignment == shelf_alignment()) |
| 350 return; | 352 return; |
| 351 TrayBackgroundView::SetShelfAlignment(alignment); | 353 TrayBackgroundView::SetShelfAlignment(alignment); |
| 352 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 353 // Destroy any existing bubble so that it will be rebuilt correctly. | 354 // Destroy any existing bubble so that it will be rebuilt correctly. |
| 354 message_center_tray_->HideMessageCenterBubble(); | 355 message_center_tray_->HideMessageCenterBubble(); |
| 355 message_center_tray_->HidePopupBubble(); | 356 message_center_tray_->HidePopupBubble(); |
| 356 } | 357 } |
| 357 | 358 |
| 358 void WebNotificationTray::AnchorUpdated() { | 359 void WebNotificationTray::AnchorUpdated() { |
| 359 if (message_center_bubble()) { | 360 if (message_center_bubble()) { |
| 360 message_center_bubble()->bubble_view()->UpdateBubble(); | 361 message_center_bubble()->bubble_view()->UpdateBubble(); |
| 361 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); | 362 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); |
| 362 } | 363 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 524 |
| 524 message_center::MessageCenterBubble* | 525 message_center::MessageCenterBubble* |
| 525 WebNotificationTray::GetMessageCenterBubbleForTest() { | 526 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 526 if (!message_center_bubble()) | 527 if (!message_center_bubble()) |
| 527 return NULL; | 528 return NULL; |
| 528 return static_cast<message_center::MessageCenterBubble*>( | 529 return static_cast<message_center::MessageCenterBubble*>( |
| 529 message_center_bubble()->bubble()); | 530 message_center_bubble()->bubble()); |
| 530 } | 531 } |
| 531 | 532 |
| 532 } // namespace ash | 533 } // namespace ash |
| OLD | NEW |