| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 4 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
| 5 | 5 |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "ash/display/screen_orientation_controller_chromeos.h" | 8 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 9 #include "ash/public/cpp/window_properties.h" | 9 #include "ash/public/cpp/window_properties.h" |
| 10 #include "ash/shared/app_types.h" | 10 #include "ash/shared/app_types.h" |
| 11 #include "ash/shelf/shelf_model.h" | 11 #include "ash/shelf/shelf_model.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| 14 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
| 15 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 16 #include "ash/wm_window.h" | 16 #include "ash/wm_window.h" |
| 17 #include "base/bind.h" | 17 #include "base/bind.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "chrome/browser/chromeos/arc/arc_util.h" | 19 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 21 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 22 #include "chrome/browser/ui/ash/launcher/arc_app_window.h" | 22 #include "chrome/browser/ui/ash/launcher/arc_app_window.h" |
| 23 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller
.h" | 23 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller
.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 DCHECK(widget); | 297 DCHECK(widget); |
| 298 DCHECK(!info->app_window()); | 298 DCHECK(!info->app_window()); |
| 299 info->set_app_window(base::MakeUnique<ArcAppWindow>( | 299 info->set_app_window(base::MakeUnique<ArcAppWindow>( |
| 300 task_id, info->app_shelf_id(), widget, this)); | 300 task_id, info->app_shelf_id(), widget, this)); |
| 301 info->app_window()->SetDescription(info->title(), info->icon_data_png()); | 301 info->app_window()->SetDescription(info->title(), info->icon_data_png()); |
| 302 RegisterApp(info); | 302 RegisterApp(info); |
| 303 DCHECK(info->app_window()->controller()); | 303 DCHECK(info->app_window()->controller()); |
| 304 const ash::ShelfID shelf_id(info->app_window()->shelf_id()); | 304 const ash::ShelfID shelf_id(info->app_window()->shelf_id()); |
| 305 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize())); | 305 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize())); |
| 306 if (ash::Shell::Get() | 306 if (ash::Shell::Get() |
| 307 ->maximize_mode_controller() | 307 ->tablet_mode_controller() |
| 308 ->IsMaximizeModeWindowManagerEnabled()) { | 308 ->IsTabletModeWindowManagerEnabled()) { |
| 309 SetOrientationLockForAppWindow(info->app_window()); | 309 SetOrientationLockForAppWindow(info->app_window()); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 void ArcAppWindowLauncherController::OnAppReadyChanged( | 313 void ArcAppWindowLauncherController::OnAppReadyChanged( |
| 314 const std::string& arc_app_id, | 314 const std::string& arc_app_id, |
| 315 bool ready) { | 315 bool ready) { |
| 316 if (!ready) | 316 if (!ready) |
| 317 OnAppRemoved(arc_app_id); | 317 OnAppRemoved(arc_app_id); |
| 318 } | 318 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (!info->has_requested_orientation_lock()) { | 413 if (!info->has_requested_orientation_lock()) { |
| 414 info->set_requested_orientation_lock(arc::mojom::OrientationLock::NONE); | 414 info->set_requested_orientation_lock(arc::mojom::OrientationLock::NONE); |
| 415 } | 415 } |
| 416 } else { | 416 } else { |
| 417 info->set_requested_orientation_lock(orientation_lock); | 417 info->set_requested_orientation_lock(orientation_lock); |
| 418 info->set_lock_completion_behavior( | 418 info->set_lock_completion_behavior( |
| 419 ScreenOrientationController::LockCompletionBehavior::None); | 419 ScreenOrientationController::LockCompletionBehavior::None); |
| 420 } | 420 } |
| 421 | 421 |
| 422 if (ash::Shell::Get() | 422 if (ash::Shell::Get() |
| 423 ->maximize_mode_controller() | 423 ->tablet_mode_controller() |
| 424 ->IsMaximizeModeWindowManagerEnabled()) { | 424 ->IsTabletModeWindowManagerEnabled()) { |
| 425 ArcAppWindow* app_window = info->app_window(); | 425 ArcAppWindow* app_window = info->app_window(); |
| 426 if (app_window) | 426 if (app_window) |
| 427 SetOrientationLockForAppWindow(app_window); | 427 SetOrientationLockForAppWindow(app_window); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { | 431 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { |
| 432 if (observed_profile_ != owner()->profile()) { | 432 if (observed_profile_ != owner()->profile()) { |
| 433 active_task_id_ = task_id; | 433 active_task_id_ = task_id; |
| 434 return; | 434 return; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 void ArcAppWindowLauncherController::OnWindowActivated( | 494 void ArcAppWindowLauncherController::OnWindowActivated( |
| 495 aura::client::ActivationChangeObserver::ActivationReason reason, | 495 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 496 aura::Window* gained_active, | 496 aura::Window* gained_active, |
| 497 aura::Window* lost_active) { | 497 aura::Window* lost_active) { |
| 498 AppWindowLauncherController::OnWindowActivated(reason, gained_active, | 498 AppWindowLauncherController::OnWindowActivated(reason, gained_active, |
| 499 lost_active); | 499 lost_active); |
| 500 OnTaskSetActive(active_task_id_); | 500 OnTaskSetActive(active_task_id_); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void ArcAppWindowLauncherController::OnMaximizeModeStarted() { | 503 void ArcAppWindowLauncherController::OnTabletModeStarted() { |
| 504 for (auto& it : task_id_to_app_window_info_) { | 504 for (auto& it : task_id_to_app_window_info_) { |
| 505 ArcAppWindow* app_window = it.second->app_window(); | 505 ArcAppWindow* app_window = it.second->app_window(); |
| 506 if (app_window) | 506 if (app_window) |
| 507 SetOrientationLockForAppWindow(app_window); | 507 SetOrientationLockForAppWindow(app_window); |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 | 510 |
| 511 void ArcAppWindowLauncherController::OnMaximizeModeEnded() { | 511 void ArcAppWindowLauncherController::OnTabletModeEnded() { |
| 512 ash::ScreenOrientationController* orientation_controller = | 512 ash::ScreenOrientationController* orientation_controller = |
| 513 ash::Shell::Get()->screen_orientation_controller(); | 513 ash::Shell::Get()->screen_orientation_controller(); |
| 514 // Don't unlock one by one because it'll switch to next rotation. | 514 // Don't unlock one by one because it'll switch to next rotation. |
| 515 orientation_controller->UnlockAll(); | 515 orientation_controller->UnlockAll(); |
| 516 } | 516 } |
| 517 | 517 |
| 518 void ArcAppWindowLauncherController::StartObserving(Profile* profile) { | 518 void ArcAppWindowLauncherController::StartObserving(Profile* profile) { |
| 519 aura::Env* env = aura::Env::GetInstanceDontCreate(); | 519 aura::Env* env = aura::Env::GetInstanceDontCreate(); |
| 520 if (env) | 520 if (env) |
| 521 env->AddObserver(this); | 521 env->AddObserver(this); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); | 628 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); |
| 629 if (arc_app_id.empty()) | 629 if (arc_app_id.empty()) |
| 630 return -1; | 630 return -1; |
| 631 | 631 |
| 632 int task_id = -1; | 632 int task_id = -1; |
| 633 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) | 633 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) |
| 634 return -1; | 634 return -1; |
| 635 | 635 |
| 636 return task_id; | 636 return task_id; |
| 637 } | 637 } |
| OLD | NEW |