| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/arc/notification/arc_custom_notification_view.h" | 5 #include "ui/arc/notification/arc_custom_notification_view.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "components/exo/notification_surface.h" | 10 #include "components/exo/notification_surface.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} | 152 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} |
| 153 | 153 |
| 154 ArcCustomNotificationView* const owner_; | 154 ArcCustomNotificationView* const owner_; |
| 155 bool sliding_ = false; | 155 bool sliding_ = false; |
| 156 std::unique_ptr<ui::LayerTreeOwner> surface_copy_; | 156 std::unique_ptr<ui::LayerTreeOwner> surface_copy_; |
| 157 | 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(SlideHelper); | 158 DISALLOW_COPY_AND_ASSIGN(SlideHelper); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 class ArcCustomNotificationView::ControlButton |
| 162 : public message_center::PaddedButton { |
| 163 public: |
| 164 explicit ControlButton(ArcCustomNotificationView* owner) |
| 165 : message_center::PaddedButton(owner), owner_(owner) {} |
| 166 |
| 167 void OnFocus() override { |
| 168 message_center::PaddedButton::OnFocus(); |
| 169 owner_->UpdateControlButtonsVisibility(); |
| 170 } |
| 171 |
| 172 void OnBlur() override { |
| 173 message_center::PaddedButton::OnBlur(); |
| 174 owner_->UpdateControlButtonsVisibility(); |
| 175 } |
| 176 |
| 177 void HideInkDrop() { AnimateInkDrop(views::InkDropState::HIDDEN, nullptr); } |
| 178 |
| 179 private: |
| 180 ArcCustomNotificationView* const owner_; |
| 181 |
| 182 DISALLOW_COPY_AND_ASSIGN(ControlButton); |
| 183 }; |
| 184 |
| 161 class ArcCustomNotificationView::ContentViewDelegate | 185 class ArcCustomNotificationView::ContentViewDelegate |
| 162 : public message_center::CustomNotificationContentViewDelegate { | 186 : public message_center::CustomNotificationContentViewDelegate { |
| 163 public: | 187 public: |
| 164 explicit ContentViewDelegate(ArcCustomNotificationView* owner) | 188 explicit ContentViewDelegate(ArcCustomNotificationView* owner) |
| 165 : owner_(owner) {} | 189 : owner_(owner) {} |
| 166 | 190 |
| 167 bool IsCloseButtonFocused() const override { | 191 bool IsCloseButtonFocused() const override { |
| 168 if (owner_->close_button_ == nullptr) | 192 if (owner_->close_button_ == nullptr) |
| 169 return false; | 193 return false; |
| 170 return owner_->close_button_->HasFocus(); | 194 return owner_->close_button_->HasFocus(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 183 void UpdateControlButtonsVisibility() override { | 207 void UpdateControlButtonsVisibility() override { |
| 184 owner_->UpdateControlButtonsVisibility(); | 208 owner_->UpdateControlButtonsVisibility(); |
| 185 } | 209 } |
| 186 | 210 |
| 187 private: | 211 private: |
| 188 ArcCustomNotificationView* const owner_; | 212 ArcCustomNotificationView* const owner_; |
| 189 | 213 |
| 190 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); | 214 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); |
| 191 }; | 215 }; |
| 192 | 216 |
| 193 class ArcCustomNotificationView::ControlButton | |
| 194 : public message_center::PaddedButton { | |
| 195 public: | |
| 196 explicit ControlButton(ArcCustomNotificationView* owner) | |
| 197 : message_center::PaddedButton(owner), owner_(owner) {} | |
| 198 | |
| 199 void OnFocus() override { | |
| 200 message_center::PaddedButton::OnFocus(); | |
| 201 owner_->UpdateControlButtonsVisibility(); | |
| 202 } | |
| 203 | |
| 204 void OnBlur() override { | |
| 205 message_center::PaddedButton::OnBlur(); | |
| 206 owner_->UpdateControlButtonsVisibility(); | |
| 207 } | |
| 208 | |
| 209 private: | |
| 210 ArcCustomNotificationView* const owner_; | |
| 211 }; | |
| 212 | |
| 213 ArcCustomNotificationView::ArcCustomNotificationView( | 217 ArcCustomNotificationView::ArcCustomNotificationView( |
| 214 ArcCustomNotificationItem* item) | 218 ArcCustomNotificationItem* item) |
| 215 : item_(item), | 219 : item_(item), |
| 216 notification_key_(item->notification_key()), | 220 notification_key_(item->notification_key()), |
| 217 event_forwarder_(new EventForwarder(this)) { | 221 event_forwarder_(new EventForwarder(this)) { |
| 218 SetFocusBehavior(FocusBehavior::ALWAYS); | 222 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 219 | 223 |
| 220 item_->IncrementWindowRefCount(); | 224 item_->IncrementWindowRefCount(); |
| 221 item_->AddObserver(this); | 225 item_->AddObserver(this); |
| 222 | 226 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 537 |
| 534 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 538 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
| 535 const ui::Event& event) { | 539 const ui::Event& event) { |
| 536 if (item_ && !item_->pinned() && sender == close_button_) { | 540 if (item_ && !item_->pinned() && sender == close_button_) { |
| 537 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, | 541 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, |
| 538 parent()->GetClassName()); | 542 parent()->GetClassName()); |
| 539 static_cast<message_center::CustomNotificationView*>(parent()) | 543 static_cast<message_center::CustomNotificationView*>(parent()) |
| 540 ->OnCloseButtonPressed(); | 544 ->OnCloseButtonPressed(); |
| 541 } | 545 } |
| 542 if (item_ && settings_button_ && sender == settings_button_) { | 546 if (item_ && settings_button_ && sender == settings_button_) { |
| 547 settings_button_->HideInkDrop(); |
| 543 item_->OpenSettings(); | 548 item_->OpenSettings(); |
| 544 } | 549 } |
| 545 } | 550 } |
| 546 | 551 |
| 547 void ArcCustomNotificationView::OnWindowBoundsChanged( | 552 void ArcCustomNotificationView::OnWindowBoundsChanged( |
| 548 aura::Window* window, | 553 aura::Window* window, |
| 549 const gfx::Rect& old_bounds, | 554 const gfx::Rect& old_bounds, |
| 550 const gfx::Rect& new_bounds) { | 555 const gfx::Rect& new_bounds) { |
| 551 if (in_layout_) | 556 if (in_layout_) |
| 552 return; | 557 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 583 | 588 |
| 584 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 589 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
| 585 exo::NotificationSurface* surface) { | 590 exo::NotificationSurface* surface) { |
| 586 if (surface->notification_id() != notification_key_) | 591 if (surface->notification_id() != notification_key_) |
| 587 return; | 592 return; |
| 588 | 593 |
| 589 SetSurface(nullptr); | 594 SetSurface(nullptr); |
| 590 } | 595 } |
| 591 | 596 |
| 592 } // namespace arc | 597 } // namespace arc |
| OLD | NEW |