Commit 9e3561e0 authored by John Mellor's avatar John Mellor Committed by Commit Bot

Revert "Add first-party notification styling in MD notification."

This reverts commit 01f38b46.

Reason for revert: Sorry, this broke compilation on 3 bots:
- https://build.chromium.org/p/chromium.android/builders/Android%20x86%20Builder%20%28dbg%29
- https://build.chromium.org/p/chromium.android/builders/Android%20x64%20Builder%20%28dbg%29
- https://build.chromium.org/p/chromium.android/builders/Android%20MIPS%20Builder%20%28dbg%29

With the following linker error:

obj/ui/message_center/message_center/notification.o: In function `message_center::Notification::CreateSystemNotification(...)':
../../ui/message_center/notification.cc:182: undefined reference to `gfx::kNoneIcon'
obj/ui/message_center/message_center/notification.o: In function `message_center::Notification::CreateSystemNotification(...)':
../../ui/message_center/notification.cc:232: undefined reference to `gfx::CreateVectorIcon(gfx::VectorIcon const&, unsigned int)'


Original change's description:
> Add first-party notification styling in MD notification.
> 
> In new-style notification, first-party notification should have
> different styling compared to general web notifications.
> To do this, all system notifications should be created by
> new CreateSystemNotification. (Previously, it was not a requirement.)
> 
> By using the function,
> * the display source defaults to string "ChromeOS system".
> * the notification has single accent color based on
>   SystemNotificationWarningLevel.
> * gfx::VectorIcon will be passed as small_image instead of gfx::Image
>   to perform icon coloring on CreateSystemNotification side.
> 
> TEST=out/Debug/message_center_unittests
> BUG=738779,726241,740807,740813
> 
> Change-Id: I9e85b3f1de33b6499297f060b5305d0b02157eef
> Reviewed-on: https://chromium-review.googlesource.com/566765
> Reviewed-by: James Cook <jamescook@chromium.org>
> Reviewed-by: Yoshiki Iguchi <yoshiki@chromium.org>
> Reviewed-by: Peter Beverloo <peter@chromium.org>
> Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#491592}

TBR=jamescook@chromium.org,yoshiki@chromium.org,peter@chromium.org,fukino@chromium.org,tetsui@chromium.org

Change-Id: I10fe30dbdad6012fbafe32c17a439065f4d816d3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 738779, 726241, 740807, 740813
Reviewed-on: https://chromium-review.googlesource.com/600067Reviewed-by: default avatarJohn Mellor <johnme@chromium.org>
Commit-Queue: John Mellor <johnme@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491696}
parent 85b0527c
...@@ -107,7 +107,6 @@ ...@@ -107,7 +107,6 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h" #include "chrome/common/logging_chrome.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
#include "chromeos/audio/audio_devices_pref_handler_impl.h" #include "chromeos/audio/audio_devices_pref_handler_impl.h"
#include "chromeos/audio/cras_audio_handler.h" #include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/cert_loader.h" #include "chromeos/cert_loader.h"
...@@ -170,12 +169,10 @@ ...@@ -170,12 +169,10 @@
#include "ui/base/ime/chromeos/ime_keyboard.h" #include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/chromeos/input_method_util.h" #include "ui/base/ime/chromeos/input_method_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/touch/touch_device.h" #include "ui/base/touch/touch_device.h"
#include "ui/chromeos/events/event_rewriter_chromeos.h" #include "ui/chromeos/events/event_rewriter_chromeos.h"
#include "ui/chromeos/events/pref_names.h" #include "ui/chromeos/events/pref_names.h"
#include "ui/events/event_utils.h" #include "ui/events/event_utils.h"
#include "ui/message_center/message_center.h"
#if BUILDFLAG(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
#include "components/rlz/rlz_tracker.h" #include "components/rlz/rlz_tracker.h"
...@@ -790,11 +787,6 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { ...@@ -790,11 +787,6 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
VLOG(1) << "Relaunching browser for user: " << account_id.Serialize() VLOG(1) << "Relaunching browser for user: " << account_id.Serialize()
<< " with hash: " << user_id_hash; << " with hash: " << user_id_hash;
} }
// Set product name ("Chrome OS" or "Chromium OS") to be used in context
// header of new-style notification.
message_center::MessageCenter::Get()->SetProductOSName(
l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME));
} }
class GuestLanguageSetCallbackData { class GuestLanguageSetCallbackData {
......
...@@ -28,7 +28,6 @@ component("message_center") { ...@@ -28,7 +28,6 @@ component("message_center") {
deps = [ deps = [
"//base", "//base",
"//ui/base", "//ui/base",
"//ui/strings",
"//url", "//url",
] ]
...@@ -48,6 +47,7 @@ component("message_center") { ...@@ -48,6 +47,7 @@ component("message_center") {
"//ui/gfx/geometry", "//ui/gfx/geometry",
"//ui/native_theme", "//ui/native_theme",
"//ui/resources", "//ui/resources",
"//ui/strings",
] ]
configs += [ configs += [
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/message_center/fake_message_center.h" #include "ui/message_center/fake_message_center.h"
#include "base/strings/string_util.h"
#include "ui/message_center/notification_list.h" #include "ui/message_center/notification_list.h"
namespace message_center { namespace message_center {
...@@ -143,13 +142,6 @@ void FakeMessageCenter::RestartPopupTimers() {} ...@@ -143,13 +142,6 @@ void FakeMessageCenter::RestartPopupTimers() {}
void FakeMessageCenter::PausePopupTimers() {} void FakeMessageCenter::PausePopupTimers() {}
const base::string16& FakeMessageCenter::GetProductOSName() const {
return base::EmptyString16();
}
void FakeMessageCenter::SetProductOSName(
const base::string16& product_os_name) {}
void FakeMessageCenter::DisableTimersForTest() {} void FakeMessageCenter::DisableTimersForTest() {}
void FakeMessageCenter::EnableChangeQueueForTest(bool enabled) {} void FakeMessageCenter::EnableChangeQueueForTest(bool enabled) {}
......
...@@ -68,8 +68,6 @@ class FakeMessageCenter : public MessageCenter { ...@@ -68,8 +68,6 @@ class FakeMessageCenter : public MessageCenter {
bool IsMessageCenterVisible() const override; bool IsMessageCenterVisible() const override;
void RestartPopupTimers() override; void RestartPopupTimers() override;
void PausePopupTimers() override; void PausePopupTimers() override;
const base::string16& GetProductOSName() const override;
void SetProductOSName(const base::string16& product_os_name) override;
protected: protected:
void DisableTimersForTest() override; void DisableTimersForTest() override;
......
...@@ -193,11 +193,6 @@ class MESSAGE_CENTER_EXPORT MessageCenter { ...@@ -193,11 +193,6 @@ class MESSAGE_CENTER_EXPORT MessageCenter {
// example, after the mouse leaves the popup.) // example, after the mouse leaves the popup.)
virtual void RestartPopupTimers() = 0; virtual void RestartPopupTimers() = 0;
// "Chromium OS" or "Chrome OS" in the current locale.
// Return empty string if not on these platforms.
virtual const base::string16& GetProductOSName() const = 0;
virtual void SetProductOSName(const base::string16& product_os_name) = 0;
protected: protected:
friend class ::DownloadNotification; friend class ::DownloadNotification;
friend class ::DownloadNotificationTestBase; friend class ::DownloadNotificationTestBase;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/message_center/message_center_style.h" #include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_switches.h" #include "ui/message_center/message_center_switches.h"
...@@ -944,15 +943,6 @@ void MessageCenterImpl::PausePopupTimers() { ...@@ -944,15 +943,6 @@ void MessageCenterImpl::PausePopupTimers() {
popup_timers_controller_->PauseAll(); popup_timers_controller_->PauseAll();
} }
const base::string16& MessageCenterImpl::GetProductOSName() const {
return product_os_name_;
}
void MessageCenterImpl::SetProductOSName(
const base::string16& product_os_name) {
product_os_name_ = product_os_name;
}
void MessageCenterImpl::DisableTimersForTest() { void MessageCenterImpl::DisableTimersForTest() {
popup_timers_controller_.reset(); popup_timers_controller_.reset();
} }
......
...@@ -84,8 +84,6 @@ class MessageCenterImpl : public MessageCenter, ...@@ -84,8 +84,6 @@ class MessageCenterImpl : public MessageCenter,
void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) override; void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) override;
void RestartPopupTimers() override; void RestartPopupTimers() override;
void PausePopupTimers() override; void PausePopupTimers() override;
const base::string16& GetProductOSName() const override;
void SetProductOSName(const base::string16& product_os_name) override;
void ForceNotificationFlush(const std::string& id) override; void ForceNotificationFlush(const std::string& id) override;
// NotificationBlocker::Observer overrides: // NotificationBlocker::Observer overrides:
...@@ -139,8 +137,6 @@ class MessageCenterImpl : public MessageCenter, ...@@ -139,8 +137,6 @@ class MessageCenterImpl : public MessageCenter,
// center is visible. // center is visible.
std::unique_ptr<internal::ChangeQueue> notification_queue_; std::unique_ptr<internal::ChangeQueue> notification_queue_;
base::string16 product_os_name_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterImpl); DISALLOW_COPY_AND_ASSIGN(MessageCenterImpl);
}; };
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/message_center/message_center_export.h" #include "ui/message_center/message_center_export.h"
...@@ -101,15 +100,6 @@ const SkColor kSmallImageMaskBackgroundColor = SkColorSetRGB(0xa3, 0xa3, 0xa3); ...@@ -101,15 +100,6 @@ const SkColor kSmallImageMaskBackgroundColor = SkColorSetRGB(0xa3, 0xa3, 0xa3);
const SkColor kControlButtonBackgroundColor = const SkColor kControlButtonBackgroundColor =
SkColorSetA(SK_ColorWHITE, 0.9 * 0xff); SkColorSetA(SK_ColorWHITE, 0.9 * 0xff);
// Accent colors of system notifications.
const SkColor kSystemNotificationColorNormal = SkColorSetRGB(0x33, 0x67, 0xd6);
const SkColor kSystemNotificationColorWarning = SkColorSetRGB(0xea, 0x61, 0x0);
const SkColor kSystemNotificationColorCriticalWarning =
SkColorSetRGB(0xc5, 0x39, 0x29);
// Default accent color of notifications that are not generated by system.
const SkColor kNotificationDefaultAccentColor = gfx::kChromeIconGrey;
// Limits. // Limits.
// Given the size of an image, returns the size of the properly scaled-up image // Given the size of an image, returns the size of the properly scaled-up image
......
...@@ -5,15 +5,8 @@ ...@@ -5,15 +5,8 @@
#include "ui/message_center/notification.h" #include "ui/message_center/notification.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/notification_delegate.h" #include "ui/message_center/notification_delegate.h"
#include "ui/message_center/notification_types.h" #include "ui/message_center/notification_types.h"
#include "ui/strings/grit/ui_strings.h"
namespace message_center { namespace message_center {
...@@ -61,9 +54,7 @@ RichNotificationData::RichNotificationData(const RichNotificationData& other) ...@@ -61,9 +54,7 @@ RichNotificationData::RichNotificationData(const RichNotificationData& other)
vibration_pattern(other.vibration_pattern), vibration_pattern(other.vibration_pattern),
renotify(other.renotify), renotify(other.renotify),
silent(other.silent), silent(other.silent),
accessible_name(other.accessible_name), accessible_name(other.accessible_name) {}
accent_color(other.accent_color) {
}
RichNotificationData::~RichNotificationData() = default; RichNotificationData::~RichNotificationData() = default;
...@@ -179,58 +170,14 @@ std::unique_ptr<Notification> Notification::CreateSystemNotification( ...@@ -179,58 +170,14 @@ std::unique_ptr<Notification> Notification::CreateSystemNotification(
const gfx::Image& icon, const gfx::Image& icon,
const std::string& system_component_id, const std::string& system_component_id,
const base::Closure& click_callback) { const base::Closure& click_callback) {
std::unique_ptr<Notification> notification = CreateSystemNotification( std::unique_ptr<Notification> notification(new Notification(
NOTIFICATION_TYPE_SIMPLE, notification_id, title, message, icon, NOTIFICATION_TYPE_SIMPLE, notification_id, title, message, icon,
base::string16() /* display_source */, GURL(), base::string16() /* display_source */, GURL(),
NotifierId(NotifierId::SYSTEM_COMPONENT, system_component_id), NotifierId(NotifierId::SYSTEM_COMPONENT, system_component_id),
RichNotificationData(), RichNotificationData(),
new HandleNotificationClickedDelegate(click_callback), gfx::kNoneIcon, new HandleNotificationClickedDelegate(click_callback)));
SystemNotificationWarningLevel::CRITICAL_WARNING);
notification->SetSystemPriority(); notification->SetSystemPriority();
return notification; return notification;
} }
// static
std::unique_ptr<Notification> Notification::CreateSystemNotification(
NotificationType type,
const std::string& id,
const base::string16& title,
const base::string16& message,
const gfx::Image& icon,
const base::string16& display_source,
const GURL& origin_url,
const NotifierId& notifier_id,
const RichNotificationData& optional_fields,
scoped_refptr<NotificationDelegate> delegate,
const gfx::VectorIcon& small_image,
SystemNotificationWarningLevel color_type) {
SkColor color = message_center::kSystemNotificationColorNormal;
switch (color_type) {
case SystemNotificationWarningLevel::NORMAL:
color = message_center::kSystemNotificationColorNormal;
break;
case SystemNotificationWarningLevel::WARNING:
color = message_center::kSystemNotificationColorWarning;
break;
case SystemNotificationWarningLevel::CRITICAL_WARNING:
color = message_center::kSystemNotificationColorCriticalWarning;
break;
}
base::string16 display_source_or_default = display_source;
if (display_source_or_default.empty()) {
display_source_or_default = l10n_util::GetStringFUTF16(
IDS_MESSAGE_CENTER_NOTIFICATION_CHROMEOS_SYSTEM,
MessageCenter::Get()->GetProductOSName());
}
std::unique_ptr<Notification> notification = base::MakeUnique<Notification>(
type, id, title, message, icon, display_source_or_default, origin_url,
notifier_id, optional_fields, delegate);
notification->set_accent_color(color);
notification->set_small_image(
small_image.is_empty()
? gfx::Image()
: gfx::Image(gfx::CreateVectorIcon(small_image, color)));
return notification;
}
} // namespace message_center } // namespace message_center
...@@ -15,19 +15,13 @@ ...@@ -15,19 +15,13 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck #include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck
#include "ui/gfx/color_palette.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/skia_util.h"
#include "ui/message_center/message_center_export.h" #include "ui/message_center/message_center_export.h"
#include "ui/message_center/notification_delegate.h" #include "ui/message_center/notification_delegate.h"
#include "ui/message_center/notification_types.h" #include "ui/message_center/notification_types.h"
#include "ui/message_center/notifier_settings.h" #include "ui/message_center/notifier_settings.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace gfx {
struct VectorIcon;
} // namespace gfx
namespace message_center { namespace message_center {
namespace mojom { namespace mojom {
...@@ -51,8 +45,6 @@ enum class ButtonType { ...@@ -51,8 +45,6 @@ enum class ButtonType {
TEXT TEXT
}; };
enum class SystemNotificationWarningLevel { NORMAL, WARNING, CRITICAL_WARNING };
// Represents a button to be shown as part of a notification. // Represents a button to be shown as part of a notification.
struct MESSAGE_CENTER_EXPORT ButtonInfo { struct MESSAGE_CENTER_EXPORT ButtonInfo {
explicit ButtonInfo(const base::string16& title); explicit ButtonInfo(const base::string16& title);
...@@ -149,12 +141,6 @@ class MESSAGE_CENTER_EXPORT RichNotificationData { ...@@ -149,12 +141,6 @@ class MESSAGE_CENTER_EXPORT RichNotificationData {
// An accessible description of the notification's contents. // An accessible description of the notification's contents.
base::string16 accessible_name; base::string16 accessible_name;
// Unified theme color used in new style notification.
// Usually, it should not be set directly.
// For system notification, CreateSystemNotification with
// SystemNotificationWarningLevel should be used.
SkColor accent_color = SK_ColorTRANSPARENT;
}; };
class MESSAGE_CENTER_EXPORT Notification { class MESSAGE_CENTER_EXPORT Notification {
...@@ -359,11 +345,6 @@ class MESSAGE_CENTER_EXPORT Notification { ...@@ -359,11 +345,6 @@ class MESSAGE_CENTER_EXPORT Notification {
return optional_fields_.accessible_name; return optional_fields_.accessible_name;
} }
SkColor accent_color() const { return optional_fields_.accent_color; }
void set_accent_color(SkColor accent_color) {
optional_fields_.accent_color = accent_color;
}
NotificationDelegate* delegate() const { return delegate_.get(); } NotificationDelegate* delegate() const { return delegate_.get(); }
const RichNotificationData& rich_notification_data() const { const RichNotificationData& rich_notification_data() const {
...@@ -383,13 +364,6 @@ class MESSAGE_CENTER_EXPORT Notification { ...@@ -383,13 +364,6 @@ class MESSAGE_CENTER_EXPORT Notification {
// Helper method to create a simple system notification. |click_callback| // Helper method to create a simple system notification. |click_callback|
// will be invoked when the notification is clicked. // will be invoked when the notification is clicked.
//
// It should only be used for critical notification, as SetSystemPriority and
// CRITICAL_WARNING color are set inside, which means the notification would
// not go away without user interaction.
//
// TODO(tetsui): Add a function parameter |small_image| of gfx::VectorIcon, so
// display source of critical system notification is illustrated by icon.
static std::unique_ptr<Notification> CreateSystemNotification( static std::unique_ptr<Notification> CreateSystemNotification(
const std::string& notification_id, const std::string& notification_id,
const base::string16& title, const base::string16& title,
...@@ -398,25 +372,6 @@ class MESSAGE_CENTER_EXPORT Notification { ...@@ -398,25 +372,6 @@ class MESSAGE_CENTER_EXPORT Notification {
const std::string& system_component_id, const std::string& system_component_id,
const base::Closure& click_callback); const base::Closure& click_callback);
// Factory method to create all kinds of notifications generated by system,
// from normal priority ones to critical priority ones.
// |small_image| is a small icon show on the upper left header to illustrate
// |display_source| of the notification.
// One specified in the |optional_fields| is overridden.
static std::unique_ptr<Notification> CreateSystemNotification(
NotificationType type,
const std::string& id,
const base::string16& title,
const base::string16& message,
const gfx::Image& icon,
const base::string16& display_source,
const GURL& origin_url,
const NotifierId& notifier_id,
const RichNotificationData& optional_fields,
scoped_refptr<NotificationDelegate> delegate,
const gfx::VectorIcon& small_image,
SystemNotificationWarningLevel color_type);
protected: protected:
// The type of notification we'd like displayed. // The type of notification we'd like displayed.
NotificationType type_; NotificationType type_;
......
...@@ -68,6 +68,8 @@ class ExpandButton : public views::ImageView { ...@@ -68,6 +68,8 @@ class ExpandButton : public views::ImageView {
}; };
ExpandButton::ExpandButton() { ExpandButton::ExpandButton() {
SetImage(gfx::CreateVectorIcon(kNotificationExpandMoreIcon, kExpandIconSize,
gfx::kChromeIconGrey));
focus_painter_ = views::Painter::CreateSolidFocusPainter( focus_painter_ = views::Painter::CreateSolidFocusPainter(
kFocusBorderColor, gfx::Insets(1, 2, 2, 2)); kFocusBorderColor, gfx::Insets(1, 2, 2, 2));
SetFocusBehavior(FocusBehavior::ALWAYS); SetFocusBehavior(FocusBehavior::ALWAYS);
...@@ -157,7 +159,6 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) ...@@ -157,7 +159,6 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener)
app_name_view_ = new views::Label(base::string16()); app_name_view_ = new views::Label(base::string16());
app_name_view_->SetFontList(font_list); app_name_view_->SetFontList(font_list);
app_name_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); app_name_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
app_name_view_->SetEnabledColor(accent_color_);
app_info_container->AddChildView(app_name_view_); app_info_container->AddChildView(app_name_view_);
// Summary text divider // Summary text divider
...@@ -192,7 +193,6 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) ...@@ -192,7 +193,6 @@ NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener)
// Expand button view // Expand button view
expand_button_ = new ExpandButton(); expand_button_ = new ExpandButton();
SetExpanded(is_expanded_);
app_info_container->AddChildView(expand_button_); app_info_container->AddChildView(expand_button_);
// Spacer between left-aligned views and right-aligned views // Spacer between left-aligned views and right-aligned views
...@@ -224,10 +224,6 @@ void NotificationHeaderView::SetAppIcon(const gfx::ImageSkia& img) { ...@@ -224,10 +224,6 @@ void NotificationHeaderView::SetAppIcon(const gfx::ImageSkia& img) {
app_icon_view_->SetImage(img); app_icon_view_->SetImage(img);
} }
void NotificationHeaderView::ClearAppIcon() {
app_icon_view_->SetImage(gfx::CreateVectorIcon(kProductIcon, accent_color_));
}
void NotificationHeaderView::SetAppName(const base::string16& name) { void NotificationHeaderView::SetAppName(const base::string16& name) {
app_name_view_->SetText(name); app_name_view_->SetText(name);
} }
...@@ -281,10 +277,10 @@ void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) { ...@@ -281,10 +277,10 @@ void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) {
} }
void NotificationHeaderView::SetExpanded(bool expanded) { void NotificationHeaderView::SetExpanded(bool expanded) {
is_expanded_ = expanded; expand_button_->SetImage(
expand_button_->SetImage(gfx::CreateVectorIcon( gfx::CreateVectorIcon(
expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon,
kExpandIconSize, accent_color_)); kExpandIconSize, gfx::kChromeIconGrey));
} }
void NotificationHeaderView::SetSettingsButtonEnabled(bool enabled) { void NotificationHeaderView::SetSettingsButtonEnabled(bool enabled) {
...@@ -308,12 +304,6 @@ void NotificationHeaderView::SetControlButtonsVisible(bool visible) { ...@@ -308,12 +304,6 @@ void NotificationHeaderView::SetControlButtonsVisible(bool visible) {
} }
} }
void NotificationHeaderView::SetAccentColor(SkColor color) {
accent_color_ = color;
app_name_view_->SetEnabledColor(accent_color_);
SetExpanded(is_expanded_);
}
bool NotificationHeaderView::IsExpandButtonEnabled() { bool NotificationHeaderView::IsExpandButtonEnabled() {
return expand_button_->visible(); return expand_button_->visible();
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_HEADER_VIEW_H_ #define UI_MESSAGE_CENTER_VIEWS_NOTIFICATION_HEADER_VIEW_H_
#include "base/macros.h" #include "base/macros.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/views/padded_button.h" #include "ui/message_center/views/padded_button.h"
#include "ui/views/controls/button/custom_button.h" #include "ui/views/controls/button/custom_button.h"
...@@ -31,10 +30,6 @@ class NotificationHeaderView : public views::CustomButton { ...@@ -31,10 +30,6 @@ class NotificationHeaderView : public views::CustomButton {
void SetSettingsButtonEnabled(bool enabled); void SetSettingsButtonEnabled(bool enabled);
void SetCloseButtonEnabled(bool enabled); void SetCloseButtonEnabled(bool enabled);
void SetControlButtonsVisible(bool visible); void SetControlButtonsVisible(bool visible);
// Set the unified theme color used among the app icon, app name, and expand
// button.
void SetAccentColor(SkColor color);
void ClearAppIcon();
void ClearProgress(); void ClearProgress();
void ClearOverflowIndicator(); void ClearOverflowIndicator();
void ClearTimestamp(); void ClearTimestamp();
...@@ -58,8 +53,6 @@ class NotificationHeaderView : public views::CustomButton { ...@@ -58,8 +53,6 @@ class NotificationHeaderView : public views::CustomButton {
// Update visibility for both |summary_text_view_| and |timestamp_view_|. // Update visibility for both |summary_text_view_| and |timestamp_view_|.
void UpdateSummaryTextVisibility(); void UpdateSummaryTextVisibility();
SkColor accent_color_ = message_center::kNotificationDefaultAccentColor;
views::Label* app_name_view_ = nullptr; views::Label* app_name_view_ = nullptr;
views::Label* summary_text_divider_ = nullptr; views::Label* summary_text_divider_ = nullptr;
views::Label* summary_text_view_ = nullptr; views::Label* summary_text_view_ = nullptr;
...@@ -76,7 +69,6 @@ class NotificationHeaderView : public views::CustomButton { ...@@ -76,7 +69,6 @@ class NotificationHeaderView : public views::CustomButton {
bool has_progress_ = false; bool has_progress_ = false;
bool has_overflow_indicator_ = false; bool has_overflow_indicator_ = false;
bool has_timestamp_ = false; bool has_timestamp_ = false;
bool is_expanded_ = false;
DISALLOW_COPY_AND_ASSIGN(NotificationHeaderView); DISALLOW_COPY_AND_ASSIGN(NotificationHeaderView);
}; };
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/gfx/text_elider.h" #include "ui/gfx/text_elider.h"
...@@ -55,6 +56,10 @@ constexpr gfx::Insets kStatusTextPadding(4, 0, 0, 0); ...@@ -55,6 +56,10 @@ constexpr gfx::Insets kStatusTextPadding(4, 0, 0, 0);
constexpr gfx::Size kActionButtonMinSize(88, 32); constexpr gfx::Size kActionButtonMinSize(88, 32);
constexpr gfx::Size kIconViewSize(30, 30); constexpr gfx::Size kIconViewSize(30, 30);
// Foreground of small icon image.
constexpr SkColor kSmallImageBackgroundColor = SK_ColorWHITE;
// Background of small icon image.
const SkColor kSmallImageColor = SkColorSetRGB(0x43, 0x43, 0x43);
// Background of inline actions area. // Background of inline actions area.
const SkColor kActionsRowBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee); const SkColor kActionsRowBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee);
// Base ink drop color of action buttons. // Base ink drop color of action buttons.
...@@ -78,6 +83,37 @@ constexpr int kMessageViewWidth = ...@@ -78,6 +83,37 @@ constexpr int kMessageViewWidth =
message_center::kNotificationWidth - kIconViewSize.width() - message_center::kNotificationWidth - kIconViewSize.width() -
kContentRowPadding.left() - kContentRowPadding.right(); kContentRowPadding.left() - kContentRowPadding.right();
const gfx::ImageSkia CreateSolidColorImage(int width,
int height,
SkColor color) {
SkBitmap bitmap;
bitmap.allocN32Pixels(width, height);
bitmap.eraseColor(color);
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
}
// Take the alpha channel of icon, mask it with the foreground,
// then add the masked foreground on top of the background
const gfx::ImageSkia GetMaskedIcon(const gfx::ImageSkia& icon) {
int width = icon.width();
int height = icon.height();
// Background color grey
const gfx::ImageSkia background = CreateSolidColorImage(
width, height, message_center::kSmallImageBackgroundColor);
// Foreground color white
const gfx::ImageSkia foreground =
CreateSolidColorImage(width, height, message_center::kSmallImageColor);
const gfx::ImageSkia masked_small_image =
gfx::ImageSkiaOperations::CreateMaskedImage(foreground, icon);
return gfx::ImageSkiaOperations::CreateSuperimposedImage(background,
masked_small_image);
}
const gfx::ImageSkia GetProductIcon() {
return gfx::CreateVectorIcon(kProductIcon, kSmallImageColor);
}
// ItemView //////////////////////////////////////////////////////////////////// // ItemView ////////////////////////////////////////////////////////////////////
// ItemViews are responsible for drawing each list notification item's title and // ItemViews are responsible for drawing each list notification item's title and
...@@ -468,10 +504,6 @@ void NotificationViewMD::RequestFocusOnCloseButton() { ...@@ -468,10 +504,6 @@ void NotificationViewMD::RequestFocusOnCloseButton() {
void NotificationViewMD::CreateOrUpdateContextTitleView( void NotificationViewMD::CreateOrUpdateContextTitleView(
const Notification& notification) { const Notification& notification) {
header_row_->SetAppName(notification.display_source()); header_row_->SetAppName(notification.display_source());
header_row_->SetAccentColor(
notification.accent_color() == SK_ColorTRANSPARENT
? message_center::kNotificationDefaultAccentColor
: notification.accent_color());
header_row_->SetTimestamp(notification.timestamp()); header_row_->SetTimestamp(notification.timestamp());
} }
...@@ -655,10 +687,11 @@ void NotificationViewMD::CreateOrUpdateIconView( ...@@ -655,10 +687,11 @@ void NotificationViewMD::CreateOrUpdateIconView(
void NotificationViewMD::CreateOrUpdateSmallIconView( void NotificationViewMD::CreateOrUpdateSmallIconView(
const Notification& notification) { const Notification& notification) {
if (notification.small_image().IsEmpty()) gfx::ImageSkia icon =
header_row_->ClearAppIcon(); notification.small_image().IsEmpty()
else ? GetProductIcon()
header_row_->SetAppIcon(notification.small_image().AsImageSkia()); : GetMaskedIcon(notification.small_image().AsImageSkia());
header_row_->SetAppIcon(icon);
} }
void NotificationViewMD::CreateOrUpdateImageView( void NotificationViewMD::CreateOrUpdateImageView(
...@@ -727,12 +760,6 @@ void NotificationViewMD::CreateOrUpdateActionButtonViews( ...@@ -727,12 +760,6 @@ void NotificationViewMD::CreateOrUpdateActionButtonViews(
action_buttons_[i]->SchedulePaint(); action_buttons_[i]->SchedulePaint();
action_buttons_[i]->Layout(); action_buttons_[i]->Layout();
} }
// Change action button color to the accent color.
action_buttons_[i]->SetEnabledTextColors(notification.accent_color() ==
SK_ColorTRANSPARENT
? kActionButtonTextColor
: notification.accent_color());
} }
// Inherit mouse hover state when action button views reset. // Inherit mouse hover state when action button views reset.
......
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