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

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

Issue 2870283002: Move message_center::CustomNotificationView to arc::ArcNotificationView (Closed)
Patch Set: Addressed comment Created 3 years, 6 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {} 168 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) override {}
169 169
170 ArcCustomNotificationView* const owner_; 170 ArcCustomNotificationView* const owner_;
171 bool sliding_ = false; 171 bool sliding_ = false;
172 std::unique_ptr<ui::LayerTreeOwner> surface_copy_; 172 std::unique_ptr<ui::LayerTreeOwner> surface_copy_;
173 173
174 DISALLOW_COPY_AND_ASSIGN(SlideHelper); 174 DISALLOW_COPY_AND_ASSIGN(SlideHelper);
175 }; 175 };
176 176
177 class ArcCustomNotificationView::ContentViewDelegate 177 class ArcCustomNotificationView::ContentViewDelegate
178 : public message_center::CustomNotificationContentViewDelegate { 178 : public ArcNotificationContentViewDelegate {
179 public: 179 public:
180 explicit ContentViewDelegate(ArcCustomNotificationView* owner) 180 explicit ContentViewDelegate(ArcCustomNotificationView* owner)
181 : owner_(owner) {} 181 : owner_(owner) {}
182 182
183 bool IsCloseButtonFocused() const override { 183 bool IsCloseButtonFocused() const override {
184 if (!owner_->close_button_) 184 if (!owner_->close_button_)
185 return false; 185 return false;
186 return owner_->close_button_->HasFocus(); 186 return owner_->close_button_->HasFocus();
187 } 187 }
188 188
(...skipping 68 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 573
574 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) { 574 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) {
575 UpdateControlButtonsVisibility(); 575 UpdateControlButtonsVisibility();
576 } 576 }
577 577
578 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) { 578 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) {
579 UpdateControlButtonsVisibility(); 579 UpdateControlButtonsVisibility();
580 } 580 }
581 581
582 void ArcCustomNotificationView::OnFocus() { 582 void ArcCustomNotificationView::OnFocus() {
583 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, 583 CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName());
584 parent()->GetClassName());
585 584
586 NativeViewHost::OnFocus(); 585 NativeViewHost::OnFocus();
587 static_cast<message_center::CustomNotificationView*>(parent()) 586 static_cast<ArcNotificationView*>(parent())->OnContentFocused();
588 ->OnContentFocused();
589 } 587 }
590 588
591 void ArcCustomNotificationView::OnBlur() { 589 void ArcCustomNotificationView::OnBlur() {
592 if (!parent()) { 590 if (!parent()) {
593 // OnBlur may be called when this view is being removed. 591 // OnBlur may be called when this view is being removed.
594 return; 592 return;
595 } 593 }
596 594
597 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, 595 CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName());
598 parent()->GetClassName());
599 596
600 NativeViewHost::OnBlur(); 597 NativeViewHost::OnBlur();
601 static_cast<message_center::CustomNotificationView*>(parent()) 598 static_cast<ArcNotificationView*>(parent())->OnContentBlured();
602 ->OnContentBlured();
603 } 599 }
604 600
605 void ArcCustomNotificationView::ActivateToast() { 601 void ArcCustomNotificationView::ActivateToast() {
606 if (message_center::ToastContentsView::kViewClassName == 602 if (message_center::ToastContentsView::kViewClassName ==
607 parent()->parent()->GetClassName()) { 603 parent()->parent()->GetClassName()) {
608 static_cast<message_center::ToastContentsView*>(parent()->parent()) 604 static_cast<message_center::ToastContentsView*>(parent()->parent())
609 ->ActivateToast(); 605 ->ActivateToast();
610 } 606 }
611 } 607 }
612 608
613 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { 609 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() {
614 if (floating_control_buttons_widget_) 610 if (floating_control_buttons_widget_)
615 return static_cast<views::internal::RootView*>( 611 return static_cast<views::internal::RootView*>(
616 floating_control_buttons_widget_->GetRootView()); 612 floating_control_buttons_widget_->GetRootView());
617 return nullptr; 613 return nullptr;
618 } 614 }
619 615
620 bool ArcCustomNotificationView::HandleAccessibleAction( 616 bool ArcCustomNotificationView::HandleAccessibleAction(
621 const ui::AXActionData& action_data) { 617 const ui::AXActionData& action_data) {
622 if (item_ && action_data.action == ui::AX_ACTION_DO_DEFAULT) { 618 if (item_ && action_data.action == ui::AX_ACTION_DO_DEFAULT) {
623 item_->ToggleExpansion(); 619 item_->ToggleExpansion();
624 return true; 620 return true;
625 } 621 }
626 return false; 622 return false;
627 } 623 }
628 624
629 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, 625 void ArcCustomNotificationView::ButtonPressed(views::Button* sender,
630 const ui::Event& event) { 626 const ui::Event& event) {
631 if (item_ && !item_->GetPinned() && sender == close_button_.get()) { 627 if (item_ && !item_->GetPinned() && sender == close_button_.get()) {
632 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, 628 CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName());
633 parent()->GetClassName()); 629 static_cast<ArcNotificationView*>(parent())->OnCloseButtonPressed();
634 static_cast<message_center::CustomNotificationView*>(parent())
635 ->OnCloseButtonPressed();
636 } 630 }
637 if (item_ && settings_button_ && sender == settings_button_) { 631 if (item_ && settings_button_ && sender == settings_button_) {
638 item_->OpenSettings(); 632 item_->OpenSettings();
639 } 633 }
640 } 634 }
641 635
642 void ArcCustomNotificationView::OnWindowBoundsChanged( 636 void ArcCustomNotificationView::OnWindowBoundsChanged(
643 aura::Window* window, 637 aura::Window* window,
644 const gfx::Rect& old_bounds, 638 const gfx::Rect& old_bounds,
645 const gfx::Rect& new_bounds) { 639 const gfx::Rect& new_bounds) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 706 }
713 if (close_button_) { 707 if (close_button_) {
714 close_button_->set_background( 708 close_button_->set_background(
715 views::Background::CreateSolidBackground(current_color)); 709 views::Background::CreateSolidBackground(current_color));
716 close_button_->SchedulePaint(); 710 close_button_->SchedulePaint();
717 } 711 }
718 } 712 }
719 } 713 }
720 714
721 } // namespace arc 715 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_custom_notification_view.h ('k') | ui/arc/notification/arc_notification_content_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698