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" |
11 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 12 #include "components/signin/core/account_id/account_id.h" |
12 #include "extensions/browser/app_window/app_window.h" | 13 #include "extensions/browser/app_window/app_window.h" |
13 #include "extensions/browser/app_window/native_app_window.h" | 14 #include "extensions/browser/app_window/native_app_window.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 bool ControlsWindow(aura::Window* window) { | 19 bool ControlsWindow(aura::Window* window) { |
19 return chrome::GetHostDesktopTypeForNativeWindow(window) == | 20 return chrome::GetHostDesktopTypeForNativeWindow(window) == |
20 chrome::HOST_DESKTOP_TYPE_ASH; | 21 chrome::HOST_DESKTOP_TYPE_ASH; |
21 } | 22 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (!ControlsWindow(app_window->GetNativeWindow())) | 80 if (!ControlsWindow(app_window->GetNativeWindow())) |
80 return; | 81 return; |
81 | 82 |
82 app_window_list_.push_back(app_window); | 83 app_window_list_.push_back(app_window); |
83 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); | 84 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); |
84 // If the window got created for a non active user but the user allowed to | 85 // If the window got created for a non active user but the user allowed to |
85 // teleport to the current user's desktop, we teleport it now. | 86 // teleport to the current user's desktop, we teleport it now. |
86 if (!multi_user_util::IsProfileFromActiveUser(profile) && | 87 if (!multi_user_util::IsProfileFromActiveUser(profile) && |
87 UserHasAppOnActiveDesktop(app_window)) { | 88 UserHasAppOnActiveDesktop(app_window)) { |
88 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 89 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( |
89 app_window->GetNativeWindow(), multi_user_util::GetCurrentUserId()); | 90 app_window->GetNativeWindow(), multi_user_util::GetCurrentAccountId()); |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
93 void MultiProfileAppWindowLauncherController::OnAppWindowShown( | 94 void MultiProfileAppWindowLauncherController::OnAppWindowShown( |
94 extensions::AppWindow* app_window, | 95 extensions::AppWindow* app_window, |
95 bool was_hidden) { | 96 bool was_hidden) { |
96 if (!ControlsWindow(app_window->GetNativeWindow())) | 97 if (!ControlsWindow(app_window->GetNativeWindow())) |
97 return; | 98 return; |
98 | 99 |
99 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); | 100 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 std::find(app_window_list_.begin(), app_window_list_.end(), app_window); | 141 std::find(app_window_list_.begin(), app_window_list_.end(), app_window); |
141 DCHECK(it != app_window_list_.end()); | 142 DCHECK(it != app_window_list_.end()); |
142 app_window_list_.erase(it); | 143 app_window_list_.erase(it); |
143 } | 144 } |
144 | 145 |
145 bool MultiProfileAppWindowLauncherController::UserHasAppOnActiveDesktop( | 146 bool MultiProfileAppWindowLauncherController::UserHasAppOnActiveDesktop( |
146 extensions::AppWindow* app_window) { | 147 extensions::AppWindow* app_window) { |
147 const std::string& app_id = app_window->extension_id(); | 148 const std::string& app_id = app_window->extension_id(); |
148 content::BrowserContext* app_context = app_window->browser_context(); | 149 content::BrowserContext* app_context = app_window->browser_context(); |
149 DCHECK(!app_context->IsOffTheRecord()); | 150 DCHECK(!app_context->IsOffTheRecord()); |
150 const std::string& current_user = multi_user_util::GetCurrentUserId(); | 151 const AccountId current_account_id = multi_user_util::GetCurrentAccountId(); |
151 chrome::MultiUserWindowManager* manager = | 152 chrome::MultiUserWindowManager* manager = |
152 chrome::MultiUserWindowManager::GetInstance(); | 153 chrome::MultiUserWindowManager::GetInstance(); |
153 for (AppWindowList::iterator it = app_window_list_.begin(); | 154 for (AppWindowList::iterator it = app_window_list_.begin(); |
154 it != app_window_list_.end(); | 155 it != app_window_list_.end(); |
155 ++it) { | 156 ++it) { |
156 extensions::AppWindow* other_window = *it; | 157 extensions::AppWindow* other_window = *it; |
157 DCHECK(!other_window->browser_context()->IsOffTheRecord()); | 158 DCHECK(!other_window->browser_context()->IsOffTheRecord()); |
158 if (manager->IsWindowOnDesktopOfUser(other_window->GetNativeWindow(), | 159 if (manager->IsWindowOnDesktopOfUser(other_window->GetNativeWindow(), |
159 current_user) && | 160 current_account_id) && |
160 app_id == other_window->extension_id() && | 161 app_id == other_window->extension_id() && |
161 app_context == other_window->browser_context()) { | 162 app_context == other_window->browser_context()) { |
162 return true; | 163 return true; |
163 } | 164 } |
164 } | 165 } |
165 return false; | 166 return false; |
166 } | 167 } |
OLD | NEW |