Chromium Code Reviews| 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" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 should_block_shelf_auto_hide_(false) { | 215 should_block_shelf_auto_hide_(false) { |
| 216 DCHECK(shelf); | 216 DCHECK(shelf); |
| 217 DCHECK(status_area_window_); | 217 DCHECK(status_area_window_); |
| 218 DCHECK(system_tray_); | 218 DCHECK(system_tray_); |
| 219 button_ = new WebNotificationButton(this); | 219 button_ = new WebNotificationButton(this); |
| 220 button_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | | 220 button_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | |
| 221 ui::EF_RIGHT_MOUSE_BUTTON); | 221 ui::EF_RIGHT_MOUSE_BUTTON); |
| 222 tray_container()->AddChildView(button_); | 222 tray_container()->AddChildView(button_); |
| 223 button_->SetFocusBehavior(FocusBehavior::NEVER); | 223 button_->SetFocusBehavior(FocusBehavior::NEVER); |
| 224 SetContentsBackground(); | 224 SetContentsBackground(); |
| 225 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 226 message_center_tray_.reset(new message_center::MessageCenterTray( | 225 message_center_tray_.reset(new message_center::MessageCenterTray( |
| 227 this, message_center::MessageCenter::Get())); | 226 this, message_center::MessageCenter::Get())); |
| 228 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); | 227 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); |
| 229 popup_collection_.reset(new message_center::MessagePopupCollection( | 228 popup_collection_.reset(new message_center::MessagePopupCollection( |
| 230 message_center(), message_center_tray_.get(), | 229 message_center(), message_center_tray_.get(), |
| 231 popup_alignment_delegate_.get())); | 230 popup_alignment_delegate_.get())); |
| 232 const display::Display& display = | 231 const display::Display& display = |
| 233 status_area_window_->GetDisplayNearestWindow(); | 232 status_area_window_->GetDisplayNearestWindow(); |
| 234 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(), | 233 popup_alignment_delegate_->StartObserving(display::Screen::GetScreen(), |
| 235 display); | 234 display); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 void WebNotificationTray::UpdateAfterLoginStatusChange( | 341 void WebNotificationTray::UpdateAfterLoginStatusChange( |
| 343 LoginStatus login_status) { | 342 LoginStatus login_status) { |
| 344 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); | 343 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); |
| 345 OnMessageCenterTrayChanged(); | 344 OnMessageCenterTrayChanged(); |
| 346 } | 345 } |
| 347 | 346 |
| 348 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { | 347 void WebNotificationTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 349 if (alignment == shelf_alignment()) | 348 if (alignment == shelf_alignment()) |
| 350 return; | 349 return; |
| 351 TrayBackgroundView::SetShelfAlignment(alignment); | 350 TrayBackgroundView::SetShelfAlignment(alignment); |
| 352 tray_container()->SetBorder(views::Border::NullBorder()); | |
| 353 // Destroy any existing bubble so that it will be rebuilt correctly. | 351 // Destroy any existing bubble so that it will be rebuilt correctly. |
| 354 message_center_tray_->HideMessageCenterBubble(); | 352 message_center_tray_->HideMessageCenterBubble(); |
| 355 message_center_tray_->HidePopupBubble(); | 353 message_center_tray_->HidePopupBubble(); |
| 356 } | 354 } |
| 357 | 355 |
| 358 void WebNotificationTray::AnchorUpdated() { | 356 void WebNotificationTray::AnchorUpdated() { |
| 359 if (message_center_bubble()) { | 357 if (message_center_bubble()) { |
| 360 message_center_bubble()->bubble_view()->UpdateBubble(); | 358 message_center_bubble()->bubble_view()->UpdateBubble(); |
| 361 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); | 359 UpdateBubbleViewArrow(message_center_bubble()->bubble_view()); |
| 362 } | 360 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 return message_center_tray_->message_center(); | 512 return message_center_tray_->message_center(); |
| 515 } | 513 } |
| 516 | 514 |
| 517 bool WebNotificationTray::IsLoggedIn() const { | 515 bool WebNotificationTray::IsLoggedIn() const { |
| 518 WmShell* shell = WmShell::Get(); | 516 WmShell* shell = WmShell::Get(); |
| 519 return shell->system_tray_delegate()->GetUserLoginStatus() != | 517 return shell->system_tray_delegate()->GetUserLoginStatus() != |
| 520 LoginStatus::NOT_LOGGED_IN && | 518 LoginStatus::NOT_LOGGED_IN && |
| 521 !shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 519 !shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 522 } | 520 } |
| 523 | 521 |
| 522 void WebNotificationTray::OnPaint(gfx::Canvas* canvas) { | |
| 523 // Paint a 1px separator to separate the notification button and status tray. | |
|
varkha
2016/07/14 21:34:48
nit: I think this comment is not necessary.
yiyix
2016/07/26 20:27:32
Done.
| |
| 524 DrawSeparator(canvas); | |
| 525 } | |
| 526 | |
| 524 // Methods for testing | 527 // Methods for testing |
| 525 | 528 |
| 526 bool WebNotificationTray::IsPopupVisible() const { | 529 bool WebNotificationTray::IsPopupVisible() const { |
| 527 return message_center_tray_->popups_visible(); | 530 return message_center_tray_->popups_visible(); |
| 528 } | 531 } |
| 529 | 532 |
| 530 message_center::MessageCenterBubble* | 533 message_center::MessageCenterBubble* |
| 531 WebNotificationTray::GetMessageCenterBubbleForTest() { | 534 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 532 if (!message_center_bubble()) | 535 if (!message_center_bubble()) |
| 533 return NULL; | 536 return NULL; |
| 534 return static_cast<message_center::MessageCenterBubble*>( | 537 return static_cast<message_center::MessageCenterBubble*>( |
| 535 message_center_bubble()->bubble()); | 538 message_center_bubble()->bubble()); |
| 536 } | 539 } |
| 537 | 540 |
| 538 } // namespace ash | 541 } // namespace ash |
| OLD | NEW |