OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/first_run/desktop_cleaner.h" | 5 #include "ash/first_run/desktop_cleaner.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ui/aura/window_event_dispatcher.h" | 9 #include "ui/aura/window_event_dispatcher.h" |
10 #include "ui/aura/window_observer.h" | 10 #include "ui/aura/window_observer.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 : container_was_hidden_(!container->IsVisible()), | 34 : container_was_hidden_(!container->IsVisible()), |
35 container_(container) { | 35 container_(container) { |
36 if (container_was_hidden_) | 36 if (container_was_hidden_) |
37 return; | 37 return; |
38 ui::Layer* layer = container_->layer(); | 38 ui::Layer* layer = container_->layer(); |
39 ui::ScopedLayerAnimationSettings animation_settings(layer->GetAnimator()); | 39 ui::ScopedLayerAnimationSettings animation_settings(layer->GetAnimator()); |
40 animation_settings.AddObserver(this); | 40 animation_settings.AddObserver(this); |
41 layer->SetOpacity(0.0); | 41 layer->SetOpacity(0.0); |
42 } | 42 } |
43 | 43 |
44 virtual ~ContainerHider() { | 44 ~ContainerHider() override { |
45 if (container_was_hidden_ || !container_) | 45 if (container_was_hidden_ || !container_) |
46 return; | 46 return; |
47 if (!WasAnimationCompletedForProperty(ui::LayerAnimationElement::OPACITY)) { | 47 if (!WasAnimationCompletedForProperty(ui::LayerAnimationElement::OPACITY)) { |
48 // We are in the middle of animation. | 48 // We are in the middle of animation. |
49 StopObservingImplicitAnimations(); | 49 StopObservingImplicitAnimations(); |
50 } else { | 50 } else { |
51 container_->Show(); | 51 container_->Show(); |
52 } | 52 } |
53 ui::Layer* layer = container_->layer(); | 53 ui::Layer* layer = container_->layer(); |
54 ui::ScopedLayerAnimationSettings animation_settings(layer->GetAnimator()); | 54 ui::ScopedLayerAnimationSettings animation_settings(layer->GetAnimator()); |
55 layer->SetOpacity(1.0); | 55 layer->SetOpacity(1.0); |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 // Overriden from ui::ImplicitAnimationObserver. | 59 // Overriden from ui::ImplicitAnimationObserver. |
60 virtual void OnImplicitAnimationsCompleted() override { | 60 void OnImplicitAnimationsCompleted() override { container_->Hide(); } |
61 container_->Hide(); | |
62 } | |
63 | 61 |
64 // Overriden from aura::WindowObserver. | 62 // Overriden from aura::WindowObserver. |
65 virtual void OnWindowDestroying(aura::Window* window) override { | 63 void OnWindowDestroying(aura::Window* window) override { |
66 DCHECK(window == container_); | 64 DCHECK(window == container_); |
67 container_ = NULL; | 65 container_ = NULL; |
68 } | 66 } |
69 | 67 |
70 const bool container_was_hidden_; | 68 const bool container_was_hidden_; |
71 aura::Window* container_; | 69 aura::Window* container_; |
72 | 70 |
73 DISALLOW_COPY_AND_ASSIGN(ContainerHider); | 71 DISALLOW_COPY_AND_ASSIGN(ContainerHider); |
74 }; | 72 }; |
75 | 73 |
76 class NotificationBlocker : public message_center::NotificationBlocker { | 74 class NotificationBlocker : public message_center::NotificationBlocker { |
77 public: | 75 public: |
78 NotificationBlocker() | 76 NotificationBlocker() |
79 : message_center::NotificationBlocker( | 77 : message_center::NotificationBlocker( |
80 message_center::MessageCenter::Get()) { | 78 message_center::MessageCenter::Get()) { |
81 NotifyBlockingStateChanged(); | 79 NotifyBlockingStateChanged(); |
82 } | 80 } |
83 | 81 |
84 virtual ~NotificationBlocker() {}; | 82 ~NotificationBlocker() override{}; |
Daniel Erat
2014/10/27 21:55:49
i feel like the following, with a space between 'o
dcheng
2014/10/27 22:03:41
I think this is a misformatting by clang-format. T
| |
85 | 83 |
86 private: | 84 private: |
87 // Overriden from message_center::NotificationBlocker. | 85 // Overriden from message_center::NotificationBlocker. |
88 virtual bool ShouldShowNotificationAsPopup( | 86 bool ShouldShowNotificationAsPopup( |
89 const message_center::NotifierId& notifier_id) const override { | 87 const message_center::NotifierId& notifier_id) const override { |
90 return false; | 88 return false; |
91 } | 89 } |
92 | 90 |
93 DISALLOW_COPY_AND_ASSIGN(NotificationBlocker); | 91 DISALLOW_COPY_AND_ASSIGN(NotificationBlocker); |
94 }; | 92 }; |
95 | 93 |
96 DesktopCleaner::DesktopCleaner() { | 94 DesktopCleaner::DesktopCleaner() { |
97 // TODO(dzhioev): Add support for secondary displays. | 95 // TODO(dzhioev): Add support for secondary displays. |
98 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 96 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
99 for (size_t i = 0; i < arraysize(kContainerIdsToHide); ++i) { | 97 for (size_t i = 0; i < arraysize(kContainerIdsToHide); ++i) { |
100 aura::Window* container = | 98 aura::Window* container = |
101 Shell::GetContainer(root_window, kContainerIdsToHide[i]); | 99 Shell::GetContainer(root_window, kContainerIdsToHide[i]); |
102 container_hiders_.push_back(make_linked_ptr(new ContainerHider(container))); | 100 container_hiders_.push_back(make_linked_ptr(new ContainerHider(container))); |
103 } | 101 } |
104 notification_blocker_.reset(new NotificationBlocker()); | 102 notification_blocker_.reset(new NotificationBlocker()); |
105 } | 103 } |
106 | 104 |
107 DesktopCleaner::~DesktopCleaner() {} | 105 DesktopCleaner::~DesktopCleaner() {} |
108 | 106 |
109 // static | 107 // static |
110 std::vector<int> DesktopCleaner::GetContainersToHideForTest() { | 108 std::vector<int> DesktopCleaner::GetContainersToHideForTest() { |
111 return std::vector<int>(kContainerIdsToHide, | 109 return std::vector<int>(kContainerIdsToHide, |
112 kContainerIdsToHide + arraysize(kContainerIdsToHide)); | 110 kContainerIdsToHide + arraysize(kContainerIdsToHide)); |
113 } | 111 } |
114 | 112 |
115 } // namespace ash | 113 } // namespace ash |
116 | 114 |
OLD | NEW |