Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Unified Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2845003002: Merge ArcNotificationItem and ArcCustomNotificationItem (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0c8c2ea404313552bb7e8ac750756954ab1e9fad..54f498f912a05b332717ae68b22a60addfcac631 100644
--- a/ui/arc/notification/arc_custom_notification_view.cc
+++ b/ui/arc/notification/arc_custom_notification_view.cc
@@ -193,7 +193,7 @@ class ArcCustomNotificationView::ContentViewDelegate
bool IsPinned() const override {
if (!owner_->item_)
return false;
- return owner_->item_->pinned();
+ return owner_->item_->GetPinned();
}
void UpdateControlButtonsVisibility() override {
@@ -211,7 +211,7 @@ ArcCustomNotificationView::ControlButton::ControlButton(
: message_center::PaddedButton(owner), owner_(owner) {
if (owner_->item_) {
set_background(views::Background::CreateSolidBackground(
- GetControlButtonBackgroundColor(owner_->item_->shown_contents())));
+ GetControlButtonBackgroundColor(owner_->item_->GetShownContents())));
} else {
set_background(views::Background::CreateSolidBackground(
message_center::kControlButtonBackgroundColor));
@@ -228,21 +228,22 @@ void ArcCustomNotificationView::ControlButton::OnBlur() {
owner_->UpdateControlButtonsVisibility();
}
-ArcCustomNotificationView::ArcCustomNotificationView(
- ArcCustomNotificationItem* item)
+ArcCustomNotificationView::ArcCustomNotificationView(ArcNotificationItem* item)
: item_(item),
- notification_key_(item->notification_key()),
+ notification_key_(item->GetNotificationKey()),
event_forwarder_(new EventForwarder(this)) {
SetFocusBehavior(FocusBehavior::ALWAYS);
item_->IncrementWindowRefCount();
item_->AddObserver(this);
- ArcNotificationSurfaceManager::Get()->AddObserver(this);
- exo::NotificationSurface* surface =
- ArcNotificationSurfaceManager::Get()->GetSurface(notification_key_);
- if (surface)
- OnNotificationSurfaceAdded(surface);
+ if (ArcNotificationSurfaceManager::Get()) {
hidehiko 2017/05/01 12:29:17 Optional/nit: auto* surface_manager = ArcNotifica
yoshiki 2017/05/08 06:24:52 Done.
+ ArcNotificationSurfaceManager::Get()->AddObserver(this);
+ exo::NotificationSurface* surface =
+ ArcNotificationSurfaceManager::Get()->GetSurface(notification_key_);
+ if (surface)
+ OnNotificationSurfaceAdded(surface);
+ }
// Create a layer as an anchor to insert surface copy during a slide.
SetPaintToLayer();
@@ -310,7 +311,7 @@ void ArcCustomNotificationView::MaybeCreateFloatingControlButtons() {
if (item_->IsOpeningSettingsSupported())
CreateSettingsButton();
- if (!item_->pinned())
+ if (!item_->GetPinned())
CreateCloseButton();
views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL);
@@ -360,8 +361,8 @@ void ArcCustomNotificationView::SetSurface(exo::NotificationSurface* surface) {
void ArcCustomNotificationView::UpdatePreferredSize() {
gfx::Size preferred_size =
- surface_ ? surface_->GetSize() : item_ ? item_->snapshot().size()
- : gfx::Size();
+ surface_ ? surface_->GetSize()
hidehiko 2017/05/01 12:29:17 Optional/nit: Maybe better to avoid nested "?:" o
yoshiki 2017/05/08 06:24:52 Done.
+ : item_ ? item_->GetSnapshot().size() : gfx::Size();
if (preferred_size.IsEmpty())
return;
@@ -408,11 +409,11 @@ void ArcCustomNotificationView::UpdatePinnedState() {
if (!item_)
return;
- if (item_->pinned() && close_button_) {
+ if (item_->GetPinned() && close_button_) {
control_buttons_view_->RemoveChildView(close_button_.get());
close_button_.reset();
Layout();
- } else if (!item_->pinned() && !close_button_) {
+ } else if (!item_->GetPinned() && !close_button_) {
CreateCloseButton();
Layout();
}
@@ -466,11 +467,11 @@ bool ArcCustomNotificationView::ShouldUpdateControlButtonsColor() const {
if (settings_button_ &&
settings_button_->background()->get_color() !=
- GetControlButtonBackgroundColor(item_->shown_contents()))
+ GetControlButtonBackgroundColor(item_->GetShownContents()))
return true;
if (close_button_ &&
close_button_->background()->get_color() !=
- GetControlButtonBackgroundColor(item_->shown_contents()))
+ GetControlButtonBackgroundColor(item_->GetShownContents()))
return true;
return false;
}
@@ -555,11 +556,11 @@ void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) {
views::NativeViewHost::OnPaint(canvas);
// Bail if there is a |surface_| or no item or no snapshot image.
- if (surface_ || !item_ || item_->snapshot().isNull())
+ if (surface_ || !item_ || item_->GetSnapshot().isNull())
return;
const gfx::Rect contents_bounds = GetContentsBounds();
- canvas->DrawImageInt(item_->snapshot(), 0, 0, item_->snapshot().width(),
- item_->snapshot().height(), contents_bounds.x(),
+ canvas->DrawImageInt(item_->GetSnapshot(), 0, 0, item_->GetSnapshot().width(),
+ item_->GetSnapshot().height(), contents_bounds.x(),
contents_bounds.y(), contents_bounds.width(),
contents_bounds.height(), false);
}
@@ -634,7 +635,8 @@ bool ArcCustomNotificationView::OnMousePressed(const ui::MouseEvent& event) {
// event because the target of all events generated by automation API is set
// to nullptr.
if (event.IsOnlyLeftMouseButton() && item_ &&
- item_->expand_state() != mojom::ArcNotificationExpandState::FIXED_SIZE &&
+ item_->GetExpandState() !=
+ mojom::ArcNotificationExpandState::FIXED_SIZE &&
event.target() == nullptr) {
item_->ToggleExpansion();
return true;
@@ -644,7 +646,7 @@ bool ArcCustomNotificationView::OnMousePressed(const ui::MouseEvent& event) {
void ArcCustomNotificationView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
- if (item_ && !item_->pinned() && sender == close_button_.get()) {
+ if (item_ && !item_->GetPinned() && sender == close_button_.get()) {
CHECK_EQ(message_center::CustomNotificationView::kViewClassName,
parent()->GetClassName());
static_cast<message_center::CustomNotificationView*>(parent())
@@ -714,7 +716,7 @@ void ArcCustomNotificationView::AnimationProgressed(
if (item_) {
const SkColor target =
- GetControlButtonBackgroundColor(item_->shown_contents());
+ GetControlButtonBackgroundColor(item_->GetShownContents());
const SkColor start =
target == message_center::kControlButtonBackgroundColor
? SK_ColorTRANSPARENT

Powered by Google App Engine
This is Rietveld 408576698