summaryrefslogtreecommitdiff
path: root/chromium/ui/message_center/views
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2013-12-11 21:33:03 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-12-13 12:34:07 +0100
commitf2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch)
tree0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/ui/message_center/views
parent5362912cdb5eea702b68ebe23702468d17c3017a (diff)
downloadqtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/ui/message_center/views')
-rw-r--r--chromium/ui/message_center/views/bounded_label.cc18
-rw-r--r--chromium/ui/message_center/views/bounded_label.h4
-rw-r--r--chromium/ui/message_center/views/bounded_label_unittest.cc17
-rw-r--r--chromium/ui/message_center/views/message_center_view.cc38
-rw-r--r--chromium/ui/message_center/views/message_center_view.h18
-rw-r--r--chromium/ui/message_center/views/message_center_view_unittest.cc2
-rw-r--r--chromium/ui/message_center/views/message_popup_collection.cc34
-rw-r--r--chromium/ui/message_center/views/message_popup_collection_unittest.cc29
-rw-r--r--chromium/ui/message_center/views/message_view.cc32
-rw-r--r--chromium/ui/message_center/views/notification_view.cc46
-rw-r--r--chromium/ui/message_center/views/notification_view.h1
-rw-r--r--chromium/ui/message_center/views/notifier_settings_view.cc5
-rw-r--r--chromium/ui/message_center/views/toast_contents_view.cc36
-rw-r--r--chromium/ui/message_center/views/toast_contents_view.h22
14 files changed, 190 insertions, 112 deletions
diff --git a/chromium/ui/message_center/views/bounded_label.cc b/chromium/ui/message_center/views/bounded_label.cc
index 6752795390e..9c6f4df5840 100644
--- a/chromium/ui/message_center/views/bounded_label.cc
+++ b/chromium/ui/message_center/views/bounded_label.cc
@@ -8,8 +8,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "ui/base/text/text_elider.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/text_elider.h"
#include "ui/views/controls/label.h"
namespace {
@@ -143,18 +143,18 @@ std::vector<string16> InnerBoundedLabel::GetWrappedText(int width, int lines) {
// Wrap, using INT_MAX for -1 widths that indicate no wrapping.
std::vector<string16> wrapped;
- ui::ElideRectangleText(text(), font(),
- (width < 0) ? std::numeric_limits<int>::max() : width,
- height, ui::WRAP_LONG_WORDS, &wrapped);
+ gfx::ElideRectangleText(text(), font_list(),
+ (width < 0) ? std::numeric_limits<int>::max() : width,
+ height, gfx::WRAP_LONG_WORDS, &wrapped);
// Elide if necessary.
if (lines > 0 && wrapped.size() > static_cast<unsigned int>(lines)) {
// Add an ellipsis to the last line. If this ellipsis makes the last line
- // too wide, that line will be further elided by the ui::ElideText below,
+ // too wide, that line will be further elided by the gfx::ElideText below,
// so for example "ABC" could become "ABC..." and then "AB...".
- string16 last = wrapped[lines - 1] + UTF8ToUTF16(ui::kEllipsis);
+ string16 last = wrapped[lines - 1] + UTF8ToUTF16(gfx::kEllipsis);
if (width > 0 && font().GetStringWidth(last) > width)
- last = ui::ElideText(last, font(), width, ui::ELIDE_AT_END);
+ last = gfx::ElideText(last, font(), width, gfx::ELIDE_AT_END);
wrapped.resize(lines - 1);
wrapped.push_back(last);
}
@@ -259,10 +259,10 @@ void InnerBoundedLabel::SetCachedSize(std::pair<int, int> width_and_lines,
// BoundedLabel ///////////////////////////////////////////////////////////
-BoundedLabel::BoundedLabel(const string16& text, gfx::Font font)
+BoundedLabel::BoundedLabel(const string16& text, const gfx::FontList& font_list)
: line_limit_(-1) {
label_.reset(new InnerBoundedLabel(*this));
- label_->SetFont(font);
+ label_->SetFontList(font_list);
label_->SetText(text);
}
diff --git a/chromium/ui/message_center/views/bounded_label.h b/chromium/ui/message_center/views/bounded_label.h
index 6d97c8850cc..d6b2f49a519 100644
--- a/chromium/ui/message_center/views/bounded_label.h
+++ b/chromium/ui/message_center/views/bounded_label.h
@@ -14,7 +14,7 @@
#include "ui/views/view.h"
namespace gfx {
-class Font;
+class FontList;
}
namespace message_center {
@@ -33,7 +33,7 @@ class BoundedLabelTest;
// bounded_label.cc file for details.
class MESSAGE_CENTER_EXPORT BoundedLabel : public views::View {
public:
- BoundedLabel(const string16& text, gfx::Font font);
+ BoundedLabel(const string16& text, const gfx::FontList& font_list);
BoundedLabel(const string16& text);
virtual ~BoundedLabel();
diff --git a/chromium/ui/message_center/views/bounded_label_unittest.cc b/chromium/ui/message_center/views/bounded_label_unittest.cc
index a73d84bba9e..bdfb0aceeb6 100644
--- a/chromium/ui/message_center/views/bounded_label_unittest.cc
+++ b/chromium/ui/message_center/views/bounded_label_unittest.cc
@@ -10,7 +10,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/font.h"
+#include "ui/gfx/font_list.h"
+#include "ui/gfx/text_utils.h"
#include "ui/views/controls/label.h"
namespace message_center {
@@ -22,9 +23,10 @@ namespace test {
class BoundedLabelTest : public testing::Test {
public:
BoundedLabelTest() {
- digit_pixels_ = font_.GetStringWidth(UTF8ToUTF16("0"));
- space_pixels_ = font_.GetStringWidth(UTF8ToUTF16(" "));
- ellipsis_pixels_ = font_.GetStringWidth(UTF8ToUTF16("\xE2\x80\xA6"));
+ digit_pixels_ = gfx::GetStringWidth(UTF8ToUTF16("0"), font_list_);
+ space_pixels_ = gfx::GetStringWidth(UTF8ToUTF16(" "), font_list_);
+ ellipsis_pixels_ = gfx::GetStringWidth(UTF8ToUTF16("\xE2\x80\xA6"),
+ font_list_);
}
virtual ~BoundedLabelTest() {}
@@ -62,7 +64,7 @@ class BoundedLabelTest : public testing::Test {
// Exercise BounderLabel::GetLinesForWidthAndLimit() using the test label.
int GetLinesForWidth(int width) {
- label_->SetBounds(0, 0, width, font_.GetHeight() * lines_);
+ label_->SetBounds(0, 0, width, font_list_.GetHeight() * lines_);
return label_->GetLinesForWidthAndLimit(width, lines_);
}
@@ -71,13 +73,14 @@ class BoundedLabelTest : public testing::Test {
// test the newly created label using the exercise methods above.
BoundedLabelTest& Label(string16 text, int lines) {
lines_ = lines;
- label_.reset(new BoundedLabel(text, font_));
+ label_.reset(new BoundedLabel(text, font_list_));
label_->SetLineLimit(lines_);
return *this;
}
private:
- gfx::Font font_; // The default font, which will be used for tests.
+ // The default font list, which will be used for tests.
+ gfx::FontList font_list_;
int digit_pixels_;
int space_pixels_;
int ellipsis_pixels_;
diff --git a/chromium/ui/message_center/views/message_center_view.cc b/chromium/ui/message_center/views/message_center_view.cc
index 95c2cc37669..2acece7402a 100644
--- a/chromium/ui/message_center/views/message_center_view.cc
+++ b/chromium/ui/message_center/views/message_center_view.cc
@@ -11,15 +11,16 @@
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "grit/ui_strings.h"
-#include "ui/base/animation/multi_animation.h"
-#include "ui/base/animation/slide_animation.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/animation/multi_animation.h"
+#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
+#include "ui/message_center/message_center_types.h"
#include "ui/message_center/views/message_center_button_bar.h"
#include "ui/message_center/views/message_view.h"
#include "ui/message_center/views/notification_view.h"
@@ -415,7 +416,7 @@ void MessageListView::OnBoundsAnimatorProgressed(
DCHECK_EQ(animator_.get(), animator);
for (std::set<views::View*>::iterator iter = deleted_when_done_.begin();
iter != deleted_when_done_.end(); ++iter) {
- const ui::SlideAnimation* animation = animator->GetAnimationForView(*iter);
+ const gfx::SlideAnimation* animation = animator->GetAnimationForView(*iter);
if (animation)
(*iter)->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0));
}
@@ -683,28 +684,28 @@ void MessageCenterView::SetSettingsVisible(bool visible) {
source_height_ = source_view_->GetHeightForWidth(width());
target_height_ = target_view_->GetHeightForWidth(width());
- ui::MultiAnimation::Parts parts;
+ gfx::MultiAnimation::Parts parts;
// First part: slide resize animation.
- parts.push_back(ui::MultiAnimation::Part(
+ parts.push_back(gfx::MultiAnimation::Part(
(source_height_ == target_height_) ? 0 : kDefaultAnimationDurationMs,
- ui::Tween::EASE_OUT));
+ gfx::Tween::EASE_OUT));
// Second part: fade-out the source_view.
if (source_view_->layer()) {
- parts.push_back(ui::MultiAnimation::Part(
- kDefaultAnimationDurationMs, ui::Tween::LINEAR));
+ parts.push_back(gfx::MultiAnimation::Part(
+ kDefaultAnimationDurationMs, gfx::Tween::LINEAR));
} else {
- parts.push_back(ui::MultiAnimation::Part());
+ parts.push_back(gfx::MultiAnimation::Part());
}
// Third part: fade-in the target_view.
if (target_view_->layer()) {
- parts.push_back(ui::MultiAnimation::Part(
- kDefaultAnimationDurationMs, ui::Tween::LINEAR));
+ parts.push_back(gfx::MultiAnimation::Part(
+ kDefaultAnimationDurationMs, gfx::Tween::LINEAR));
target_view_->layer()->SetOpacity(0);
target_view_->SetVisible(true);
} else {
- parts.push_back(ui::MultiAnimation::Part());
+ parts.push_back(gfx::MultiAnimation::Part());
}
- settings_transition_animation_.reset(new ui::MultiAnimation(
+ settings_transition_animation_.reset(new gfx::MultiAnimation(
parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz)));
settings_transition_animation_->set_delegate(this);
settings_transition_animation_->set_continuous(false);
@@ -931,9 +932,14 @@ void MessageCenterView::OnNotificationUpdated(const std::string& id) {
}
}
-void MessageCenterView::AnimationEnded(const ui::Animation* animation) {
+void MessageCenterView::AnimationEnded(const gfx::Animation* animation) {
DCHECK_EQ(animation, settings_transition_animation_.get());
+ Visibility visibility = target_view_ == settings_view_
+ ? VISIBILITY_SETTINGS
+ : VISIBILITY_MESSAGE_CENTER;
+ message_center_->SetVisibility(visibility);
+
source_view_->SetVisible(false);
target_view_->SetVisible(true);
if (source_view_->layer())
@@ -945,7 +951,7 @@ void MessageCenterView::AnimationEnded(const ui::Animation* animation) {
Layout();
}
-void MessageCenterView::AnimationProgressed(const ui::Animation* animation) {
+void MessageCenterView::AnimationProgressed(const gfx::Animation* animation) {
DCHECK_EQ(animation, settings_transition_animation_.get());
PreferredSizeChanged();
if (settings_transition_animation_->current_part_index() == 1 &&
@@ -961,7 +967,7 @@ void MessageCenterView::AnimationProgressed(const ui::Animation* animation) {
}
}
-void MessageCenterView::AnimationCanceled(const ui::Animation* animation) {
+void MessageCenterView::AnimationCanceled(const gfx::Animation* animation) {
DCHECK_EQ(animation, settings_transition_animation_.get());
AnimationEnded(animation);
}
diff --git a/chromium/ui/message_center/views/message_center_view.h b/chromium/ui/message_center/views/message_center_view.h
index d53910c2734..7e3c8296730 100644
--- a/chromium/ui/message_center/views/message_center_view.h
+++ b/chromium/ui/message_center/views/message_center_view.h
@@ -7,15 +7,15 @@
#include "ui/views/view.h"
-#include "ui/base/animation/animation_delegate.h"
+#include "ui/gfx/animation/animation_delegate.h"
#include "ui/message_center/message_center_export.h"
#include "ui/message_center/message_center_observer.h"
#include "ui/message_center/notification_list.h"
#include "ui/views/controls/button/button.h"
-namespace ui {
+namespace gfx {
class MultiAnimation;
-} // namespace ui
+} // namespace gfx
namespace views {
class Button;
@@ -37,7 +37,7 @@ class NotifierSettingsView;
class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View,
public MessageCenterObserver,
- public ui::AnimationDelegate {
+ public gfx::AnimationDelegate {
public:
MessageCenterView(MessageCenter* message_center,
MessageCenterTray* tray,
@@ -73,10 +73,10 @@ class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View,
bool by_user) OVERRIDE;
virtual void OnNotificationUpdated(const std::string& id) OVERRIDE;
- // Overridden from ui::AnimationDelegate:
- virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
- virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
- virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
+ // Overridden from gfx::AnimationDelegate:
+ virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
+ virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
+ virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE;
private:
friend class MessageCenterViewTest;
@@ -102,7 +102,7 @@ class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View,
// Animation managing transition between message center and settings (and vice
// versa).
- scoped_ptr<ui::MultiAnimation> settings_transition_animation_;
+ scoped_ptr<gfx::MultiAnimation> settings_transition_animation_;
// Helper data to keep track of the transition between settings and
// message center views.
diff --git a/chromium/ui/message_center/views/message_center_view_unittest.cc b/chromium/ui/message_center/views/message_center_view_unittest.cc
index f6e05f4e30f..b9e34a1ebd1 100644
--- a/chromium/ui/message_center/views/message_center_view_unittest.cc
+++ b/chromium/ui/message_center/views/message_center_view_unittest.cc
@@ -133,7 +133,7 @@ void MessageCenterViewTest::SetUp() {
UTF8ToUTF16("message"),
gfx::Image(),
UTF8ToUTF16("display source"),
- std::string("extension id"),
+ NotifierId(NotifierId::APPLICATION, "extension_id"),
message_center::RichNotificationData(),
NULL);
diff --git a/chromium/ui/message_center/views/message_popup_collection.cc b/chromium/ui/message_center/views/message_popup_collection.cc
index 130a8650f6a..5355ad6962b 100644
--- a/chromium/ui/message_center/views/message_popup_collection.cc
+++ b/chromium/ui/message_center/views/message_popup_collection.cc
@@ -14,8 +14,8 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "ui/base/accessibility/accessibility_types.h"
-#include "ui/base/animation/animation_delegate.h"
-#include "ui/base/animation/slide_animation.h"
+#include "ui/gfx/animation/animation_delegate.h"
+#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/screen.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
@@ -150,9 +150,14 @@ void MessagePopupCollection::UpdateWidgets() {
toasts_.push_back(toast);
gfx::Size preferred_size = toast->GetPreferredSize();
- gfx::Point origin(
- GetToastOriginX(gfx::Rect(preferred_size)) + preferred_size.width(),
- top_down ? base + view_height : base);
+ gfx::Point origin(GetToastOriginX(gfx::Rect(preferred_size)), base);
+ // The toast slides in from the edge of the screen horizontally.
+ if (alignment_ & POPUP_ALIGNMENT_LEFT)
+ origin.set_x(origin.x() - preferred_size.width());
+ else
+ origin.set_x(origin.x() + preferred_size.width());
+ if (top_down)
+ origin.set_y(origin.y() + view_height);
toast->RevealWithAnimation(origin);
// Shift the base line to be a few pixels above the last added toast or (few
@@ -358,9 +363,7 @@ void MessagePopupCollection::OnNotificationRemoved(
return;
target_top_edge_ = (*iter)->bounds().y();
- (*iter)->CloseWithAnimation(true);
- if (by_user) {
- RepositionWidgetsWithTarget();
+ if (by_user && !user_is_closing_toasts_by_clicking_) {
// [Re] start a timeout after which the toasts re-position to their
// normal locations after tracking the mouse pointer for easy deletion.
// This provides a period of time when toasts are easy to remove because
@@ -368,11 +371,18 @@ void MessagePopupCollection::OnNotificationRemoved(
// pointer. If the user continue to remove the toasts, the delay is reset.
// Once user stopped removing the toasts, the toasts re-populate/rearrange
// after the specified delay.
- if (!user_is_closing_toasts_by_clicking_) {
- user_is_closing_toasts_by_clicking_ = true;
- IncrementDeferCounter();
- }
+ user_is_closing_toasts_by_clicking_ = true;
+ IncrementDeferCounter();
}
+
+ // CloseWithAnimation ultimately causes a call to RemoveToast, which calls
+ // OnMouseExited. This means that |user_is_closing_toasts_by_clicking_| must
+ // have been set before this call, otherwise it will remain true even after
+ // the toast is closed, since the defer timer won't be started.
+ (*iter)->CloseWithAnimation(true);
+
+ if (by_user)
+ RepositionWidgetsWithTarget();
}
void MessagePopupCollection::OnDeferTimerExpired() {
diff --git a/chromium/ui/message_center/views/message_popup_collection_unittest.cc b/chromium/ui/message_center/views/message_popup_collection_unittest.cc
index 52299edd6d9..cca2774729e 100644
--- a/chromium/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/chromium/ui/message_center/views/message_popup_collection_unittest.cc
@@ -10,8 +10,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_constants.h"
+#include "ui/events/event.h"
+#include "ui/events/event_constants.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
#include "ui/message_center/fake_message_center.h"
@@ -90,7 +90,7 @@ class MessagePopupCollectionTest : public views::ViewsTestBase {
UTF8ToUTF16("test message"),
gfx::Image(),
string16() /* display_source */,
- "" /* extension_id */,
+ NotifierId(),
message_center::RichNotificationData(),
NULL /* delegate */));
MessageCenter::Get()->AddNotification(notification.Pass());
@@ -377,6 +377,29 @@ TEST_F(MessagePopupCollectionTest, DetectMouseHover) {
// TODO(dimich): Test repositioning - both normal one and when user is closing
// the toasts.
+TEST_F(MessagePopupCollectionTest, DetectMouseHoverWithUserClose) {
+ std::string id0 = AddNotification();
+ std::string id1 = AddNotification();
+ WaitForTransitionsDone();
+
+ views::WidgetDelegateView* toast0 = GetToast(id0);
+ EXPECT_TRUE(toast0 != NULL);
+ views::WidgetDelegateView* toast1 = GetToast(id1);
+ ASSERT_TRUE(toast1 != NULL);
+
+ ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 0);
+ toast1->OnMouseEntered(event);
+ static_cast<MessageCenterObserver*>(collection())->OnNotificationRemoved(
+ id1, true);
+
+ EXPECT_FALSE(MouseInCollection());
+ std::string id2 = AddNotification();
+
+ WaitForTransitionsDone();
+ views::WidgetDelegateView* toast2 = GetToast(id2);
+ EXPECT_TRUE(toast2 != NULL);
+}
+
} // namespace test
} // namespace message_center
diff --git a/chromium/ui/message_center/views/message_view.cc b/chromium/ui/message_center/views/message_view.cc
index 7eb9838e24b..e3199ccdb4b 100644
--- a/chromium/ui/message_center/views/message_view.cc
+++ b/chromium/ui/message_center/views/message_view.cc
@@ -35,8 +35,7 @@ const int kShadowBlur = 4;
// Menu constants
const int kTogglePermissionCommand = 0;
-const int kToggleExtensionCommand = 1;
-const int kShowSettingsCommand = 2;
+const int kShowSettingsCommand = 1;
// ControlButtons are ImageButtons whose image can be padded within the button.
// This allows the creation of buttons like the notification close and expand
@@ -170,7 +169,7 @@ class MenuModel : public ui::SimpleMenuModel,
message_center::MessageCenterTray* tray,
const std::string& notification_id,
const string16& display_source,
- const std::string& extension_id);
+ const message_center::NotifierId& notifier_id);
virtual ~MenuModel();
// Overridden from ui::SimpleMenuModel::Delegate:
@@ -186,6 +185,7 @@ class MenuModel : public ui::SimpleMenuModel,
message_center::MessageCenter* message_center_; // Weak reference.
message_center::MessageCenterTray* tray_; // Weak reference.
std::string notification_id_;
+ message_center::NotifierId notifier_id_;
DISALLOW_COPY_AND_ASSIGN(MenuModel);
};
@@ -194,19 +194,16 @@ MenuModel::MenuModel(message_center::MessageCenter* message_center,
message_center::MessageCenterTray* tray,
const std::string& notification_id,
const string16& display_source,
- const std::string& extension_id)
+ const message_center::NotifierId& notifier_id)
: ui::SimpleMenuModel(this),
message_center_(message_center),
tray_(tray),
- notification_id_(notification_id) {
+ notification_id_(notification_id),
+ notifier_id_(notifier_id) {
// Add 'disable notifications' menu item.
- if (!extension_id.empty() && !display_source.empty()) {
- AddItem(kToggleExtensionCommand,
- l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_EXTENSIONS_DISABLE,
- display_source));
- } else if (!display_source.empty()) {
+ if (!display_source.empty()) {
AddItem(kTogglePermissionCommand,
- l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_SITE_DISABLE,
+ l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_NOTIFIER_DISABLE,
display_source));
}
// Add settings menu item.
@@ -236,18 +233,13 @@ bool MenuModel::GetAcceleratorForCommandId(int command_id,
void MenuModel::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
- case kToggleExtensionCommand:
- message_center_->DisableNotificationsByExtension(notification_id_);
- break;
case kTogglePermissionCommand:
- message_center_->DisableNotificationsByUrl(notification_id_);
+ message_center_->DisableNotificationsByNotifier(notifier_id_);
break;
case kShowSettingsCommand:
// |tray_| may be NULL in tests.
if (tray_)
tray_->ShowNotifierSettingsBubble();
- else
- message_center_->ShowNotificationSettings(notification_id_);
break;
default:
NOTREACHED();
@@ -276,7 +268,7 @@ class MessageViewContextMenuController : public views::ContextMenuController {
MessageCenterTray* tray_; // Weak reference.
std::string notification_id_;
string16 display_source_;
- std::string extension_id_;
+ NotifierId notifier_id_;
};
MessageViewContextMenuController::MessageViewContextMenuController(
@@ -287,7 +279,7 @@ MessageViewContextMenuController::MessageViewContextMenuController(
tray_(tray),
notification_id_(notification.id()),
display_source_(notification.display_source()),
- extension_id_(notification.extension_id()) {
+ notifier_id_(notification.notifier_id()) {
}
MessageViewContextMenuController::~MessageViewContextMenuController() {
@@ -298,7 +290,7 @@ void MessageViewContextMenuController::ShowContextMenuForView(
const gfx::Point& point,
ui::MenuSourceType source_type) {
MenuModel menu_model(message_center_, tray_, notification_id_,
- display_source_, extension_id_);
+ display_source_, notifier_id_);
if (menu_model.GetItemCount() == 0)
return;
diff --git a/chromium/ui/message_center/views/notification_view.cc b/chromium/ui/message_center/views/notification_view.cc
index abfc1efe689..b6e8bcc8d4b 100644
--- a/chromium/ui/message_center/views/notification_view.cc
+++ b/chromium/ui/message_center/views/notification_view.cc
@@ -10,10 +10,10 @@
#include "grit/ui_resources.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/text/text_elider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/size.h"
#include "ui/gfx/skia_util.h"
+#include "ui/gfx/text_elider.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_switches.h"
@@ -30,6 +30,10 @@
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/widget.h"
+#if defined(USE_AURA)
+#include "ui/base/cursor/cursor.h"
+#endif
+
namespace {
// Dimensions.
@@ -53,12 +57,16 @@ const size_t kTitleCharacterLimit =
const size_t kMessageCharacterLimit =
message_center::kNotificationWidth *
message_center::kMessageExpandedLineLimit / 3;
+const size_t kContextMessageCharacterLimit =
+ message_center::kNotificationWidth *
+ message_center::kContextMessageLineLimit / 3;
// Notification colors. The text background colors below are used only to keep
// view::Label from modifying the text color and will not actually be drawn.
// See view::Label's RecalculateColors() for details.
const SkColor kRegularTextBackgroundColor = SK_ColorWHITE;
const SkColor kDimTextBackgroundColor = SK_ColorWHITE;
+const SkColor kContextTextBackgroundColor = SK_ColorWHITE;
// static
views::Background* MakeBackground(
@@ -462,13 +470,17 @@ NotificationView::NotificationView(const Notification& notification,
top_view_->set_border(MakeEmptyBorder(
kTextTopPadding - 8, 0, kTextBottomPadding - 5, 0));
+ const gfx::FontList default_label_font_list = views::Label().font_list();
+
// Create the title view if appropriate.
title_view_ = NULL;
if (!notification.title().empty()) {
- gfx::Font font = views::Label().font().DeriveFont(2);
- int padding = kTitleLineHeight - font.GetHeight();
+ const gfx::FontList& font_list =
+ default_label_font_list.DeriveFontListWithSizeDelta(2);
+ int padding = kTitleLineHeight - font_list.GetHeight();
title_view_ = new BoundedLabel(
- ui::TruncateString(notification.title(), kTitleCharacterLimit), font);
+ gfx::TruncateString(notification.title(), kTitleCharacterLimit),
+ font_list);
title_view_->SetLineHeight(kTitleLineHeight);
title_view_->SetLineLimit(message_center::kTitleLineLimit);
title_view_->SetColors(message_center::kRegularTextColor,
@@ -481,18 +493,36 @@ NotificationView::NotificationView(const Notification& notification,
// Create the message view if appropriate.
message_view_ = NULL;
if (!notification.message().empty()) {
- int padding = kMessageLineHeight - views::Label().font().GetHeight();
+ int padding = kMessageLineHeight - default_label_font_list.GetHeight();
message_view_ = new BoundedLabel(
- ui::TruncateString(notification.message(), kMessageCharacterLimit));
+ gfx::TruncateString(notification.message(), kMessageCharacterLimit));
message_view_->SetLineHeight(kMessageLineHeight);
message_view_->SetVisible(!is_expanded() || !notification.items().size());
- message_view_->SetColors(message_center::kDimTextColor,
+ message_view_->SetColors(message_center::kRegularTextColor,
kDimTextBackgroundColor);
message_view_->set_border(MakeTextBorder(padding, 4, 0));
top_view_->AddChildView(message_view_);
accessible_lines.push_back(notification.message());
}
+ // Create the context message view if appropriate.
+ context_message_view_ = NULL;
+ if (!notification.context_message().empty()) {
+ int padding = kMessageLineHeight - default_label_font_list.GetHeight();
+ context_message_view_ =
+ new BoundedLabel(gfx::TruncateString(notification.context_message(),
+ kContextMessageCharacterLimit),
+ default_label_font_list);
+ context_message_view_->SetLineLimit(
+ message_center::kContextMessageLineLimit);
+ context_message_view_->SetLineHeight(kMessageLineHeight);
+ context_message_view_->SetColors(message_center::kDimTextColor,
+ kContextTextBackgroundColor);
+ context_message_view_->set_border(MakeTextBorder(padding, 4, 0));
+ top_view_->AddChildView(context_message_view_);
+ accessible_lines.push_back(notification.context_message());
+ }
+
// Create the progress bar view.
progress_bar_view_ = NULL;
if (notification.type() == NOTIFICATION_TYPE_PROGRESS) {
@@ -504,7 +534,7 @@ NotificationView::NotificationView(const Notification& notification,
}
// Create the list item views (up to a maximum).
- int padding = kMessageLineHeight - views::Label().font().GetHeight();
+ int padding = kMessageLineHeight - default_label_font_list.GetHeight();
std::vector<NotificationItem> items = notification.items();
for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
ItemView* item_view = new ItemView(items[i]);
diff --git a/chromium/ui/message_center/views/notification_view.h b/chromium/ui/message_center/views/notification_view.h
index 622e2c3bd69..5479939da8c 100644
--- a/chromium/ui/message_center/views/notification_view.h
+++ b/chromium/ui/message_center/views/notification_view.h
@@ -71,6 +71,7 @@ class MESSAGE_CENTER_EXPORT NotificationView : public MessageView {
views::View* top_view_;
BoundedLabel* title_view_;
BoundedLabel* message_view_;
+ BoundedLabel* context_message_view_;
std::vector<views::View*> item_views_;
views::View* icon_view_;
views::View* bottom_view_;
diff --git a/chromium/ui/message_center/views/notifier_settings_view.cc b/chromium/ui/message_center/views/notifier_settings_view.cc
index b4e18846a2b..40982748637 100644
--- a/chromium/ui/message_center/views/notifier_settings_view.cc
+++ b/chromium/ui/message_center/views/notifier_settings_view.cc
@@ -13,10 +13,10 @@
#include "grit/ui_strings.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/size.h"
@@ -419,7 +419,7 @@ void NotifierSettingsView::UpdateContentsView(
contents_title_view->AddChildView(top_label);
string16 notifier_group_text;
- if (provider_) {
+ if (provider_ && provider_->GetNotifierGroupCount() > 0) {
const NotifierGroup& active_group = provider_->GetActiveNotifierGroup();
notifier_group_text = active_group.login_info.empty()
? active_group.name
@@ -478,7 +478,6 @@ gfx::Size NotifierSettingsView::GetMinimumSize() {
gfx::Size NotifierSettingsView::GetPreferredSize() {
gfx::Size preferred_size;
- std::vector<gfx::Size> child_sizes;
gfx::Size title_size = title_label_->GetPreferredSize();
gfx::Size content_size = scroller_->contents()->GetPreferredSize();
return gfx::Size(std::max(title_size.width(), content_size.width()),
diff --git a/chromium/ui/message_center/views/toast_contents_view.cc b/chromium/ui/message_center/views/toast_contents_view.cc
index b7dae986a20..645c654701c 100644
--- a/chromium/ui/message_center/views/toast_contents_view.cc
+++ b/chromium/ui/message_center/views/toast_contents_view.cc
@@ -11,8 +11,8 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "ui/base/accessibility/accessible_view_state.h"
-#include "ui/base/animation/animation_delegate.h"
-#include "ui/base/animation/slide_animation.h"
+#include "ui/gfx/animation/animation_delegate.h"
+#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/message_center/message_center.h"
@@ -59,7 +59,7 @@ ToastContentsView::ToastContentsView(
// remains. This is hacky but easier to keep the consistency.
set_background(views::Background::CreateSolidBackground(0, 0, 0, 0));
- fade_animation_.reset(new ui::SlideAnimation(this));
+ fade_animation_.reset(new gfx::SlideAnimation(this));
fade_animation_->SetSlideDuration(kFadeInOutDuration);
}
@@ -91,8 +91,22 @@ void ToastContentsView::SetContents(MessageView* view) {
Layout();
// If it has the contents already, this invocation means an update of the
// popup toast, and the new contents should be read through a11y feature.
- if (already_has_contents)
- NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, false);
+ // The notification type should be ALERT, otherwise the accessibility message
+ // won't be read for this view which returns ROLE_WINDOW.
+ if (already_has_contents) {
+ const NotificationList::Notifications& notifications =
+ message_center_->GetNotifications();
+ for (NotificationList::Notifications::const_iterator iter =
+ notifications.begin(); iter != notifications.end(); ++iter) {
+ if ((*iter)->id() != id_)
+ continue;
+
+ const RichNotificationData& optional = (*iter)->rich_notification_data();
+ if (optional.should_make_spoken_feedback_for_popup_updates)
+ NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, false);
+ break;
+ }
+ }
}
void ToastContentsView::RevealWithAnimation(gfx::Point origin) {
@@ -153,7 +167,7 @@ void ToastContentsView::SetBoundsWithAnimation(gfx::Rect new_bounds) {
if (bounds_animation_.get())
bounds_animation_->Stop();
- bounds_animation_.reset(new ui::SlideAnimation(this));
+ bounds_animation_.reset(new gfx::SlideAnimation(this));
bounds_animation_->Show();
}
@@ -181,7 +195,7 @@ void ToastContentsView::StartFadeOut() {
}
void ToastContentsView::OnBoundsAnimationEndedOrCancelled(
- const ui::Animation* animation) {
+ const gfx::Animation* animation) {
if (is_closing_ && closing_animation_ == animation && GetWidget()) {
views::Widget* widget = GetWidget();
#if defined(USE_AURA)
@@ -205,8 +219,8 @@ void ToastContentsView::OnBoundsAnimationEndedOrCancelled(
collection_->DecrementDeferCounter();
}
-// ui::AnimationDelegate
-void ToastContentsView::AnimationProgressed(const ui::Animation* animation) {
+// gfx::AnimationDelegate
+void ToastContentsView::AnimationProgressed(const gfx::Animation* animation) {
if (animation == bounds_animation_.get()) {
gfx::Rect current(animation->CurrentValueBetween(
animated_bounds_start_, animated_bounds_end_));
@@ -218,12 +232,12 @@ void ToastContentsView::AnimationProgressed(const ui::Animation* animation) {
}
}
-void ToastContentsView::AnimationEnded(const ui::Animation* animation) {
+void ToastContentsView::AnimationEnded(const gfx::Animation* animation) {
OnBoundsAnimationEndedOrCancelled(animation);
}
void ToastContentsView::AnimationCanceled(
- const ui::Animation* animation) {
+ const gfx::Animation* animation) {
OnBoundsAnimationEndedOrCancelled(animation);
}
diff --git a/chromium/ui/message_center/views/toast_contents_view.h b/chromium/ui/message_center/views/toast_contents_view.h
index 4f26c6acb0c..6b79ac1336e 100644
--- a/chromium/ui/message_center/views/toast_contents_view.h
+++ b/chromium/ui/message_center/views/toast_contents_view.h
@@ -7,14 +7,14 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
-#include "ui/base/animation/animation_delegate.h"
+#include "ui/gfx/animation/animation_delegate.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "ui/views/widget/widget_delegate.h"
-namespace ui {
+namespace gfx {
class Animation;
class SlideAnimation;
}
@@ -32,7 +32,7 @@ class Notification;
class ToastContentsView : public views::WidgetDelegateView,
- public ui::AnimationDelegate {
+ public gfx::AnimationDelegate {
public:
ToastContentsView(const Notification* notification,
base::WeakPtr<MessagePopupCollection> collection,
@@ -71,10 +71,10 @@ class ToastContentsView : public views::WidgetDelegateView,
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
private:
- // Overridden from ui::AnimationDelegate:
- virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
- virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
- virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
+ // Overridden from gfx::AnimationDelegate:
+ virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
+ virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
+ virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE;
// Overridden from views::WidgetDelegate:
virtual views::View* GetContentsView() OVERRIDE;
@@ -90,7 +90,7 @@ class ToastContentsView : public views::WidgetDelegateView,
void StartFadeIn();
void StartFadeOut(); // Will call Widget::Close() when animation ends.
- void OnBoundsAnimationEndedOrCancelled(const ui::Animation* animation);
+ void OnBoundsAnimationEndedOrCancelled(const gfx::Animation* animation);
base::WeakPtr<MessagePopupCollection> collection_;
MessageCenter* message_center_;
@@ -98,8 +98,8 @@ class ToastContentsView : public views::WidgetDelegateView,
// Id if the corresponding Notification.
std::string id_;
- scoped_ptr<ui::SlideAnimation> bounds_animation_;
- scoped_ptr<ui::SlideAnimation> fade_animation_;
+ scoped_ptr<gfx::SlideAnimation> bounds_animation_;
+ scoped_ptr<gfx::SlideAnimation> fade_animation_;
bool is_animating_bounds_;
gfx::Rect animated_bounds_start_;
@@ -108,7 +108,7 @@ class ToastContentsView : public views::WidgetDelegateView,
bool is_closing_;
// Closing animation - when it ends, close the widget. Weak, only used
// for referential equality.
- ui::Animation* closing_animation_;
+ gfx::Animation* closing_animation_;
gfx::Point origin_;
gfx::Size preferred_size_;