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

Side by Side Diff: ash/common/system/tray/system_tray.cc

Issue 2736753005: Converts WmActivationObserver to aura::client::ActivationChangeObserver (Closed)
Patch Set: cleanup Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/system/tray/system_tray.h" 5 #include "ash/common/system/tray/system_tray.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 #include "ash/common/system/tray/system_tray_controller.h" 38 #include "ash/common/system/tray/system_tray_controller.h"
39 #include "ash/common/system/tray/system_tray_delegate.h" 39 #include "ash/common/system/tray/system_tray_delegate.h"
40 #include "ash/common/system/tray/system_tray_item.h" 40 #include "ash/common/system/tray/system_tray_item.h"
41 #include "ash/common/system/tray/tray_bubble_wrapper.h" 41 #include "ash/common/system/tray/tray_bubble_wrapper.h"
42 #include "ash/common/system/tray/tray_constants.h" 42 #include "ash/common/system/tray/tray_constants.h"
43 #include "ash/common/system/tray_accessibility.h" 43 #include "ash/common/system/tray_accessibility.h"
44 #include "ash/common/system/update/tray_update.h" 44 #include "ash/common/system/update/tray_update.h"
45 #include "ash/common/system/user/tray_user.h" 45 #include "ash/common/system/user/tray_user.h"
46 #include "ash/common/system/web_notification/web_notification_tray.h" 46 #include "ash/common/system/web_notification/web_notification_tray.h"
47 #include "ash/common/wm/container_finder.h" 47 #include "ash/common/wm/container_finder.h"
48 #include "ash/common/wm_activation_observer.h"
49 #include "ash/common/wm_shell.h" 48 #include "ash/common/wm_shell.h"
50 #include "ash/common/wm_window.h" 49 #include "ash/common/wm_window.h"
51 #include "ash/public/cpp/shell_window_ids.h" 50 #include "ash/public/cpp/shell_window_ids.h"
52 #include "ash/root_window_controller.h" 51 #include "ash/root_window_controller.h"
52 #include "ash/shell.h"
53 #include "ash/strings/grit/ash_strings.h" 53 #include "ash/strings/grit/ash_strings.h"
54 #include "base/logging.h" 54 #include "base/logging.h"
55 #include "base/memory/ptr_util.h" 55 #include "base/memory/ptr_util.h"
56 #include "base/metrics/histogram_macros.h" 56 #include "base/metrics/histogram_macros.h"
57 #include "base/timer/timer.h" 57 #include "base/timer/timer.h"
58 #include "ui/base/accelerators/accelerator.h" 58 #include "ui/base/accelerators/accelerator.h"
59 #include "ui/base/l10n/l10n_util.h" 59 #include "ui/base/l10n/l10n_util.h"
60 #include "ui/compositor/layer.h" 60 #include "ui/compositor/layer.h"
61 #include "ui/display/display.h" 61 #include "ui/display/display.h"
62 #include "ui/display/screen.h" 62 #include "ui/display/screen.h"
63 #include "ui/events/event_constants.h" 63 #include "ui/events/event_constants.h"
64 #include "ui/gfx/canvas.h" 64 #include "ui/gfx/canvas.h"
65 #include "ui/gfx/skia_util.h" 65 #include "ui/gfx/skia_util.h"
66 #include "ui/message_center/message_center.h" 66 #include "ui/message_center/message_center.h"
67 #include "ui/message_center/message_center_style.h" 67 #include "ui/message_center/message_center_style.h"
68 #include "ui/views/border.h" 68 #include "ui/views/border.h"
69 #include "ui/views/controls/label.h" 69 #include "ui/views/controls/label.h"
70 #include "ui/views/view.h" 70 #include "ui/views/view.h"
71 #include "ui/views/widget/widget.h" 71 #include "ui/views/widget/widget.h"
72 #include "ui/wm/public/activation_change_observer.h"
73 #include "ui/wm/public/activation_client.h"
72 74
73 using views::TrayBubbleView; 75 using views::TrayBubbleView;
74 76
75 namespace ash { 77 namespace ash {
76 78
77 namespace { 79 namespace {
78 80
79 // A tray item that just reserves space in the tray. 81 // A tray item that just reserves space in the tray.
80 class PaddingTrayItem : public SystemTrayItem { 82 class PaddingTrayItem : public SystemTrayItem {
81 public: 83 public:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 private: 153 private:
152 std::unique_ptr<SystemTrayBubble> bubble_; 154 std::unique_ptr<SystemTrayBubble> bubble_;
153 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_; 155 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
154 bool is_persistent_; 156 bool is_persistent_;
155 157
156 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); 158 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper);
157 }; 159 };
158 160
159 // An activation observer to close the bubble if the window other 161 // An activation observer to close the bubble if the window other
160 // than system bubble nor popup notification is activated. 162 // than system bubble nor popup notification is activated.
161 class SystemTray::ActivationObserver : public WmActivationObserver { 163 class SystemTray::ActivationObserver
164 : public aura::client::ActivationChangeObserver {
162 public: 165 public:
163 explicit ActivationObserver(SystemTray* tray) : tray_(tray) { 166 explicit ActivationObserver(SystemTray* tray) : tray_(tray) {
164 DCHECK(tray_); 167 DCHECK(tray_);
165 WmShell::Get()->AddActivationObserver(this); 168 Shell::GetInstance()->activation_client()->AddObserver(this);
166 } 169 }
167 170
168 ~ActivationObserver() override { 171 ~ActivationObserver() override {
169 WmShell::Get()->RemoveActivationObserver(this); 172 Shell::GetInstance()->activation_client()->RemoveObserver(this);
170 } 173 }
171 174
172 // WmActivationObserver: 175 // WmActivationObserver:
173 void OnWindowActivated(WmWindow* gained_active, 176 void OnWindowActivated(ActivationReason reason,
174 WmWindow* lost_active) override { 177 aura::Window* gained_active,
178 aura::Window* lost_active) override {
179 WmWindow* wm_gained_active = WmWindow::Get(gained_active);
175 if (!tray_->HasSystemBubble() || !gained_active) 180 if (!tray_->HasSystemBubble() || !gained_active)
176 return; 181 return;
177 182
178 int container_id = 183 int container_id =
179 wm::GetContainerForWindow(gained_active)->GetShellWindowId(); 184 wm::GetContainerForWindow(wm_gained_active)->GetShellWindowId();
180 185
181 // Don't close the bubble if a popup notification is activated. 186 // Don't close the bubble if a popup notification is activated.
182 if (container_id == kShellWindowId_StatusContainer) 187 if (container_id == kShellWindowId_StatusContainer)
183 return; 188 return;
184 189
185 if (tray_->GetSystemBubble()->bubble_view()->GetWidget() != 190 if (tray_->GetSystemBubble()->bubble_view()->GetWidget() !=
186 gained_active->GetInternalWidget()) { 191 wm_gained_active->GetInternalWidget()) {
187 tray_->CloseSystemBubble(); 192 tray_->CloseSystemBubble();
188 } 193 }
189 } 194 }
190 void OnAttemptToReactivateWindow(WmWindow* request_active,
191 WmWindow* actual_active) override {}
192 195
193 private: 196 private:
194 SystemTray* tray_; 197 SystemTray* tray_;
195 198
196 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); 199 DISALLOW_COPY_AND_ASSIGN(ActivationObserver);
197 }; 200 };
198 201
199 // SystemTray 202 // SystemTray
200 203
201 SystemTray::SystemTray(WmShelf* wm_shelf) 204 SystemTray::SystemTray(WmShelf* wm_shelf)
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 .work_area() 770 .work_area()
768 .height(); 771 .height();
769 if (work_area_height > 0) { 772 if (work_area_height > 0) {
770 UMA_HISTOGRAM_CUSTOM_COUNTS( 773 UMA_HISTOGRAM_CUSTOM_COUNTS(
771 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 774 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
772 100 * bubble_view->height() / work_area_height, 1, 300, 100); 775 100 * bubble_view->height() / work_area_height, 1, 300, 100);
773 } 776 }
774 } 777 }
775 778
776 } // namespace ash 779 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698