Commit 1b9fc29e authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Make SetIsNested only called on Chrome OS.

SetIsNested should only be called when MessageView is in
MessageCenterView. However, there was minor exception that it's called
on Aero enabled Windows.

As a result, shadow will be removed on Aero enabled Windows (Win 7).
The shadow was already removed on Win8 & 10, so it should be an
acceptable minor change.

TEST=manual
BUG=none

Change-Id: I1d252553cce7da5027ad0c8d5ce629351ab1ff2c
Reviewed-on: https://chromium-review.googlesource.com/1196290
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587960}
parent ea29e693
......@@ -559,8 +559,9 @@ void MessageCenterView::OnViewPreferredSizeChanged(views::View* observed_view) {
void MessageCenterView::AddNotificationAt(const Notification& notification,
int index) {
MessageView* view = message_center::MessageViewFactory::Create(
notification, false); // Not top-level.
MessageView* view = message_center::MessageViewFactory::Create(notification);
// Not top-level.
view->SetIsNested();
view->AddObserver(this);
view->set_scroller(scroller_);
message_list_view_->AddNotificationAt(view, index);
......
......@@ -169,7 +169,7 @@ class ArcNotificationContentViewTest : public AshTestBase {
CreateNotificationView(const Notification& notification) {
std::unique_ptr<ArcNotificationView> notification_view(
static_cast<ArcNotificationView*>(
message_center::MessageViewFactory::Create(notification, true)));
message_center::MessageViewFactory::Create(notification)));
notification_view->set_owned_by_client();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
......
......@@ -73,7 +73,7 @@ class ArcNotificationViewTest : public AshTestBase {
std::unique_ptr<Notification> notification = CreateSimpleNotification();
notification_view_.reset(static_cast<ArcNotificationView*>(
message_center::MessageViewFactory::Create(*notification, true)));
message_center::MessageViewFactory::Create(*notification)));
notification_view_->set_owned_by_client();
surface_ = std::make_unique<MockArcNotificationSurface>(
kDefaultNotificationKey, Shell::Get()->aura_env());
......
......@@ -342,8 +342,8 @@ void UnifiedMessageCenterView::Update() {
void UnifiedMessageCenterView::AddNotificationAt(
const Notification& notification,
int index) {
MessageView* view = message_center::MessageViewFactory::Create(
notification, /*top-level=*/false);
MessageView* view = message_center::MessageViewFactory::Create(notification);
view->SetIsNested();
view->AddObserver(this);
view->AddSlideObserver(message_list_view_);
view->set_scroller(scroller_);
......
......@@ -31,7 +31,7 @@ namespace message_center {
MessagePopupView::MessagePopupView(const Notification& notification,
PopupAlignmentDelegate* alignment_delegate,
MessagePopupCollection* popup_collection)
: message_view_(MessageViewFactory::Create(notification, true)),
: message_view_(MessageViewFactory::Create(notification)),
alignment_delegate_(alignment_delegate),
popup_collection_(popup_collection),
a11y_feedback_on_init_(
......
......@@ -34,8 +34,6 @@ namespace message_center {
namespace {
const SkColor kBorderColor = SkColorSetARGB(0x1F, 0x0, 0x0, 0x0);
const int kShadowCornerRadius = 0;
const int kShadowElevation = 2;
// Creates a text for spoken feedback from the data contained in the
// notification.
......@@ -109,20 +107,8 @@ void MessageView::SetIsNested() {
// Update enability since it might be changed by "is_nested" flag.
slide_out_controller_.set_slide_mode(CalculateSlideMode());
if (ShouldRoundMessageViewCorners()) {
SetBorder(views::CreateRoundedRectBorder(
kNotificationBorderThickness, kNotificationCornerRadius, kBorderColor));
} else {
const auto& shadow =
gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius);
gfx::Insets ninebox_insets =
gfx::ShadowValue::GetBlurRegion(shadow.values) +
gfx::Insets(kShadowCornerRadius);
SetBorder(views::CreateBorderPainter(
views::Painter::CreateImagePainter(shadow.ninebox_image,
ninebox_insets),
-gfx::ShadowValue::GetMargin(shadow.values)));
}
SetBorder(views::CreateRoundedRectBorder(
kNotificationBorderThickness, kNotificationCornerRadius, kBorderColor));
if (!base::FeatureList::IsEnabled(message_center::kNotificationSwipeControl))
return;
......
......@@ -12,10 +12,6 @@
#include "ui/message_center/views/notification_view.h"
#include "ui/message_center/views/notification_view_md.h"
#if defined(OS_WIN)
#include "ui/base/win/shell.h"
#endif
namespace message_center {
namespace {
......@@ -26,8 +22,7 @@ base::LazyInstance<MessageViewFactory::CustomMessageViewFactoryFunction>::Leaky
} // namespace
// static
MessageView* MessageViewFactory::Create(const Notification& notification,
bool top_level) {
MessageView* MessageViewFactory::Create(const Notification& notification) {
MessageView* notification_view = nullptr;
switch (notification.type()) {
case NOTIFICATION_TYPE_BASE_FORMAT:
......@@ -56,21 +51,6 @@ MessageView* MessageViewFactory::Create(const Notification& notification,
<< ". Falling back to simple notification type.";
notification_view = new NotificationView(notification);
}
#if defined(OS_LINUX)
// Don't create shadows for notification toasts on Linux or CrOS.
if (top_level)
return notification_view;
#endif
#if defined(OS_WIN)
// Don't create shadows for notifications on Windows under classic theme.
if (top_level && !ui::win::IsAeroGlassEnabled()) {
return notification_view;
}
#endif // OS_WIN
notification_view->SetIsNested();
return notification_view;
}
......
......@@ -27,7 +27,7 @@ class MESSAGE_CENTER_EXPORT MessageViewFactory {
typedef base::Callback<std::unique_ptr<MessageView>(const Notification&)>
CustomMessageViewFactoryFunction;
static MessageView* Create(const Notification& notification, bool top_level);
static MessageView* Create(const Notification& notification);
// Sets the function that will be invoked to create a custom notification
// view. This should be a repeating callback. It's an error to attempt to show
......
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