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

Unified Diff: ash/system/tray/system_tray.cc

Issue 11028134: Re-factor Ash Message Center code part 2/4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray.cc
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 92da9398bf1f21d802ec70b7c5c047d5b6137eb8..56b7e9c52fe5ddaf63c4b9febf8389b1538b3399 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -54,7 +54,6 @@ namespace ash {
// SystemTray
using internal::SystemTrayBubble;
-using internal::TrayBubbleView;
SystemTray::SystemTray(internal::StatusAreaWidget* status_area_widget)
: internal::TrayBackgroundView(status_area_widget),
@@ -270,18 +269,6 @@ void SystemTray::DestroyNotificationBubble() {
status_area_widget()->SetHideWebNotifications(false);
}
-void SystemTray::RemoveBubble(SystemTrayBubble* bubble) {
- if (bubble == bubble_.get()) {
- DestroyBubble();
- UpdateNotificationBubble(); // State changed, re-create notifications.
- Shell::GetInstance()->shelf()->UpdateAutoHideState();
- } else if (bubble == notification_bubble_) {
- DestroyNotificationBubble();
- } else {
- NOTREACHED();
- }
-}
-
int SystemTray::GetTrayXOffset(SystemTrayItem* item) const {
// Don't attempt to align the arrow if the shelf is on the left or right.
if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM)
@@ -331,7 +318,8 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
ash::Shell::GetInstance()->tray_delegate();
views::View* anchor = tray_container();
TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY,
- shelf_alignment());
+ GetAnchorAlignment(),
+ kTrayPopupWidth);
init_params.can_activate = can_activate;
if (detailed) {
// This is the case where a volume control or brightness control bubble
@@ -344,7 +332,7 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
init_params.arrow_color = kHeaderBackgroundColorDark;
}
init_params.arrow_offset = arrow_offset;
- bubble_->InitView(anchor, init_params, delegate->GetUserLoginStatus());
+ bubble_->InitView(anchor, delegate->GetUserLoginStatus(), &init_params);
}
// Save height of default view for creating detailed views directly.
if (!detailed)
@@ -399,13 +387,15 @@ void SystemTray::UpdateNotificationBubble() {
anchor = tray_container();
anchor_type = TrayBubbleView::ANCHOR_TYPE_TRAY;
}
- TrayBubbleView::InitParams init_params(anchor_type, shelf_alignment());
+ TrayBubbleView::InitParams init_params(anchor_type,
+ GetAnchorAlignment(),
+ kTrayPopupWidth);
init_params.top_color = kBackgroundColor;
init_params.arrow_color = kBackgroundColor;
init_params.arrow_offset = GetTrayXOffset(notification_items_[0]);
user::LoginStatus login_status =
Shell::GetInstance()->tray_delegate()->GetUserLoginStatus();
- notification_bubble_->InitView(anchor, init_params, login_status);
+ notification_bubble_->InitView(anchor, login_status, &init_params);
if (notification_bubble_->bubble_view()->child_count() == 0) {
// It is possible that none of the items generated actual notifications.
DestroyNotificationBubble();
@@ -450,6 +440,26 @@ string16 SystemTray::GetAccessibleName() {
return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME);
}
+void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {
+ if (bubble_.get() && bubble_view == bubble_->bubble_view()) {
+ DestroyBubble();
+ UpdateNotificationBubble(); // State changed, re-create notifications.
+ Shell::GetInstance()->shelf()->UpdateAutoHideState();
+ } else if (notification_bubble_.get() &&
+ bubble_view == notification_bubble_->bubble_view()) {
+ DestroyNotificationBubble();
+ }
+}
+
+bool SystemTray::ClickedOutsideBubble() {
+ if (!bubble_.get() ||
+ bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION) {
+ return false;
+ }
+ HideBubbleWithView(bubble_->bubble_view());
+ return true;
+}
+
bool SystemTray::PerformAction(const ui::Event& event) {
// If we're already showing the default view, hide it; otherwise, show it
// (and hide any popup that's currently shown).
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698