Chromium Code Reviews| 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_; | |
|
yoshiki
2017/03/07 14:59:29
nit: Could you add DISALLOW_COPY_AND_ASSIGN(Contro
yhanada
2017/03/08 00:27:00
Done.
| |
| 181 }; | |
| 182 | |
| 161 class ArcCustomNotificationView::ContentViewDelegate | 183 class ArcCustomNotificationView::ContentViewDelegate |
| 162 : public message_center::CustomNotificationContentViewDelegate { | 184 : public message_center::CustomNotificationContentViewDelegate { |
| 163 public: | 185 public: |
| 164 explicit ContentViewDelegate(ArcCustomNotificationView* owner) | 186 explicit ContentViewDelegate(ArcCustomNotificationView* owner) |
| 165 : owner_(owner) {} | 187 : owner_(owner) {} |
| 166 | 188 |
| 167 bool IsCloseButtonFocused() const override { | 189 bool IsCloseButtonFocused() const override { |
| 168 if (owner_->close_button_ == nullptr) | 190 if (owner_->close_button_ == nullptr) |
| 169 return false; | 191 return false; |
| 170 return owner_->close_button_->HasFocus(); | 192 return owner_->close_button_->HasFocus(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 183 void UpdateControlButtonsVisibility() override { | 205 void UpdateControlButtonsVisibility() override { |
| 184 owner_->UpdateControlButtonsVisibility(); | 206 owner_->UpdateControlButtonsVisibility(); |
| 185 } | 207 } |
| 186 | 208 |
| 187 private: | 209 private: |
| 188 ArcCustomNotificationView* const owner_; | 210 ArcCustomNotificationView* const owner_; |
| 189 | 211 |
| 190 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); | 212 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); |
| 191 }; | 213 }; |
| 192 | 214 |
| 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( | 215 ArcCustomNotificationView::ArcCustomNotificationView( |
| 214 ArcCustomNotificationItem* item) | 216 ArcCustomNotificationItem* item) |
| 215 : item_(item), | 217 : item_(item), |
| 216 notification_key_(item->notification_key()), | 218 notification_key_(item->notification_key()), |
| 217 event_forwarder_(new EventForwarder(this)) { | 219 event_forwarder_(new EventForwarder(this)) { |
| 218 SetFocusBehavior(FocusBehavior::ALWAYS); | 220 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 219 | 221 |
| 220 item_->IncrementWindowRefCount(); | 222 item_->IncrementWindowRefCount(); |
| 221 item_->AddObserver(this); | 223 item_->AddObserver(this); |
| 222 | 224 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 532 |
| 531 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 533 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
| 532 const ui::Event& event) { | 534 const ui::Event& event) { |
| 533 if (item_ && !item_->pinned() && sender == close_button_) { | 535 if (item_ && !item_->pinned() && sender == close_button_) { |
| 534 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, | 536 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, |
| 535 parent()->GetClassName()); | 537 parent()->GetClassName()); |
| 536 static_cast<message_center::CustomNotificationView*>(parent()) | 538 static_cast<message_center::CustomNotificationView*>(parent()) |
| 537 ->OnCloseButtonPressed(); | 539 ->OnCloseButtonPressed(); |
| 538 } | 540 } |
| 539 if (item_ && settings_button_ && sender == settings_button_) { | 541 if (item_ && settings_button_ && sender == settings_button_) { |
| 542 settings_button_->HideInkDrop(); | |
| 540 item_->OpenSettings(); | 543 item_->OpenSettings(); |
| 541 } | 544 } |
| 542 } | 545 } |
| 543 | 546 |
| 544 void ArcCustomNotificationView::OnWindowBoundsChanged( | 547 void ArcCustomNotificationView::OnWindowBoundsChanged( |
| 545 aura::Window* window, | 548 aura::Window* window, |
| 546 const gfx::Rect& old_bounds, | 549 const gfx::Rect& old_bounds, |
| 547 const gfx::Rect& new_bounds) { | 550 const gfx::Rect& new_bounds) { |
| 548 if (in_layout_) | 551 if (in_layout_) |
| 549 return; | 552 return; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 580 | 583 |
| 581 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 584 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
| 582 exo::NotificationSurface* surface) { | 585 exo::NotificationSurface* surface) { |
| 583 if (surface->notification_id() != notification_key_) | 586 if (surface->notification_id() != notification_key_) |
| 584 return; | 587 return; |
| 585 | 588 |
| 586 SetSurface(nullptr); | 589 SetSurface(nullptr); |
| 587 } | 590 } |
| 588 | 591 |
| 589 } // namespace arc | 592 } // namespace arc |
| OLD | NEW |