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

Side by Side Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2870283002: Move message_center::CustomNotificationView to arc::ArcNotificationView (Closed)
Patch Set: Fixed test Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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"
11 #include "components/exo/surface.h" 11 #include "components/exo/surface.h"
12 #include "ui/accessibility/ax_action_data.h" 12 #include "ui/accessibility/ax_action_data.h"
13 #include "ui/arc/notification/arc_notification_view.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/compositor/layer_animation_observer.h" 16 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/events/event_handler.h" 17 #include "ui/events/event_handler.h"
17 #include "ui/gfx/animation/linear_animation.h" 18 #include "ui/gfx/animation/linear_animation.h"
18 #include "ui/gfx/animation/tween.h" 19 #include "ui/gfx/animation/tween.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/transform.h" 21 #include "ui/gfx/transform.h"
21 #include "ui/message_center/message_center_style.h" 22 #include "ui/message_center/message_center_style.h"
22 #include "ui/message_center/views/custom_notification_view.h"
23 #include "ui/message_center/views/toast_contents_view.h" 23 #include "ui/message_center/views/toast_contents_view.h"
24 #include "ui/strings/grit/ui_strings.h" 24 #include "ui/strings/grit/ui_strings.h"
25 #include "ui/views/background.h" 25 #include "ui/views/background.h"
26 #include "ui/views/focus/focus_manager.h" 26 #include "ui/views/focus/focus_manager.h"
27 #include "ui/views/layout/box_layout.h" 27 #include "ui/views/layout/box_layout.h"
28 #include "ui/views/painter.h" 28 #include "ui/views/painter.h"
29 #include "ui/views/widget/root_view.h" 29 #include "ui/views/widget/root_view.h"
30 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
31 #include "ui/wm/core/window_util.h" 31 #include "ui/wm/core/window_util.h"
32 32
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} 173 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {}
174 174
175 ArcCustomNotificationView* const owner_; 175 ArcCustomNotificationView* const owner_;
176 bool sliding_ = false; 176 bool sliding_ = false;
177 std::unique_ptr<ui::LayerTreeOwner> surface_copy_; 177 std::unique_ptr<ui::LayerTreeOwner> surface_copy_;
178 178
179 DISALLOW_COPY_AND_ASSIGN(SlideHelper); 179 DISALLOW_COPY_AND_ASSIGN(SlideHelper);
180 }; 180 };
181 181
182 class ArcCustomNotificationView::ContentViewDelegate 182 class ArcCustomNotificationView::ContentViewDelegate
183 : public message_center::CustomNotificationContentViewDelegate { 183 : public ArcNotificationContentViewDelegate {
184 public: 184 public:
185 explicit ContentViewDelegate(ArcCustomNotificationView* owner) 185 explicit ContentViewDelegate(ArcCustomNotificationView* owner)
186 : owner_(owner) {} 186 : owner_(owner) {}
187 187
188 bool IsCloseButtonFocused() const override { 188 bool IsCloseButtonFocused() const override {
189 if (!owner_->close_button_) 189 if (!owner_->close_button_)
190 return false; 190 return false;
191 return owner_->close_button_->HasFocus(); 191 return owner_->close_button_->HasFocus();
192 } 192 }
193 193
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 auto* surface_manager = ArcNotificationSurfaceManager::Get(); 258 auto* surface_manager = ArcNotificationSurfaceManager::Get();
259 if (surface_manager) 259 if (surface_manager)
260 surface_manager->RemoveObserver(this); 260 surface_manager->RemoveObserver(this);
261 if (item_) { 261 if (item_) {
262 item_->RemoveObserver(this); 262 item_->RemoveObserver(this);
263 item_->DecrementWindowRefCount(); 263 item_->DecrementWindowRefCount();
264 } 264 }
265 } 265 }
266 266
267 std::unique_ptr<message_center::CustomNotificationContentViewDelegate> 267 std::unique_ptr<ArcNotificationContentViewDelegate>
268 ArcCustomNotificationView::CreateContentViewDelegate() { 268 ArcCustomNotificationView::CreateContentViewDelegate() {
269 return base::MakeUnique<ArcCustomNotificationView::ContentViewDelegate>(this); 269 return base::MakeUnique<ArcCustomNotificationView::ContentViewDelegate>(this);
270 } 270 }
271 271
272 void ArcCustomNotificationView::CreateCloseButton() { 272 void ArcCustomNotificationView::CreateCloseButton() {
273 DCHECK(control_buttons_view_); 273 DCHECK(control_buttons_view_);
274 DCHECK(item_); 274 DCHECK(item_);
275 275
276 close_button_ = base::MakeUnique<ControlButton>(this); 276 close_button_ = base::MakeUnique<ControlButton>(this);
277 close_button_->SetImage(views::CustomButton::STATE_NORMAL, 277 close_button_->SetImage(views::CustomButton::STATE_NORMAL,
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 587
588 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) { 588 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) {
589 UpdateControlButtonsVisibility(); 589 UpdateControlButtonsVisibility();
590 } 590 }
591 591
592 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) { 592 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) {
593 UpdateControlButtonsVisibility(); 593 UpdateControlButtonsVisibility();
594 } 594 }
595 595
596 void ArcCustomNotificationView::OnFocus() { 596 void ArcCustomNotificationView::OnFocus() {
597 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, 597 CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName());
598 parent()->GetClassName());
599 598
600 NativeViewHost::OnFocus(); 599 NativeViewHost::OnFocus();
601 static_cast<message_center::CustomNotificationView*>(parent()) 600 static_cast<ArcNotificationView*>(parent())->OnContentFocused();
602 ->OnContentFocused();
603 } 601 }
604 602
605 void ArcCustomNotificationView::OnBlur() { 603 void ArcCustomNotificationView::OnBlur() {
606 if (!parent()) { 604 if (!parent()) {
607 // OnBlur may be called when this view is being removed. 605 // OnBlur may be called when this view is being removed.
608 return; 606 return;
609 } 607 }
610 608
611 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, 609 CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName());
612 parent()->GetClassName());
613 610
614 NativeViewHost::OnBlur(); 611 NativeViewHost::OnBlur();
615 static_cast<message_center::CustomNotificationView*>(parent()) 612 static_cast<ArcNotificationView*>(parent())->OnContentBlured();
616 ->OnContentBlured();
617 } 613 }
618 614
619 void ArcCustomNotificationView::ActivateToast() { 615 void ArcCustomNotificationView::ActivateToast() {
620 if (message_center::ToastContentsView::kViewClassName == 616 if (message_center::ToastContentsView::kViewClassName ==
621 parent()->parent()->GetClassName()) { 617 parent()->parent()->GetClassName()) {
622 static_cast<message_center::ToastContentsView*>(parent()->parent()) 618 static_cast<message_center::ToastContentsView*>(parent()->parent())
623 ->ActivateToast(); 619 ->ActivateToast();
624 } 620 }
625 } 621 }
626 622
627 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { 623 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() {
628 if (floating_control_buttons_widget_) 624 if (floating_control_buttons_widget_)
629 return static_cast<views::internal::RootView*>( 625 return static_cast<views::internal::RootView*>(
630 floating_control_buttons_widget_->GetRootView()); 626 floating_control_buttons_widget_->GetRootView());
631 return nullptr; 627 return nullptr;
632 } 628 }
633 629
634 bool ArcCustomNotificationView::HandleAccessibleAction( 630 bool ArcCustomNotificationView::HandleAccessibleAction(
635 const ui::AXActionData& action_data) { 631 const ui::AXActionData& action_data) {
636 if (item_ && action_data.action == ui::AX_ACTION_DO_DEFAULT) { 632 if (item_ && action_data.action == ui::AX_ACTION_DO_DEFAULT) {
637 item_->ToggleExpansion(); 633 item_->ToggleExpansion();
638 return true; 634 return true;
639 } 635 }
640 return false; 636 return false;
641 } 637 }
642 638
643 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, 639 void ArcCustomNotificationView::ButtonPressed(views::Button* sender,
644 const ui::Event& event) { 640 const ui::Event& event) {
645 if (item_ && !item_->GetPinned() && sender == close_button_.get()) { 641 if (item_ && !item_->GetPinned() && sender == close_button_.get()) {
646 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, 642 CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName());
647 parent()->GetClassName()); 643 static_cast<ArcNotificationView*>(parent())->OnCloseButtonPressed();
648 static_cast<message_center::CustomNotificationView*>(parent())
649 ->OnCloseButtonPressed();
650 } 644 }
651 if (item_ && settings_button_ && sender == settings_button_) { 645 if (item_ && settings_button_ && sender == settings_button_) {
652 item_->OpenSettings(); 646 item_->OpenSettings();
653 } 647 }
654 } 648 }
655 649
656 void ArcCustomNotificationView::OnWindowBoundsChanged( 650 void ArcCustomNotificationView::OnWindowBoundsChanged(
657 aura::Window* window, 651 aura::Window* window,
658 const gfx::Rect& old_bounds, 652 const gfx::Rect& old_bounds,
659 const gfx::Rect& new_bounds) { 653 const gfx::Rect& new_bounds) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 720 }
727 if (close_button_) { 721 if (close_button_) {
728 close_button_->set_background( 722 close_button_->set_background(
729 views::Background::CreateSolidBackground(current_color)); 723 views::Background::CreateSolidBackground(current_color));
730 close_button_->SchedulePaint(); 724 close_button_->SchedulePaint();
731 } 725 }
732 } 726 }
733 } 727 }
734 728
735 } // namespace arc 729 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698