| 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 cf1fac580762684a32e0c4b0300bc46b66eaa004..1ed66e16908e7454429df9c17f1fca860ad2fc1c 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
|
| @@ -246,15 +246,6 @@
|
| DISALLOW_COPY_AND_ASSIGN(AppWindow);
|
| };
|
|
|
| -struct ArcAppWindowLauncherController::TaskInfo {
|
| - TaskInfo(const std::string& package_name, const std::string& activity_name)
|
| - : package_name(package_name), activity_name(activity_name) {}
|
| - ~TaskInfo() {}
|
| -
|
| - std::string package_name;
|
| - std::string activity_name;
|
| -};
|
| -
|
| ArcAppWindowLauncherController::ArcAppWindowLauncherController(
|
| ChromeLauncherController* owner,
|
| ash::ShelfDelegate* shelf_delegate)
|
| @@ -320,7 +311,7 @@
|
| bool visible) {
|
| // The application id property should be set at this time.
|
| if (visible)
|
| - MayAttachContollerToWindow(window);
|
| + CheckForAppWindowWidget(window);
|
| }
|
|
|
| void ArcAppWindowLauncherController::OnWindowDestroying(aura::Window* window) {
|
| @@ -344,58 +335,39 @@
|
| return it->second.get();
|
| }
|
|
|
| -void ArcAppWindowLauncherController::MayAttachContollerToWindow(
|
| +void ArcAppWindowLauncherController::CheckForAppWindowWidget(
|
| aura::Window* window) {
|
| - const std::string window_app_id = exo::ShellSurface::GetApplicationId(window);
|
| - if (window_app_id.empty())
|
| + const std::string app_id = exo::ShellSurface::GetApplicationId(window);
|
| + if (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)
|
| - return;
|
| -
|
| - // We need to add the observer after exo started observing shell
|
| - // because we want to update the orientation after exo send
|
| - // the layout switch information.
|
| - if (!observing_shell_) {
|
| - observing_shell_ = true;
|
| - ash::WmShell::Get()->AddShellObserver(this);
|
| - }
|
| -
|
| - // Check if we have controller for this task.
|
| - if (GetAppWindowForTask(task_id))
|
| - return;
|
| -
|
| - // Create controller if we have task info.
|
| - TaskIdToTaskInfoMap::iterator it = task_id_to_task_info_.find(task_id);
|
| - if (it == task_id_to_task_info_.end())
|
| - return;
|
| -
|
| - const TaskInfo& task_info = *it->second;
|
| - const std::string app_id =
|
| - GetShelfAppIdFromArcAppId(ArcAppListPrefs::GetAppId(
|
| - task_info.package_name, task_info.activity_name));
|
| -
|
| - std::unique_ptr<AppWindow> app_window(new AppWindow(task_id, app_id, this));
|
| - app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window));
|
| - RegisterApp(app_window.get());
|
| - DCHECK(app_window->controller());
|
| - ash::SetShelfIDForWindow(app_window->shelf_id(), window);
|
| - chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
|
| - window,
|
| - user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
|
| - if (ash::WmShell::Get()
|
| - ->maximize_mode_controller()
|
| - ->IsMaximizeModeWindowManagerEnabled()) {
|
| - SetOrientationLockForAppWindow(app_window.get());
|
| - }
|
| - task_id_to_app_window_[task_id] = std::move(app_window);
|
| -
|
| - // TaskInfo is no longer needed. Discard it.
|
| - task_id_to_task_info_.erase(task_id);
|
| + if (sscanf(app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1)
|
| + return;
|
| +
|
| + if (task_id) {
|
| + // We need to add the observer after exo started observing shell
|
| + // because we want to update the orientation after exo send
|
| + // the layout switch information.
|
| + if (!observing_shell_) {
|
| + observing_shell_ = true;
|
| + ash::WmShell::Get()->AddShellObserver(this);
|
| + }
|
| +
|
| + AppWindow* app_window = GetAppWindowForTask(task_id);
|
| + if (app_window) {
|
| + app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window));
|
| + ash::SetShelfIDForWindow(app_window->shelf_id(), window);
|
| + chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner(
|
| + window,
|
| + user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId());
|
| + if (ash::Shell::GetInstance()
|
| + ->maximize_mode_controller()
|
| + ->IsMaximizeModeWindowManagerEnabled()) {
|
| + SetOrientationLockForAppWindow(app_window);
|
| + }
|
| + }
|
| + }
|
| }
|
|
|
| void ArcAppWindowLauncherController::OnAppReadyChanged(
|
| @@ -431,17 +403,20 @@
|
| const std::string& package_name,
|
| const std::string& activity_name) {
|
| DCHECK(!GetAppWindowForTask(task_id));
|
| - std::unique_ptr<TaskInfo> task_info(
|
| - new TaskInfo(package_name, activity_name));
|
| - task_id_to_task_info_[task_id] = std::move(task_info);
|
| -
|
| - for (auto* window : observed_windows_)
|
| - MayAttachContollerToWindow(window);
|
| +
|
| + const std::string app_id = GetShelfAppIdFromArcAppId(
|
| + ArcAppListPrefs::GetAppId(package_name, activity_name));
|
| +
|
| + std::unique_ptr<AppWindow> app_window(new AppWindow(task_id, app_id, this));
|
| + RegisterApp(app_window.get());
|
| +
|
| + task_id_to_app_window_[task_id] = std::move(app_window);
|
| +
|
| + for (auto window : observed_windows_)
|
| + CheckForAppWindowWidget(window);
|
| }
|
|
|
| void ArcAppWindowLauncherController::OnTaskDestroyed(int task_id) {
|
| - task_id_to_task_info_.erase(task_id);
|
| -
|
| TaskIdToAppWindow::iterator it = task_id_to_app_window_.find(task_id);
|
| if (it == task_id_to_app_window_.end())
|
| return;
|
|
|