summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/system/web_notification/web_notification_tray.cc23
-rw-r--r--chrome/browser/notifications/notification_ui_manager.cc7
-rw-r--r--ui/message_center/message_bubble_base.cc7
-rw-r--r--ui/message_center/message_center.gyp2
-rw-r--r--ui/message_center/message_center_bubble.cc20
-rw-r--r--ui/message_center/message_center_switches.cc3
-rw-r--r--ui/message_center/message_center_switches.h7
-rw-r--r--ui/message_center/message_center_util.cc17
-rw-r--r--ui/message_center/message_center_util.h16
9 files changed, 67 insertions, 35 deletions
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index b3e8df4..a6d92e7 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -20,6 +20,7 @@
#include "ui/message_center/message_bubble_base.h"
#include "ui/message_center/message_center_bubble.h"
#include "ui/message_center/message_center_tray_delegate.h"
+#include "ui/message_center/message_center_util.h"
#include "ui/message_center/message_popup_bubble.h"
#include "ui/message_center/quiet_mode_bubble.h"
#include "ui/views/bubble/tray_bubble_view.h"
@@ -213,10 +214,13 @@ void WebNotificationTray::ShowQuietModeBubble() {
void WebNotificationTray::UpdateAfterLoginStatusChange(
user::LoginStatus login_status) {
- // The status icon should be always visible except for lock screen / login
- // screen, to allow quiet mode and settings.
- SetVisible((login_status != user::LOGGED_IN_NONE) &&
- (login_status != user::LOGGED_IN_LOCKED));
+ if (message_center::IsRichNotificationEnabled()) {
+ // The status icon should be always visible except for lock screen / login
+ // screen, to allow quiet mode and settings. This is valid only when rich
+ // notification is enabled, since old UI doesn't have settings.
+ SetVisible((login_status != user::LOGGED_IN_NONE) &&
+ (login_status != user::LOGGED_IN_LOCKED));
+ }
if (login_status == user::LOGGED_IN_LOCKED) {
show_message_center_on_unlock_ =
@@ -368,6 +372,17 @@ void WebNotificationTray::OnMessageCenterTrayChanged() {
button_->SetState(views::CustomButton::STATE_PRESSED);
else
button_->SetState(views::CustomButton::STATE_NORMAL);
+ // Change the visibility of the buttons here when rich notifications are not
+ // enabled. If rich notifications are enabled, the visibility is changed at
+ // UpdateAfterLoginStatusChange() since the visibility won't depend on the
+ // number of notifications.
+ if (!message_center::IsRichNotificationEnabled()) {
+ bool is_visible =
+ (status_area_widget()->login_status() != user::LOGGED_IN_NONE) &&
+ (status_area_widget()->login_status() != user::LOGGED_IN_LOCKED) &&
+ (message_center->NotificationCount() > 0);
+ SetVisible(is_visible);
+ }
Layout();
SchedulePaint();
}
diff --git a/chrome/browser/notifications/notification_ui_manager.cc b/chrome/browser/notifications/notification_ui_manager.cc
index c68b725..0ea24ae 100644
--- a/chrome/browser/notifications/notification_ui_manager.cc
+++ b/chrome/browser/notifications/notification_ui_manager.cc
@@ -4,13 +4,12 @@
#include "chrome/browser/notifications/notification_ui_manager.h"
-#include "base/command_line.h"
#include "chrome/browser/notifications/balloon_notification_ui_manager.h"
#if defined(ENABLE_MESSAGE_CENTER)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/message_center_notification_manager.h"
-#include "ui/message_center/message_center_switches.h"
+#include "ui/message_center/message_center_util.h"
#endif
// static
@@ -20,8 +19,7 @@ bool NotificationUIManager::DelegatesToMessageCenter() {
// be done by BalloonCollectionImplAsh through BalloonNotificationUIManager.
// TODO(mukai): remove this |&& !defined(USE_ASH)| when that's no problem.
#if defined(ENABLE_MESSAGE_CENTER) && !defined(USE_ASH)
- return CommandLine::ForCurrentProcess()->HasSwitch(
- message_center::switches::kEnableRichNotifications);
+ return message_center::IsRichNotificationEnabled();
#endif
return false;
}
@@ -40,4 +38,3 @@ NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) {
return balloon_manager;
}
#endif
-
diff --git a/ui/message_center/message_bubble_base.cc b/ui/message_center/message_bubble_base.cc
index ba52025..6fa1fb0 100644
--- a/ui/message_center/message_bubble_base.cc
+++ b/ui/message_center/message_bubble_base.cc
@@ -5,8 +5,7 @@
#include "ui/message_center/message_bubble_base.h"
#include "base/bind.h"
-#include "base/command_line.h"
-#include "ui/message_center/message_center_switches.h"
+#include "ui/message_center/message_center_util.h"
#include "ui/message_center/message_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
@@ -59,10 +58,8 @@ bool MessageBubbleBase::IsVisible() const {
void MessageBubbleBase::SetMaxHeight(int height) {
// Maximum height makes sense only for the new design.
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableNewMessageCenterBubble)) {
+ if (!message_center::IsRichNotificationEnabled())
return;
- }
if (height == 0)
height = kMessageBubbleBaseDefaultMaxHeight;
diff --git a/ui/message_center/message_center.gyp b/ui/message_center/message_center.gyp
index f778182..ba80c06 100644
--- a/ui/message_center/message_center.gyp
+++ b/ui/message_center/message_center.gyp
@@ -39,6 +39,8 @@
'message_center_tray_delegate.h',
'message_center_switches.cc',
'message_center_switches.h',
+ 'message_center_util.cc',
+ 'message_center_util.h',
'message_popup_bubble.cc',
'message_popup_bubble.h',
'message_simple_view.cc',
diff --git a/ui/message_center/message_center_bubble.cc b/ui/message_center/message_center_bubble.cc
index 72a4486..2e5d8d6 100644
--- a/ui/message_center/message_center_bubble.cc
+++ b/ui/message_center/message_center_bubble.cc
@@ -4,7 +4,6 @@
#include "ui/message_center/message_center_bubble.h"
-#include "base/command_line.h"
#include "grit/ui_strings.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/l10n/l10n_util.h"
@@ -17,7 +16,7 @@
#include "ui/gfx/size.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/text_constants.h"
-#include "ui/message_center/message_center_switches.h"
+#include "ui/message_center/message_center_util.h"
#include "ui/message_center/message_view.h"
#include "ui/message_center/notification_view.h"
#include "ui/views/background.h"
@@ -53,11 +52,6 @@ const SkColor kButtonTextHoverColor = SkColorSetRGB(0x32, 0x32, 0x32);
// TODO(mukai): unite those implementations.
const SkColor kFocusBorderColor = SkColorSetRGB(0x40, 0x80, 0xfa);
-bool UseNewDesign() {
- return !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableNewMessageCenterBubble);
-}
-
gfx::Insets GetItemShadowInsets() {
return gfx::Insets(kItemShadowBlur / 2 - kItemShadowOffset,
kItemShadowBlur / 2,
@@ -245,7 +239,7 @@ class FixedSizedScrollView : public views::ScrollView {
FixedSizedScrollView() {
set_focusable(true);
set_notify_enter_exit_on_child(true);
- if (UseNewDesign()) {
+ if (IsRichNotificationEnabled()) {
set_background(views::Background::CreateSolidBackground(
kMessageCenterBackgroundColor));
}
@@ -298,7 +292,7 @@ class FixedSizedScrollView : public views::ScrollView {
class ScrollContentView : public views::View {
public:
ScrollContentView() {
- if (UseNewDesign()) {
+ if (IsRichNotificationEnabled()) {
// Set the margin to 0 for the layout. BoxLayout assumes the same margin
// for top and bottom, but the bottom margin here should be smaller
// because of the shadow of message view. Use an empty border instead
@@ -378,7 +372,7 @@ class MessageCenterContentsView : public views::View {
NotificationList::Delegate* list_delegate)
: list_delegate_(list_delegate),
bubble_(bubble) {
- int between_child = UseNewDesign() ? 0 : 1;
+ int between_child = IsRichNotificationEnabled() ? 0 : 1;
SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, between_child));
@@ -393,7 +387,7 @@ class MessageCenterContentsView : public views::View {
scroller_->layer()->SetMasksToBounds(true);
}
- if (UseNewDesign())
+ if (IsRichNotificationEnabled())
button_view_ = new WebNotificationButtonView2(list_delegate);
else
button_view_ = new WebNotificationButtonView(list_delegate);
@@ -414,7 +408,7 @@ class MessageCenterContentsView : public views::View {
NotificationView::ViewForNotification(*iter, list_delegate_);
view->set_scroller(scroller_);
view->SetUpView();
- if (UseNewDesign())
+ if (IsRichNotificationEnabled())
view->set_border(new MessageViewShadowBorder());
scroll_content_->AddChildView(view);
if (++num_children >=
@@ -486,7 +480,7 @@ views::TrayBubbleView::InitParams MessageCenterBubble::GetInitParams(
views::TrayBubbleView::AnchorAlignment anchor_alignment) {
views::TrayBubbleView::InitParams init_params =
GetDefaultInitParams(anchor_alignment);
- if (UseNewDesign()) {
+ if (IsRichNotificationEnabled()) {
init_params.min_width += kMarginBetweenItems * 2;
init_params.max_width += kMarginBetweenItems * 2;
}
diff --git a/ui/message_center/message_center_switches.cc b/ui/message_center/message_center_switches.cc
index 6c5c7f4..9603f94 100644
--- a/ui/message_center/message_center_switches.cc
+++ b/ui/message_center/message_center_switches.cc
@@ -7,9 +7,6 @@
namespace message_center {
namespace switches {
-const char kDisableNewMessageCenterBubble[] =
- "disable-new-message-center-bubble";
-
const char kEnableRichNotifications[] = "enable-rich-notifications";
const char kEnableNewSimpleNotifications[] = "enable-new-simple-notifications";
diff --git a/ui/message_center/message_center_switches.h b/ui/message_center/message_center_switches.h
index 590a98f..64e79cb 100644
--- a/ui/message_center/message_center_switches.h
+++ b/ui/message_center/message_center_switches.h
@@ -10,8 +10,8 @@
namespace message_center {
namespace switches {
-// Disables the new design of message center, which shows each notification as a
-// card.
+// Enables rich templated notifications and NotificationCenter. In ChromeOS,
+// this flag also means the new design of message center bubble and popups.
// TODO(mukai): Remove this flag when we don't need to provide both of designs
// anymore (i.e. the new design becomes default and no one complains about it).
// Note that some classes should be removed and renamed as the result of
@@ -19,9 +19,6 @@ namespace switches {
// Affected class list:
// - WebNotificationButtonView2: remove '2' suffix and replace the old one.
// - WebNotificationButtonViewBase: merge into WebNotificationButtonView.
-MESSAGE_CENTER_EXPORT extern const char kDisableNewMessageCenterBubble[];
-
-// Enables rich templated notifications and NotificationCenter.
MESSAGE_CENTER_EXPORT extern const char kEnableRichNotifications[];
// Enables simple notifications with the new templates defined as part of rich
diff --git a/ui/message_center/message_center_util.cc b/ui/message_center/message_center_util.cc
new file mode 100644
index 0000000..90f7f47
--- /dev/null
+++ b/ui/message_center/message_center_util.cc
@@ -0,0 +1,17 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/message_center/message_center_util.h"
+
+#include "base/command_line.h"
+#include "ui/message_center/message_center_switches.h"
+
+namespace message_center {
+
+bool IsRichNotificationEnabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableRichNotifications);
+}
+
+} // namespace message_center
diff --git a/ui/message_center/message_center_util.h b/ui/message_center/message_center_util.h
new file mode 100644
index 0000000..512cb1a
--- /dev/null
+++ b/ui/message_center/message_center_util.h
@@ -0,0 +1,16 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_UTIL_H_
+#define UI_MESSAGE_CENTER_MESSAGE_CENTER_UTIL_H_
+
+#include "ui/message_center/message_center_export.h"
+
+namespace message_center {
+
+MESSAGE_CENTER_EXPORT bool IsRichNotificationEnabled();
+
+} // namespace message_center
+
+#endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_UTIL_H_