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

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: 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
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..c2d7b1d2dcaa283d0a6734a8a9c0b8a252efb464 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
@@ -289,16 +289,30 @@ void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) {
window->AddObserver(this);
}
-void ArcAppWindowLauncherController::OnWindowVisibilityChanged(
+void ArcAppWindowLauncherController::OnWindowPropertyChanged(
aura::Window* window,
- bool visible) {
- // 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
- // consider this new window as hidden for current profile. Multi-user manager
- // uses OnWindowVisibilityChanging event to update window state.
- if (visible && observed_profile_ == owner()->GetProfile())
- AttachControllerToWindowIfNeeded(window);
+ const void* key,
+ intptr_t old) {
+ if (!exo::ShellSurface::IsApplicationWindowReadyPropertyKey(key))
+ return;
+
+ DCHECK(exo::ShellSurface::IsApplicationWindowReadyToShow(window));
+ if (observed_profile_ == owner()->GetProfile()) {
+ if (AttachControllerToWindowIfNeeded(window))
+ window->Show();
+ } else {
+ chrome::MultiUserWindowManager* multi_user_manager =
+ chrome::MultiUserWindowManager::GetInstance();
+ if (multi_user_manager->GetWindowOwner(window).empty()) {
+ multi_user_manager->SetWindowOwner(
+ window,
+ user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
+ // Now the window is registered for primary user however it is marked as
+ // hidden. Manually mark it as visible in order to get it automatically
+ // restored when user switches back to primary profile.
+ multi_user_manager->MarkWindowAsVisible(window);
+ }
+ }
}
void ArcAppWindowLauncherController::OnWindowDestroying(aura::Window* window) {
@@ -335,18 +349,21 @@ void ArcAppWindowLauncherController::AttachControllerToWindowsIfNeeded() {
AttachControllerToWindowIfNeeded(window);
}
-void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
+bool ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
aura::Window* window) {
+ if (!exo::ShellSurface::IsApplicationWindowReadyToShow(window))
+ return false;
+
const std::string window_app_id = exo::ShellSurface::GetApplicationId(window);
if (window_app_id.empty())
- return;
+ return false;
int task_id = -1;
if (sscanf(window_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
- return;
+ return false;
if (!task_id)
- return;
+ return false;
// We need to add the observer after exo started observing shell
// because we want to update the orientation after exo send
@@ -358,12 +375,12 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
// Check if we have controller for this task.
if (GetAppWindowForTask(task_id))
- return;
+ return false;
// Create controller if we have task info.
TaskIdToShelfAppIdMap::iterator it = task_id_to_shelf_app_id_.find(task_id);
if (it == task_id_to_shelf_app_id_.end())
- return;
+ return false;
const std::string& app_id = it->second;
@@ -384,6 +401,7 @@ void ArcAppWindowLauncherController::AttachControllerToWindowIfNeeded(
SetOrientationLockForAppWindow(app_window.get());
}
task_id_to_app_window_[task_id] = std::move(app_window);
+ return true;
}
void ArcAppWindowLauncherController::OnAppReadyChanged(

Powered by Google App Engine
This is Rietveld 408576698