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

Unified Diff: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc

Issue 2345043002: arc: Prevent showing Arc app window for secondary user profile. (Closed)
Patch Set: use one point to add window to multi user manager Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
index 5038c15ee2d7e8662ad46f5b51cf017612bf5050..025640f360b473ab453a092306bd18b6b27d0e50 100644
--- a/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.cc
@@ -87,6 +87,18 @@ blink::WebScreenOrientationLockType BlinkOrientationLockFromMojom(
}
}
+int GetWindowTaskId(aura::Window* window) {
+ const std::string window_app_id = exo::ShellSurface::GetApplicationId(window);
+ if (window_app_id.empty())
+ return -1;
+
+ int task_id = -1;
+ if (sscanf(window_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
+ return -1;
+
+ return task_id;
+}
+
} // namespace
class ArcAppWindowLauncherController::AppWindow : public ui::BaseWindow {
@@ -292,6 +304,14 @@ void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) {
void ArcAppWindowLauncherController::OnWindowVisibilityChanged(
aura::Window* window,
bool visible) {
+ // Attach window to multi-user manager now to let it manage visibility state
+ // of the Arc window correctly.
+ if (GetWindowTaskId(window) > 0) {
+ chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
+ window,
+ user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
+ }
+
// The application id property should be set at this time. It is important to
// have window->IsVisible set to true before attaching to a controller because
// the window is registered in multi-user manager and this manager may
@@ -337,15 +357,8 @@ void ArcAppWindowLauncherController::AttachControllerToWindowsIfNeeded() {
void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
aura::Window* window) {
- const std::string window_app_id = exo::ShellSurface::GetApplicationId(window);
- if (window_app_id.empty())
- return;
-
- int task_id = -1;
- if (sscanf(window_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
- return;
-
- if (!task_id)
+ const int task_id = GetWindowTaskId(window);
+ if (task_id <= 0)
return;
// We need to add the observer after exo started observing shell
@@ -375,9 +388,6 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
DCHECK(app_window->controller());
ash::WmWindowAura::Get(window)->SetIntProperty(
ash::WmWindowProperty::SHELF_ID, app_window->shelf_id());
- chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
- window,
- user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
if (ash::WmShell::Get()
->maximize_mode_controller()
->IsMaximizeModeWindowManagerEnabled()) {
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698