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 "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" |
6 | 6 |
7 #include "apps/app_window.h" | |
8 #include "apps/app_window_registry.h" | |
9 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
10 #include "ash/multi_profile_uma.h" | 8 #include "ash/multi_profile_uma.h" |
11 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
12 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
13 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
14 #include "ash/shell.h" | 12 #include "ash/shell.h" |
15 #include "ash/shell_delegate.h" | 13 #include "ash/shell_delegate.h" |
16 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
17 #include "ash/system/tray/system_tray_notifier.h" | 15 #include "ash/system/tray/system_tray_notifier.h" |
18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
19 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
20 #include "base/auto_reset.h" | 18 #include "base/auto_reset.h" |
21 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
22 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
23 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
27 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom
eos.h" | 25 #include "chrome/browser/ui/ash/multi_user/multi_user_notification_blocker_chrom
eos.h" |
28 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 26 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
29 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" | 27 #include "chrome/browser/ui/ash/multi_user/user_switch_animator_chromeos.h" |
30 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
32 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
33 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
34 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 33 #include "extensions/browser/app_window/app_window.h" |
| 34 #include "extensions/browser/app_window/app_window_registry.h" |
35 #include "google_apis/gaia/gaia_auth_util.h" | 35 #include "google_apis/gaia/gaia_auth_util.h" |
36 #include "ui/aura/client/aura_constants.h" | 36 #include "ui/aura/client/aura_constants.h" |
37 #include "ui/aura/window.h" | 37 #include "ui/aura/window.h" |
38 #include "ui/aura/window_event_dispatcher.h" | 38 #include "ui/aura/window_event_dispatcher.h" |
39 #include "ui/base/ui_base_types.h" | 39 #include "ui/base/ui_base_types.h" |
40 #include "ui/events/event.h" | 40 #include "ui/events/event.h" |
41 #include "ui/message_center/message_center.h" | 41 #include "ui/message_center/message_center.h" |
42 #include "ui/wm/core/transient_window_manager.h" | 42 #include "ui/wm/core/transient_window_manager.h" |
43 #include "ui/wm/core/window_animations.h" | 43 #include "ui/wm/core/window_animations.h" |
44 #include "ui/wm/core/window_util.h" | 44 #include "ui/wm/core/window_util.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_POPUP; | 112 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_POPUP; |
113 } else { | 113 } else { |
114 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_BROWSER; | 114 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_BROWSER; |
115 } | 115 } |
116 } else { | 116 } else { |
117 // Unit tests might come here without a profile manager. | 117 // Unit tests might come here without a profile manager. |
118 if (!g_browser_process->profile_manager()) | 118 if (!g_browser_process->profile_manager()) |
119 return; | 119 return; |
120 // If it is not a browser, it is probably be a V2 application. In that case | 120 // If it is not a browser, it is probably be a V2 application. In that case |
121 // one of the AppWindowRegistry instances should know about it. | 121 // one of the AppWindowRegistry instances should know about it. |
122 apps::AppWindow* app_window = NULL; | 122 extensions::AppWindow* app_window = NULL; |
123 std::vector<Profile*> profiles = | 123 std::vector<Profile*> profiles = |
124 g_browser_process->profile_manager()->GetLoadedProfiles(); | 124 g_browser_process->profile_manager()->GetLoadedProfiles(); |
125 for (std::vector<Profile*>::iterator it = profiles.begin(); | 125 for (std::vector<Profile*>::iterator it = profiles.begin(); |
126 it != profiles.end() && app_window == NULL; | 126 it != profiles.end() && app_window == NULL; |
127 it++) { | 127 it++) { |
128 app_window = apps::AppWindowRegistry::Get(*it) | 128 app_window = extensions::AppWindowRegistry::Get(*it) |
129 ->GetAppWindowForNativeWindow(window); | 129 ->GetAppWindowForNativeWindow(window); |
130 } | 130 } |
131 if (app_window) { | 131 if (app_window) { |
132 if (app_window->window_type() == apps::AppWindow::WINDOW_TYPE_PANEL || | 132 if (app_window->window_type() == |
133 app_window->window_type() == apps::AppWindow::WINDOW_TYPE_V1_PANEL) { | 133 extensions::AppWindow::WINDOW_TYPE_PANEL || |
| 134 app_window->window_type() == |
| 135 extensions::AppWindow::WINDOW_TYPE_V1_PANEL) { |
134 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL; | 136 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL; |
135 } else { | 137 } else { |
136 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP; | 138 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP; |
137 } | 139 } |
138 } | 140 } |
139 } | 141 } |
140 ash::MultiProfileUMA::RecordTeleportWindowType(window_type); | 142 ash::MultiProfileUMA::RecordTeleportWindowType(window_type); |
141 } | 143 } |
142 | 144 |
143 } // namespace | 145 } // namespace |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // Previous animation time. | 181 // Previous animation time. |
180 const base::TimeDelta previous_animation_time_; | 182 const base::TimeDelta previous_animation_time_; |
181 | 183 |
182 DISALLOW_COPY_AND_ASSIGN(AnimationSetter); | 184 DISALLOW_COPY_AND_ASSIGN(AnimationSetter); |
183 }; | 185 }; |
184 | 186 |
185 // This class keeps track of all applications which were started for a user. | 187 // This class keeps track of all applications which were started for a user. |
186 // When an app gets created, the window will be tagged for that user. Note | 188 // When an app gets created, the window will be tagged for that user. Note |
187 // that the destruction does not need to be tracked here since the universal | 189 // that the destruction does not need to be tracked here since the universal |
188 // window observer will take care of that. | 190 // window observer will take care of that. |
189 class AppObserver : public apps::AppWindowRegistry::Observer { | 191 class AppObserver : public extensions::AppWindowRegistry::Observer { |
190 public: | 192 public: |
191 explicit AppObserver(const std::string& user_id) : user_id_(user_id) {} | 193 explicit AppObserver(const std::string& user_id) : user_id_(user_id) {} |
192 virtual ~AppObserver() {} | 194 virtual ~AppObserver() {} |
193 | 195 |
194 // AppWindowRegistry::Observer overrides: | 196 // AppWindowRegistry::Observer overrides: |
195 virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE { | 197 virtual void OnAppWindowAdded(extensions::AppWindow* app_window) OVERRIDE { |
196 aura::Window* window = app_window->GetNativeWindow(); | 198 aura::Window* window = app_window->GetNativeWindow(); |
197 DCHECK(window); | 199 DCHECK(window); |
198 MultiUserWindowManagerChromeOS::GetInstance()->SetWindowOwner(window, | 200 MultiUserWindowManagerChromeOS::GetInstance()->SetWindowOwner(window, |
199 user_id_); | 201 user_id_); |
200 } | 202 } |
201 | 203 |
202 private: | 204 private: |
203 std::string user_id_; | 205 std::string user_id_; |
204 | 206 |
205 DISALLOW_COPY_AND_ASSIGN(AppObserver); | 207 DISALLOW_COPY_AND_ASSIGN(AppObserver); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 window = window_to_entry_.begin(); | 244 window = window_to_entry_.begin(); |
243 } | 245 } |
244 | 246 |
245 // Remove all app observers. | 247 // Remove all app observers. |
246 UserIDToAppWindowObserver::iterator app_observer_iterator = | 248 UserIDToAppWindowObserver::iterator app_observer_iterator = |
247 user_id_to_app_observer_.begin(); | 249 user_id_to_app_observer_.begin(); |
248 while (app_observer_iterator != user_id_to_app_observer_.end()) { | 250 while (app_observer_iterator != user_id_to_app_observer_.end()) { |
249 Profile* profile = multi_user_util::GetProfileFromUserID( | 251 Profile* profile = multi_user_util::GetProfileFromUserID( |
250 app_observer_iterator->first); | 252 app_observer_iterator->first); |
251 DCHECK(profile); | 253 DCHECK(profile); |
252 apps::AppWindowRegistry::Get(profile) | 254 extensions::AppWindowRegistry::Get(profile) |
253 ->RemoveObserver(app_observer_iterator->second); | 255 ->RemoveObserver(app_observer_iterator->second); |
254 delete app_observer_iterator->second; | 256 delete app_observer_iterator->second; |
255 user_id_to_app_observer_.erase(app_observer_iterator); | 257 user_id_to_app_observer_.erase(app_observer_iterator); |
256 app_observer_iterator = user_id_to_app_observer_.begin(); | 258 app_observer_iterator = user_id_to_app_observer_.begin(); |
257 } | 259 } |
258 | 260 |
259 if (ash::Shell::HasInstance()) | 261 if (ash::Shell::HasInstance()) |
260 ash::Shell::GetInstance()->session_state_delegate()-> | 262 ash::Shell::GetInstance()->session_state_delegate()-> |
261 RemoveSessionStateObserver(this); | 263 RemoveSessionStateObserver(this); |
262 } | 264 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 return it->second->show_for_user(); | 357 return it->second->show_for_user(); |
356 } | 358 } |
357 | 359 |
358 void MultiUserWindowManagerChromeOS::AddUser(content::BrowserContext* context) { | 360 void MultiUserWindowManagerChromeOS::AddUser(content::BrowserContext* context) { |
359 Profile* profile = Profile::FromBrowserContext(context); | 361 Profile* profile = Profile::FromBrowserContext(context); |
360 const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile); | 362 const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile); |
361 if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end()) | 363 if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end()) |
362 return; | 364 return; |
363 | 365 |
364 user_id_to_app_observer_[user_id] = new AppObserver(user_id); | 366 user_id_to_app_observer_[user_id] = new AppObserver(user_id); |
365 apps::AppWindowRegistry::Get(profile) | 367 extensions::AppWindowRegistry::Get(profile) |
366 ->AddObserver(user_id_to_app_observer_[user_id]); | 368 ->AddObserver(user_id_to_app_observer_[user_id]); |
367 | 369 |
368 // Account all existing application windows of this user accordingly. | 370 // Account all existing application windows of this user accordingly. |
369 const apps::AppWindowRegistry::AppWindowList& app_windows = | 371 const extensions::AppWindowRegistry::AppWindowList& app_windows = |
370 apps::AppWindowRegistry::Get(profile)->app_windows(); | 372 extensions::AppWindowRegistry::Get(profile)->app_windows(); |
371 apps::AppWindowRegistry::AppWindowList::const_iterator it = | 373 extensions::AppWindowRegistry::AppWindowList::const_iterator it = |
372 app_windows.begin(); | 374 app_windows.begin(); |
373 for (; it != app_windows.end(); ++it) | 375 for (; it != app_windows.end(); ++it) |
374 user_id_to_app_observer_[user_id]->OnAppWindowAdded(*it); | 376 user_id_to_app_observer_[user_id]->OnAppWindowAdded(*it); |
375 | 377 |
376 // Account all existing browser windows of this user accordingly. | 378 // Account all existing browser windows of this user accordingly. |
377 BrowserList* browser_list = BrowserList::GetInstance(HOST_DESKTOP_TYPE_ASH); | 379 BrowserList* browser_list = BrowserList::GetInstance(HOST_DESKTOP_TYPE_ASH); |
378 BrowserList::const_iterator browser_it = browser_list->begin(); | 380 BrowserList::const_iterator browser_it = browser_list->begin(); |
379 for (; browser_it != browser_list->end(); ++browser_it) { | 381 for (; browser_it != browser_list->end(); ++browser_it) { |
380 if ((*browser_it)->profile()->GetOriginalProfile() == profile) | 382 if ((*browser_it)->profile()->GetOriginalProfile() == profile) |
381 AddBrowserWindow(*browser_it); | 383 AddBrowserWindow(*browser_it); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 DCHECK_EQ(visible, window->IsVisible()); | 715 DCHECK_EQ(visible, window->IsVisible()); |
714 } | 716 } |
715 | 717 |
716 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( | 718 int MultiUserWindowManagerChromeOS::GetAdjustedAnimationTimeInMS( |
717 int default_time_in_ms) const { | 719 int default_time_in_ms) const { |
718 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : | 720 return animation_speed_ == ANIMATION_SPEED_NORMAL ? default_time_in_ms : |
719 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); | 721 (animation_speed_ == ANIMATION_SPEED_FAST ? 10 : 0); |
720 } | 722 } |
721 | 723 |
722 } // namespace chrome | 724 } // namespace chrome |
OLD | NEW |