Commit 93c331c2 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Apply system style to sync error notification.

In new-style notification, system notification has different style from
other notifications such as web notifications.

This CL fixes sync error notification:
* The context header shows the title "Sign In".
* The context header has an accent color.
* "Update sync passphrase" button is removed.
* New MD icon is used.

If chrome://flags#enable-message-center-new-style-notification is
disabled, this CL has no effect.

Before: http://screen/kTTXQujdxao
After: http://screen/WoRuaLE732T

TEST=manually tested on chell device
BUG=775381

Change-Id: I8c030131a5a9241223b6b02601fabe4035e9b866
Reviewed-on: https://chromium-review.googlesource.com/722545
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarPavel Yatsuk <pavely@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509689}
parent b2ef1382
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/user_flow.h" #include "chrome/browser/chromeos/login/user_flow.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
...@@ -25,6 +26,8 @@ ...@@ -25,6 +26,8 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/message_center/notification.h" #include "ui/message_center/notification.h"
#include "ui/message_center/notification_delegate.h" #include "ui/message_center/notification_delegate.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/public/cpp/message_center_switches.h"
namespace { namespace {
...@@ -38,7 +41,6 @@ class SyncNotificationDelegate : public message_center::NotificationDelegate { ...@@ -38,7 +41,6 @@ class SyncNotificationDelegate : public message_center::NotificationDelegate {
// NotificationDelegate: // NotificationDelegate:
void Click() override; void Click() override;
void ButtonClick(int button_index) override;
protected: protected:
~SyncNotificationDelegate() override; ~SyncNotificationDelegate() override;
...@@ -61,10 +63,6 @@ void SyncNotificationDelegate::Click() { ...@@ -61,10 +63,6 @@ void SyncNotificationDelegate::Click() {
ShowSyncSetup(); ShowSyncSetup();
} }
void SyncNotificationDelegate::ButtonClick(int button_index) {
ShowSyncSetup();
}
void SyncNotificationDelegate::ShowSyncSetup() { void SyncNotificationDelegate::ShowSyncSetup() {
LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_);
if (login_ui->current_login_ui()) { if (login_ui->current_login_ui()) {
...@@ -138,11 +136,6 @@ void SyncErrorNotifier::OnErrorChanged() { ...@@ -138,11 +136,6 @@ void SyncErrorNotifier::OnErrorChanged() {
notification_id_, NotificationUIManager::GetProfileID(profile_)) == notification_id_, NotificationUIManager::GetProfileID(profile_)) ==
nullptr); nullptr);
// Add an accept button to launch the sync setup settings subpage.
message_center::RichNotificationData data;
data.buttons.push_back(message_center::ButtonInfo(
l10n_util::GetStringUTF16(IDS_SYNC_NOTIFICATION_ACCEPT)));
message_center::NotifierId notifier_id( message_center::NotifierId notifier_id(
message_center::NotifierId::SYSTEM_COMPONENT, kProfileSyncNotificationId); message_center::NotifierId::SYSTEM_COMPONENT, kProfileSyncNotificationId);
...@@ -155,11 +148,22 @@ void SyncErrorNotifier::OnErrorChanged() { ...@@ -155,11 +148,22 @@ void SyncErrorNotifier::OnErrorChanged() {
message_center::NOTIFICATION_TYPE_SIMPLE, notification_id_, message_center::NOTIFICATION_TYPE_SIMPLE, notification_id_,
l10n_util::GetStringUTF16(IDS_SYNC_ERROR_BUBBLE_VIEW_TITLE), l10n_util::GetStringUTF16(IDS_SYNC_ERROR_BUBBLE_VIEW_TITLE),
l10n_util::GetStringUTF16(IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_MESSAGE), l10n_util::GetStringUTF16(IDS_SYNC_PASSPHRASE_ERROR_BUBBLE_VIEW_MESSAGE),
ui::ResourceBundle::GetSharedInstance().GetImageNamed( message_center::IsNewStyleNotificationEnabled()
IDR_NOTIFICATION_ALERT), ? gfx::Image()
base::string16(), // display_source : ui::ResourceBundle::GetSharedInstance().GetImageNamed(
GURL(notification_id_), notifier_id, data, IDR_NOTIFICATION_ALERT),
l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_DISPLAY_SOURCE),
GURL(notification_id_), notifier_id,
message_center::RichNotificationData(),
new SyncNotificationDelegate(profile_)); new SyncNotificationDelegate(profile_));
if (message_center::IsNewStyleNotificationEnabled()) {
notification.set_accent_color(
message_center::kSystemNotificationColorWarning);
notification.set_small_image(gfx::Image(gfx::CreateVectorIcon(
kNotificationWarningIcon, message_center::kSmallImageSizeMD,
message_center::kSystemNotificationColorWarning)));
notification.set_vector_small_image(kNotificationWarningIcon);
}
notification_ui_manager->Add(notification, profile_); notification_ui_manager->Add(notification, profile_);
notification_displayed_ = true; notification_displayed_ = true;
......
...@@ -127,7 +127,6 @@ class SyncErrorNotifierTest : public BrowserWithTestWindowTest { ...@@ -127,7 +127,6 @@ class SyncErrorNotifierTest : public BrowserWithTestWindowTest {
ASSERT_TRUE(notification); ASSERT_TRUE(notification);
ASSERT_FALSE(notification->title().empty()); ASSERT_FALSE(notification->title().empty());
ASSERT_FALSE(notification->message().empty()); ASSERT_FALSE(notification->message().empty());
ASSERT_EQ((size_t)1, notification->buttons().size());
} else { } else {
ASSERT_FALSE(notification); ASSERT_FALSE(notification);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment