OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_app_window_launcher_contr
oller.h" | 5 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr
oller.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 9 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
10 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 10 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 MultiProfileAppWindowLauncherController:: | 29 MultiProfileAppWindowLauncherController:: |
30 ~MultiProfileAppWindowLauncherController() { | 30 ~MultiProfileAppWindowLauncherController() { |
31 // We need to remove all Registry observers for added users. | 31 // We need to remove all Registry observers for added users. |
32 for (AppWindowRegistryList::iterator it = multi_user_registry_.begin(); | 32 for (AppWindowRegistryList::iterator it = multi_user_registry_.begin(); |
33 it != multi_user_registry_.end(); | 33 it != multi_user_registry_.end(); |
34 ++it) | 34 ++it) |
35 (*it)->RemoveObserver(this); | 35 (*it)->RemoveObserver(this); |
36 } | 36 } |
37 | 37 |
38 void MultiProfileAppWindowLauncherController::ActiveUserChanged( | 38 void MultiProfileAppWindowLauncherController::ActiveUserChanged( |
39 const std::string& user_email) { | 39 const user_manager::UserID& user_id) { |
40 // The active user has changed and we need to traverse our list of items to | 40 // The active user has changed and we need to traverse our list of items to |
41 // show / hide them one by one. To avoid that a user dependent state | 41 // show / hide them one by one. To avoid that a user dependent state |
42 // "survives" in a launcher item, we first delete all items making sure that | 42 // "survives" in a launcher item, we first delete all items making sure that |
43 // nothing remains and then re-create them again. | 43 // nothing remains and then re-create them again. |
44 for (AppWindowList::iterator it = app_window_list_.begin(); | 44 for (AppWindowList::iterator it = app_window_list_.begin(); |
45 it != app_window_list_.end(); | 45 it != app_window_list_.end(); |
46 ++it) { | 46 ++it) { |
47 extensions::AppWindow* app_window = *it; | 47 extensions::AppWindow* app_window = *it; |
48 Profile* profile = | 48 Profile* profile = |
49 Profile::FromBrowserContext(app_window->browser_context()); | 49 Profile::FromBrowserContext(app_window->browser_context()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 std::find(app_window_list_.begin(), app_window_list_.end(), app_window); | 140 std::find(app_window_list_.begin(), app_window_list_.end(), app_window); |
141 DCHECK(it != app_window_list_.end()); | 141 DCHECK(it != app_window_list_.end()); |
142 app_window_list_.erase(it); | 142 app_window_list_.erase(it); |
143 } | 143 } |
144 | 144 |
145 bool MultiProfileAppWindowLauncherController::UserHasAppOnActiveDesktop( | 145 bool MultiProfileAppWindowLauncherController::UserHasAppOnActiveDesktop( |
146 extensions::AppWindow* app_window) { | 146 extensions::AppWindow* app_window) { |
147 const std::string& app_id = app_window->extension_id(); | 147 const std::string& app_id = app_window->extension_id(); |
148 content::BrowserContext* app_context = app_window->browser_context(); | 148 content::BrowserContext* app_context = app_window->browser_context(); |
149 DCHECK(!app_context->IsOffTheRecord()); | 149 DCHECK(!app_context->IsOffTheRecord()); |
150 const std::string& current_user = multi_user_util::GetCurrentUserId(); | 150 const user_manager::UserID& current_user = multi_user_util::GetCurrentUserId()
; |
151 chrome::MultiUserWindowManager* manager = | 151 chrome::MultiUserWindowManager* manager = |
152 chrome::MultiUserWindowManager::GetInstance(); | 152 chrome::MultiUserWindowManager::GetInstance(); |
153 for (AppWindowList::iterator it = app_window_list_.begin(); | 153 for (AppWindowList::iterator it = app_window_list_.begin(); |
154 it != app_window_list_.end(); | 154 it != app_window_list_.end(); |
155 ++it) { | 155 ++it) { |
156 extensions::AppWindow* other_window = *it; | 156 extensions::AppWindow* other_window = *it; |
157 DCHECK(!other_window->browser_context()->IsOffTheRecord()); | 157 DCHECK(!other_window->browser_context()->IsOffTheRecord()); |
158 if (manager->IsWindowOnDesktopOfUser(other_window->GetNativeWindow(), | 158 if (manager->IsWindowOnDesktopOfUser(other_window->GetNativeWindow(), |
159 current_user) && | 159 current_user) && |
160 app_id == other_window->extension_id() && | 160 app_id == other_window->extension_id() && |
161 app_context == other_window->browser_context()) { | 161 app_context == other_window->browser_context()) { |
162 return true; | 162 return true; |
163 } | 163 } |
164 } | 164 } |
165 return false; | 165 return false; |
166 } | 166 } |
OLD | NEW |