| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 floating_control_buttons_widget_->GetRootView()); | 528 floating_control_buttons_widget_->GetRootView()); |
| 525 return nullptr; | 529 return nullptr; |
| 526 } | 530 } |
| 527 | 531 |
| 528 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 532 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
| 529 const ui::Event& event) { | 533 const ui::Event& event) { |
| 530 if (item_ && !item_->pinned() && sender == close_button_) { | 534 if (item_ && !item_->pinned() && sender == close_button_) { |
| 531 item_->CloseFromCloseButton(); | 535 item_->CloseFromCloseButton(); |
| 532 } | 536 } |
| 533 if (item_ && settings_button_ && sender == settings_button_) { | 537 if (item_ && settings_button_ && sender == settings_button_) { |
| 538 settings_button_->HideInkDrop(); |
| 534 item_->OpenSettings(); | 539 item_->OpenSettings(); |
| 535 } | 540 } |
| 536 } | 541 } |
| 537 | 542 |
| 538 void ArcCustomNotificationView::OnWindowBoundsChanged( | 543 void ArcCustomNotificationView::OnWindowBoundsChanged( |
| 539 aura::Window* window, | 544 aura::Window* window, |
| 540 const gfx::Rect& old_bounds, | 545 const gfx::Rect& old_bounds, |
| 541 const gfx::Rect& new_bounds) { | 546 const gfx::Rect& new_bounds) { |
| 542 if (in_layout_) | 547 if (in_layout_) |
| 543 return; | 548 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 574 | 579 |
| 575 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 580 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
| 576 exo::NotificationSurface* surface) { | 581 exo::NotificationSurface* surface) { |
| 577 if (surface->notification_id() != notification_key_) | 582 if (surface->notification_id() != notification_key_) |
| 578 return; | 583 return; |
| 579 | 584 |
| 580 SetSurface(nullptr); | 585 SetSurface(nullptr); |
| 581 } | 586 } |
| 582 | 587 |
| 583 } // namespace arc | 588 } // namespace arc |
| OLD | NEW |