Index: ui/arc/notification/arc_custom_notification_view.cc |
diff --git a/ui/arc/notification/arc_custom_notification_view.cc b/ui/arc/notification/arc_custom_notification_view.cc |
index cd5f6c1359a7cf665ef9924cb7b7d0fa42b97b52..d4e2faae809e56a859dd488894794c3cc0df37ea 100644 |
--- a/ui/arc/notification/arc_custom_notification_view.cc |
+++ b/ui/arc/notification/arc_custom_notification_view.cc |
@@ -9,6 +9,7 @@ |
#include "third_party/skia/include/core/SkColor.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
+#include "ui/message_center/message_center_style.h" |
#include "ui/resources/grit/ui_resources.h" |
#include "ui/strings/grit/ui_strings.h" |
#include "ui/views/background.h" |
@@ -80,17 +81,39 @@ void ArcCustomNotificationView::ViewHierarchyChanged( |
if (!widget || !surface_ || !details.is_add) |
return; |
- SetPreferredSize(surface_->GetSize()); |
+ gfx::Size preferred_size = surface_->GetSize(); |
+ if (preferred_size.width() != message_center::kNotificationWidth) { |
+ const float scale = static_cast<float>(message_center::kNotificationWidth) / |
+ preferred_size.width(); |
+ preferred_size.SetSize(message_center::kNotificationWidth, |
+ preferred_size.height() * scale); |
+ } |
+ |
+ SetPreferredSize(preferred_size); |
Attach(surface_->window()); |
} |
void ArcCustomNotificationView::Layout() { |
views::NativeViewHost::Layout(); |
- if (!floating_close_button_widget_ || !surface_ || !GetWidget()) |
+ if (!surface_ || !GetWidget()) |
+ return; |
+ |
+ // Scale notification surface if necessary. |
+ gfx::Transform transform; |
+ const gfx::Size surface_size = surface_->GetSize(); |
+ const gfx::Size contents_size = GetContentsBounds().size(); |
+ if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) { |
+ transform.Scale( |
+ static_cast<float>(contents_size.width()) / surface_size.width(), |
+ static_cast<float>(contents_size.height()) / surface_size.height()); |
+ } |
+ surface_->window()->SetTransform(transform); |
+ |
+ if (!floating_close_button_widget_) |
return; |
- gfx::Rect surface_local_bounds(surface_->window()->bounds().size()); |
+ gfx::Rect surface_local_bounds(surface_->GetSize()); |
gfx::Rect close_button_bounds(floating_close_button_->GetPreferredSize()); |
close_button_bounds.set_x(surface_local_bounds.right() - |
close_button_bounds.width()); |