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

Side by Side Diff: chrome/browser/ui/ash/launcher/multi_profile_shell_window_launcher_controller.cc

Issue 157813007: Remove Profile dependency from apps::ShellWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test 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/launcher/multi_profile_shell_window_launcher_con troller.h" 5 #include "chrome/browser/ui/ash/launcher/multi_profile_shell_window_launcher_con troller.h"
6 6
7 #include "apps/shell_window.h" 7 #include "apps/shell_window.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
(...skipping 25 matching lines...) Expand all
36 36
37 void MultiProfileShellWindowLauncherController::ActiveUserChanged( 37 void MultiProfileShellWindowLauncherController::ActiveUserChanged(
38 const std::string& user_email) { 38 const std::string& user_email) {
39 // The active user has changed and we need to traverse our list of items to 39 // The active user has changed and we need to traverse our list of items to
40 // show / hide them one by one. To avoid that a user dependent state 40 // show / hide them one by one. To avoid that a user dependent state
41 // "survives" in a launcher item, we first delete all items making sure that 41 // "survives" in a launcher item, we first delete all items making sure that
42 // nothing remains and then re-create them again. 42 // nothing remains and then re-create them again.
43 for (ShellWindowList::iterator it = shell_window_list_.begin(); 43 for (ShellWindowList::iterator it = shell_window_list_.begin();
44 it != shell_window_list_.end(); ++it) { 44 it != shell_window_list_.end(); ++it) {
45 apps::ShellWindow* shell_window = *it; 45 apps::ShellWindow* shell_window = *it;
46 if (!multi_user_util::IsProfileFromActiveUser(shell_window->profile()) && 46 Profile* profile =
47 Profile::FromBrowserContext(shell_window->browser_context());
48 if (!multi_user_util::IsProfileFromActiveUser(profile) &&
47 IsRegisteredApp(shell_window->GetNativeWindow())) 49 IsRegisteredApp(shell_window->GetNativeWindow()))
48 UnregisterApp(shell_window->GetNativeWindow()); 50 UnregisterApp(shell_window->GetNativeWindow());
49 } 51 }
50 for (ShellWindowList::iterator it = shell_window_list_.begin(); 52 for (ShellWindowList::iterator it = shell_window_list_.begin();
51 it != shell_window_list_.end(); ++it) { 53 it != shell_window_list_.end(); ++it) {
52 apps::ShellWindow* shell_window = *it; 54 apps::ShellWindow* shell_window = *it;
53 if (multi_user_util::IsProfileFromActiveUser(shell_window->profile()) && 55 Profile* profile =
56 Profile::FromBrowserContext(shell_window->browser_context());
57 if (multi_user_util::IsProfileFromActiveUser(profile) &&
54 !IsRegisteredApp(shell_window->GetNativeWindow())) 58 !IsRegisteredApp(shell_window->GetNativeWindow()))
55 RegisterApp(*it); 59 RegisterApp(*it);
56 } 60 }
57 } 61 }
58 62
59 void MultiProfileShellWindowLauncherController::AdditionalUserAddedToSession( 63 void MultiProfileShellWindowLauncherController::AdditionalUserAddedToSession(
60 Profile* profile) { 64 Profile* profile) {
61 // Each users ShellRegistry needs to be observed. 65 // Each users ShellRegistry needs to be observed.
62 apps::ShellWindowRegistry* registry = apps::ShellWindowRegistry::Get(profile); 66 apps::ShellWindowRegistry* registry = apps::ShellWindowRegistry::Get(profile);
63 multi_user_registry_.push_back(registry); 67 multi_user_registry_.push_back(registry);
64 registry->AddObserver(this); 68 registry->AddObserver(this);
65 } 69 }
66 70
67 void MultiProfileShellWindowLauncherController::OnShellWindowAdded( 71 void MultiProfileShellWindowLauncherController::OnShellWindowAdded(
68 apps::ShellWindow* shell_window) { 72 apps::ShellWindow* shell_window) {
69 if (!ControlsWindow(shell_window->GetNativeWindow())) 73 if (!ControlsWindow(shell_window->GetNativeWindow()))
70 return; 74 return;
71 shell_window_list_.push_back(shell_window); 75 shell_window_list_.push_back(shell_window);
72 if (multi_user_util::IsProfileFromActiveUser(shell_window->profile())) 76 Profile* profile =
77 Profile::FromBrowserContext(shell_window->browser_context());
78 if (multi_user_util::IsProfileFromActiveUser(profile))
73 RegisterApp(shell_window); 79 RegisterApp(shell_window);
74 } 80 }
75 81
76 void MultiProfileShellWindowLauncherController::OnShellWindowRemoved( 82 void MultiProfileShellWindowLauncherController::OnShellWindowRemoved(
77 apps::ShellWindow* shell_window) { 83 apps::ShellWindow* shell_window) {
78 if (!ControlsWindow(shell_window->GetNativeWindow())) 84 if (!ControlsWindow(shell_window->GetNativeWindow()))
79 return; 85 return;
80 86
81 // If the application is registered with ShellWindowLauncher (because the user 87 // If the application is registered with ShellWindowLauncher (because the user
82 // is currently active), the OnWindowDestroying observer has already (or will 88 // is currently active), the OnWindowDestroying observer has already (or will
83 // soon) unregister it independently from the shelf. If it was not registered 89 // soon) unregister it independently from the shelf. If it was not registered
84 // we don't need to do anything anyways. As such, all which is left to do here 90 // we don't need to do anything anyways. As such, all which is left to do here
85 // is to get rid of our own reference. 91 // is to get rid of our own reference.
86 ShellWindowList::iterator it = std::find(shell_window_list_.begin(), 92 ShellWindowList::iterator it = std::find(shell_window_list_.begin(),
87 shell_window_list_.end(), 93 shell_window_list_.end(),
88 shell_window); 94 shell_window);
89 DCHECK(it != shell_window_list_.end()); 95 DCHECK(it != shell_window_list_.end());
90 shell_window_list_.erase(it); 96 shell_window_list_.erase(it);
91 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698