| 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/launcher/chrome_launcher_controller.h" |
| 9 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 10 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 11 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 11 #include "components/signin/core/account_id/account_id.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 MultiProfileAppWindowLauncherController:: | 17 MultiProfileAppWindowLauncherController:: |
| 17 MultiProfileAppWindowLauncherController(ChromeLauncherController* owner) | 18 MultiProfileAppWindowLauncherController(ChromeLauncherController* owner) |
| 18 : ExtensionAppWindowLauncherController(owner) {} | 19 : ExtensionAppWindowLauncherController(owner) { |
| 20 // We might have already active windows. |
| 21 extensions::AppWindowRegistry* registry = |
| 22 extensions::AppWindowRegistry::Get(owner->profile()); |
| 23 app_window_list_.insert(app_window_list_.end(), |
| 24 registry->app_windows().begin(), |
| 25 registry->app_windows().end()); |
| 26 } |
| 19 | 27 |
| 20 MultiProfileAppWindowLauncherController:: | 28 MultiProfileAppWindowLauncherController:: |
| 21 ~MultiProfileAppWindowLauncherController() { | 29 ~MultiProfileAppWindowLauncherController() { |
| 22 // We need to remove all Registry observers for added users. | 30 // We need to remove all Registry observers for added users. |
| 23 for (AppWindowRegistryList::iterator it = multi_user_registry_.begin(); | 31 for (AppWindowRegistryList::iterator it = multi_user_registry_.begin(); |
| 24 it != multi_user_registry_.end(); | 32 it != multi_user_registry_.end(); |
| 25 ++it) | 33 ++it) |
| 26 (*it)->RemoveObserver(this); | 34 (*it)->RemoveObserver(this); |
| 27 } | 35 } |
| 28 | 36 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 54 app_window->GetNativeWindow()->IsVisible())) | 62 app_window->GetNativeWindow()->IsVisible())) |
| 55 RegisterApp(*it); | 63 RegisterApp(*it); |
| 56 } | 64 } |
| 57 } | 65 } |
| 58 | 66 |
| 59 void MultiProfileAppWindowLauncherController::AdditionalUserAddedToSession( | 67 void MultiProfileAppWindowLauncherController::AdditionalUserAddedToSession( |
| 60 Profile* profile) { | 68 Profile* profile) { |
| 61 // Each users AppWindowRegistry needs to be observed. | 69 // Each users AppWindowRegistry needs to be observed. |
| 62 extensions::AppWindowRegistry* registry = | 70 extensions::AppWindowRegistry* registry = |
| 63 extensions::AppWindowRegistry::Get(profile); | 71 extensions::AppWindowRegistry::Get(profile); |
| 72 DCHECK(registry->app_windows().empty()); |
| 64 multi_user_registry_.push_back(registry); | 73 multi_user_registry_.push_back(registry); |
| 65 registry->AddObserver(this); | 74 registry->AddObserver(this); |
| 66 } | 75 } |
| 67 | 76 |
| 68 void MultiProfileAppWindowLauncherController::OnAppWindowAdded( | 77 void MultiProfileAppWindowLauncherController::OnAppWindowAdded( |
| 69 extensions::AppWindow* app_window) { | 78 extensions::AppWindow* app_window) { |
| 70 app_window_list_.push_back(app_window); | 79 app_window_list_.push_back(app_window); |
| 71 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); | 80 Profile* profile = Profile::FromBrowserContext(app_window->browser_context()); |
| 72 // If the window got created for a non active user but the user allowed to | 81 // If the window got created for a non active user but the user allowed to |
| 73 // teleport to the current user's desktop, we teleport it now. | 82 // teleport to the current user's desktop, we teleport it now. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DCHECK(!other_window->browser_context()->IsOffTheRecord()); | 145 DCHECK(!other_window->browser_context()->IsOffTheRecord()); |
| 137 if (manager->IsWindowOnDesktopOfUser(other_window->GetNativeWindow(), | 146 if (manager->IsWindowOnDesktopOfUser(other_window->GetNativeWindow(), |
| 138 current_account_id) && | 147 current_account_id) && |
| 139 app_id == other_window->extension_id() && | 148 app_id == other_window->extension_id() && |
| 140 app_context == other_window->browser_context()) { | 149 app_context == other_window->browser_context()) { |
| 141 return true; | 150 return true; |
| 142 } | 151 } |
| 143 } | 152 } |
| 144 return false; | 153 return false; |
| 145 } | 154 } |
| OLD | NEW |