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

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc

Issue 166573005: Rename apps::ShellWindow to apps::AppWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, nits (rename) Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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/shell_window.h" 7 #include "apps/app_window.h"
8 #include "apps/shell_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/desktop_background/user_wallpaper_delegate.h" 10 #include "ash/desktop_background/user_wallpaper_delegate.h"
11 #include "ash/multi_profile_uma.h" 11 #include "ash/multi_profile_uma.h"
12 #include "ash/root_window_controller.h" 12 #include "ash/root_window_controller.h"
13 #include "ash/session_state_delegate.h" 13 #include "ash/session_state_delegate.h"
14 #include "ash/shelf/shelf.h" 14 #include "ash/shelf/shelf.h"
15 #include "ash/shelf/shelf_layout_manager.h" 15 #include "ash/shelf/shelf_layout_manager.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_delegate.h" 17 #include "ash/shell_delegate.h"
18 #include "ash/shell_window_ids.h" 18 #include "ash/shell_window_ids.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } else if (browser->is_type_popup()) { 116 } else if (browser->is_type_popup()) {
117 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_POPUP; 117 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_POPUP;
118 } else { 118 } else {
119 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_BROWSER; 119 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_BROWSER;
120 } 120 }
121 } else { 121 } else {
122 // Unit tests might come here without a profile manager. 122 // Unit tests might come here without a profile manager.
123 if (!g_browser_process->profile_manager()) 123 if (!g_browser_process->profile_manager())
124 return; 124 return;
125 // If it is not a browser, it is probably be a V2 application. In that case 125 // If it is not a browser, it is probably be a V2 application. In that case
126 // one of the ShellWindowRegistries should know about it. 126 // one of the AppWindowRegistry instances should know about it.
127 apps::ShellWindow* shell_window = NULL; 127 apps::AppWindow* app_window = NULL;
128 std::vector<Profile*> profiles = 128 std::vector<Profile*> profiles =
129 g_browser_process->profile_manager()->GetLoadedProfiles(); 129 g_browser_process->profile_manager()->GetLoadedProfiles();
130 for (std::vector<Profile*>::iterator it = profiles.begin(); 130 for (std::vector<Profile*>::iterator it = profiles.begin();
131 it != profiles.end() && shell_window == NULL; it++) { 131 it != profiles.end() && app_window == NULL;
132 shell_window = apps::ShellWindowRegistry::Get( 132 it++) {
133 *it)->GetShellWindowForNativeWindow(window); 133 app_window = apps::AppWindowRegistry::Get(*it)
134 ->GetAppWindowForNativeWindow(window);
134 } 135 }
135 if (shell_window) { 136 if (app_window) {
136 if (shell_window->window_type() == 137 if (app_window->window_type() == apps::AppWindow::WINDOW_TYPE_PANEL ||
137 apps::ShellWindow::WINDOW_TYPE_PANEL || 138 app_window->window_type() == apps::AppWindow::WINDOW_TYPE_V1_PANEL) {
138 shell_window->window_type() ==
139 apps::ShellWindow::WINDOW_TYPE_V1_PANEL) {
140 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL; 139 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_PANEL;
141 } else { 140 } else {
142 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP; 141 window_type = ash::MultiProfileUMA::TELEPORT_WINDOW_V2_APP;
143 } 142 }
144 } 143 }
145 } 144 }
146 ash::MultiProfileUMA::RecordTeleportWindowType(window_type); 145 ash::MultiProfileUMA::RecordTeleportWindowType(window_type);
147 } 146 }
148 147
149 } // namespace 148 } // namespace
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 202 }
204 private: 203 private:
205 204
206 DISALLOW_COPY_AND_ASSIGN(UserChangeActionDisabler); 205 DISALLOW_COPY_AND_ASSIGN(UserChangeActionDisabler);
207 }; 206 };
208 207
209 // This class keeps track of all applications which were started for a user. 208 // This class keeps track of all applications which were started for a user.
210 // When an app gets created, the window will be tagged for that user. Note 209 // When an app gets created, the window will be tagged for that user. Note
211 // that the destruction does not need to be tracked here since the universal 210 // that the destruction does not need to be tracked here since the universal
212 // window observer will take care of that. 211 // window observer will take care of that.
213 class AppObserver : public apps::ShellWindowRegistry::Observer { 212 class AppObserver : public apps::AppWindowRegistry::Observer {
214 public: 213 public:
215 explicit AppObserver(const std::string& user_id) : user_id_(user_id) {} 214 explicit AppObserver(const std::string& user_id) : user_id_(user_id) {}
216 virtual ~AppObserver() {} 215 virtual ~AppObserver() {}
217 216
218 // ShellWindowRegistry::Observer overrides: 217 // AppWindowRegistry::Observer overrides:
219 virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) OVERRIDE { 218 virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE {
220 aura::Window* window = shell_window->GetNativeWindow(); 219 aura::Window* window = app_window->GetNativeWindow();
221 DCHECK(window); 220 DCHECK(window);
222 MultiUserWindowManagerChromeOS::GetInstance()->SetWindowOwner(window, 221 MultiUserWindowManagerChromeOS::GetInstance()->SetWindowOwner(window,
223 user_id_); 222 user_id_);
224 } 223 }
225 virtual void OnShellWindowIconChanged(apps::ShellWindow* shell_window) 224 virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE {}
226 OVERRIDE {} 225 virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE {}
227 virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window)
228 OVERRIDE {}
229 226
230 private: 227 private:
231 std::string user_id_; 228 std::string user_id_;
232 229
233 DISALLOW_COPY_AND_ASSIGN(AppObserver); 230 DISALLOW_COPY_AND_ASSIGN(AppObserver);
234 }; 231 };
235 232
236 MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS( 233 MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS(
237 const std::string& current_user_id) 234 const std::string& current_user_id)
238 : current_user_id_(current_user_id), 235 : current_user_id_(current_user_id),
(...skipping 19 matching lines...) Expand all
258 255
259 MultiUserWindowManagerChromeOS::~MultiUserWindowManagerChromeOS() { 256 MultiUserWindowManagerChromeOS::~MultiUserWindowManagerChromeOS() {
260 // Remove all window observers. 257 // Remove all window observers.
261 WindowToEntryMap::iterator window = window_to_entry_.begin(); 258 WindowToEntryMap::iterator window = window_to_entry_.begin();
262 while (window != window_to_entry_.end()) { 259 while (window != window_to_entry_.end()) {
263 OnWindowDestroyed(window->first); 260 OnWindowDestroyed(window->first);
264 window = window_to_entry_.begin(); 261 window = window_to_entry_.begin();
265 } 262 }
266 263
267 // Remove all app observers. 264 // Remove all app observers.
268 UserIDToShellWindowObserver::iterator app_observer_iterator = 265 UserIDToAppWindowObserver::iterator app_observer_iterator =
269 user_id_to_app_observer_.begin(); 266 user_id_to_app_observer_.begin();
270 while (app_observer_iterator != user_id_to_app_observer_.end()) { 267 while (app_observer_iterator != user_id_to_app_observer_.end()) {
271 Profile* profile = multi_user_util::GetProfileFromUserID( 268 Profile* profile = multi_user_util::GetProfileFromUserID(
272 app_observer_iterator->first); 269 app_observer_iterator->first);
273 DCHECK(profile); 270 DCHECK(profile);
274 apps::ShellWindowRegistry::Get(profile)->RemoveObserver( 271 apps::AppWindowRegistry::Get(profile)
275 app_observer_iterator->second); 272 ->RemoveObserver(app_observer_iterator->second);
276 delete app_observer_iterator->second; 273 delete app_observer_iterator->second;
277 user_id_to_app_observer_.erase(app_observer_iterator); 274 user_id_to_app_observer_.erase(app_observer_iterator);
278 app_observer_iterator = user_id_to_app_observer_.begin(); 275 app_observer_iterator = user_id_to_app_observer_.begin();
279 } 276 }
280 277
281 if (ash::Shell::HasInstance()) 278 if (ash::Shell::HasInstance())
282 ash::Shell::GetInstance()->session_state_delegate()-> 279 ash::Shell::GetInstance()->session_state_delegate()->
283 RemoveSessionStateObserver(this); 280 RemoveSessionStateObserver(this);
284 } 281 }
285 282
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Otherwise we ask the object for its desktop. 372 // Otherwise we ask the object for its desktop.
376 return it->second->show_for_user(); 373 return it->second->show_for_user();
377 } 374 }
378 375
379 void MultiUserWindowManagerChromeOS::AddUser(Profile* profile) { 376 void MultiUserWindowManagerChromeOS::AddUser(Profile* profile) {
380 const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile); 377 const std::string& user_id = multi_user_util::GetUserIDFromProfile(profile);
381 if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end()) 378 if (user_id_to_app_observer_.find(user_id) != user_id_to_app_observer_.end())
382 return; 379 return;
383 380
384 user_id_to_app_observer_[user_id] = new AppObserver(user_id); 381 user_id_to_app_observer_[user_id] = new AppObserver(user_id);
385 apps::ShellWindowRegistry::Get(profile)->AddObserver( 382 apps::AppWindowRegistry::Get(profile)
386 user_id_to_app_observer_[user_id]); 383 ->AddObserver(user_id_to_app_observer_[user_id]);
387 384
388 // Account all existing application windows of this user accordingly. 385 // Account all existing application windows of this user accordingly.
389 const apps::ShellWindowRegistry::ShellWindowList& shell_windows = 386 const apps::AppWindowRegistry::AppWindowList& app_windows =
390 apps::ShellWindowRegistry::Get(profile)->shell_windows(); 387 apps::AppWindowRegistry::Get(profile)->app_windows();
391 apps::ShellWindowRegistry::ShellWindowList::const_iterator it = 388 apps::AppWindowRegistry::AppWindowList::const_iterator it =
392 shell_windows.begin(); 389 app_windows.begin();
393 for (; it != shell_windows.end(); ++it) 390 for (; it != app_windows.end(); ++it)
394 user_id_to_app_observer_[user_id]->OnShellWindowAdded(*it); 391 user_id_to_app_observer_[user_id]->OnAppWindowAdded(*it);
395 392
396 // Account all existing browser windows of this user accordingly. 393 // Account all existing browser windows of this user accordingly.
397 BrowserList* browser_list = BrowserList::GetInstance(HOST_DESKTOP_TYPE_ASH); 394 BrowserList* browser_list = BrowserList::GetInstance(HOST_DESKTOP_TYPE_ASH);
398 BrowserList::const_iterator browser_it = browser_list->begin(); 395 BrowserList::const_iterator browser_it = browser_list->begin();
399 for (; browser_it != browser_list->end(); ++browser_it) { 396 for (; browser_it != browser_list->end(); ++browser_it) {
400 if ((*browser_it)->profile()->GetOriginalProfile() == profile) 397 if ((*browser_it)->profile()->GetOriginalProfile() == profile)
401 AddBrowserWindow(*browser_it); 398 AddBrowserWindow(*browser_it);
402 } 399 }
403 } 400 }
404 401
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 window->Show(); 864 window->Show();
868 else 865 else
869 window->Hide(); 866 window->Hide();
870 867
871 // Make sure that animations have no influence on the window state after the 868 // Make sure that animations have no influence on the window state after the
872 // call. 869 // call.
873 DCHECK_EQ(visible, window->IsVisible()); 870 DCHECK_EQ(visible, window->IsVisible());
874 } 871 }
875 872
876 } // namespace chrome 873 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698