Commit 0f3475f0 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add default icon to notification settings.

In notification settings, there was no defualt icon for notifier
without favicon. As a result, the notifier texts are not aligend.

Before: http://screen/Dm5RpJ42F98
After: http://screen/0tx8h9G9GPb

TEST=manual
BUG=768736

Change-Id: Id0e1ebc674c39acac63036bee7d1fa91f0817e86
Reviewed-on: https://chromium-review.googlesource.com/686086Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504861}
parent 576bda00
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/message_center/public/cpp/message_center_constants.h" #include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/vector_icons.h"
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
#include "ui/views/background.h" #include "ui/views/background.h"
#include "ui/views/border.h" #include "ui/views/border.h"
...@@ -255,10 +256,6 @@ NotifierSettingsView::NotifierButton::NotifierButton( ...@@ -255,10 +256,6 @@ NotifierSettingsView::NotifierButton::NotifierButton(
DCHECK(provider_); DCHECK(provider_);
DCHECK(notifier_); DCHECK(notifier_);
// Since there may never be an icon (but that could change at a later time),
// we own the icon view here.
icon_view_->set_owned_by_client();
checkbox_->SetChecked(notifier_->enabled); checkbox_->SetChecked(notifier_->enabled);
checkbox_->set_listener(this); checkbox_->set_listener(this);
checkbox_->SetFocusBehavior(FocusBehavior::NEVER); checkbox_->SetFocusBehavior(FocusBehavior::NEVER);
...@@ -300,15 +297,15 @@ NotifierSettingsView::NotifierButton::~NotifierButton() {} ...@@ -300,15 +297,15 @@ NotifierSettingsView::NotifierButton::~NotifierButton() {}
void NotifierSettingsView::NotifierButton::UpdateIconImage( void NotifierSettingsView::NotifierButton::UpdateIconImage(
const gfx::Image& icon) { const gfx::Image& icon) {
bool has_icon_view = false;
notifier_->icon = icon; notifier_->icon = icon;
if (!icon.IsEmpty()) { if (icon.IsEmpty()) {
icon_view_->SetImage(gfx::CreateVectorIcon(
message_center::kProductIcon, kEntryIconSize, gfx::kChromeIconGrey));
} else {
icon_view_->SetImage(icon.ToImageSkia()); icon_view_->SetImage(icon.ToImageSkia());
icon_view_->SetImageSize(gfx::Size(kEntryIconSize, kEntryIconSize)); icon_view_->SetImageSize(gfx::Size(kEntryIconSize, kEntryIconSize));
has_icon_view = true;
} }
GridChanged(ShouldHaveLearnMoreButton(), has_icon_view); GridChanged(ShouldHaveLearnMoreButton());
} }
void NotifierSettingsView::NotifierButton::SetChecked(bool checked) { void NotifierSettingsView::NotifierButton::SetChecked(bool checked) {
...@@ -366,8 +363,7 @@ bool NotifierSettingsView::NotifierButton::ShouldHaveLearnMoreButton() const { ...@@ -366,8 +363,7 @@ bool NotifierSettingsView::NotifierButton::ShouldHaveLearnMoreButton() const {
return provider_->NotifierHasAdvancedSettings(notifier_->notifier_id); return provider_->NotifierHasAdvancedSettings(notifier_->notifier_id);
} }
void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more, void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more) {
bool has_icon_view) {
using views::ColumnSet; using views::ColumnSet;
using views::GridLayout; using views::GridLayout;
...@@ -379,12 +375,10 @@ void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more, ...@@ -379,12 +375,10 @@ void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more,
kComputedCheckboxSize, 0); kComputedCheckboxSize, 0);
cs->AddPaddingColumn(0, kInternalHorizontalSpacing); cs->AddPaddingColumn(0, kInternalHorizontalSpacing);
if (has_icon_view) { // Add a column for the icon.
// Add a column for the icon. cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::FIXED,
cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::FIXED, kEntryIconSize, 0);
kEntryIconSize, 0); cs->AddPaddingColumn(0, kInternalHorizontalSpacing);
cs->AddPaddingColumn(0, kInternalHorizontalSpacing);
}
// Add a column for the name. // Add a column for the name.
cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
...@@ -402,8 +396,7 @@ void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more, ...@@ -402,8 +396,7 @@ void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more,
layout->StartRow(0, 0); layout->StartRow(0, 0);
layout->AddView(checkbox_); layout->AddView(checkbox_);
if (has_icon_view) layout->AddView(icon_view_);
layout->AddView(icon_view_.get());
layout->AddView(name_view_); layout->AddView(name_view_);
if (has_learn_more) if (has_learn_more)
layout->AddView(learn_more_); layout->AddView(learn_more_);
......
...@@ -81,13 +81,11 @@ class ASH_EXPORT NotifierSettingsView ...@@ -81,13 +81,11 @@ class ASH_EXPORT NotifierSettingsView
bool ShouldHaveLearnMoreButton() const; bool ShouldHaveLearnMoreButton() const;
// Helper function to reset the layout when the view has substantially // Helper function to reset the layout when the view has substantially
// changed. // changed.
void GridChanged(bool has_learn_more, bool has_icon_view); void GridChanged(bool has_learn_more);
message_center::NotifierSettingsProvider* provider_; // Weak. message_center::NotifierSettingsProvider* provider_; // Weak.
std::unique_ptr<message_center::Notifier> notifier_; std::unique_ptr<message_center::Notifier> notifier_;
// |icon_view_| is owned by us because sometimes we don't leave it views::ImageView* icon_view_;
// in the view hierarchy.
std::unique_ptr<views::ImageView> icon_view_;
views::Label* name_view_; views::Label* name_view_;
views::Checkbox* checkbox_; views::Checkbox* checkbox_;
views::ImageButton* learn_more_; views::ImageButton* learn_more_;
......
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