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/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
9 #include "ash/common/shelf/shelf_delegate.h" | 9 #include "ash/common/shelf/shelf_delegate.h" |
10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ArcAppWindowLauncherItemController* controller_ = nullptr; | 252 ArcAppWindowLauncherItemController* controller_ = nullptr; |
253 // Unowned pointer, represents host Arc window. | 253 // Unowned pointer, represents host Arc window. |
254 | 254 |
255 DISALLOW_COPY_AND_ASSIGN(AppWindow); | 255 DISALLOW_COPY_AND_ASSIGN(AppWindow); |
256 }; | 256 }; |
257 | 257 |
258 ArcAppWindowLauncherController::ArcAppWindowLauncherController( | 258 ArcAppWindowLauncherController::ArcAppWindowLauncherController( |
259 ChromeLauncherController* owner, | 259 ChromeLauncherController* owner, |
260 ash::ShelfDelegate* shelf_delegate) | 260 ash::ShelfDelegate* shelf_delegate) |
261 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { | 261 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { |
262 if (arc::ArcAuthService::IsAllowedForProfile(owner->GetProfile())) { | 262 if (arc::ArcAuthService::IsAllowedForProfile(owner->profile())) { |
263 observed_profile_ = owner->GetProfile(); | 263 observed_profile_ = owner->profile(); |
264 StartObserving(observed_profile_); | 264 StartObserving(observed_profile_); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { | 268 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { |
269 if (observed_profile_) | 269 if (observed_profile_) |
270 StopObserving(observed_profile_); | 270 StopObserving(observed_profile_); |
271 if (observing_shell_) | 271 if (observing_shell_) |
272 ash::WmShell::Get()->RemoveShellObserver(this); | 272 ash::WmShell::Get()->RemoveShellObserver(this); |
273 } | 273 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( | 343 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( |
344 window, | 344 window, |
345 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); | 345 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); |
346 } | 346 } |
347 | 347 |
348 // The application id property should be set at this time. It is important to | 348 // The application id property should be set at this time. It is important to |
349 // have window->IsVisible set to true before attaching to a controller because | 349 // have window->IsVisible set to true before attaching to a controller because |
350 // the window is registered in multi-user manager and this manager may | 350 // the window is registered in multi-user manager and this manager may |
351 // consider this new window as hidden for current profile. Multi-user manager | 351 // consider this new window as hidden for current profile. Multi-user manager |
352 // uses OnWindowVisibilityChanging event to update window state. | 352 // uses OnWindowVisibilityChanging event to update window state. |
353 if (visible && observed_profile_ == owner()->GetProfile()) | 353 if (visible && observed_profile_ == owner()->profile()) |
354 AttachControllerToWindowIfNeeded(window); | 354 AttachControllerToWindowIfNeeded(window); |
355 } | 355 } |
356 | 356 |
357 void ArcAppWindowLauncherController::OnWindowDestroying(aura::Window* window) { | 357 void ArcAppWindowLauncherController::OnWindowDestroying(aura::Window* window) { |
358 auto it = | 358 auto it = |
359 std::find(observed_windows_.begin(), observed_windows_.end(), window); | 359 std::find(observed_windows_.begin(), observed_windows_.end(), window); |
360 DCHECK(it != observed_windows_.end()); | 360 DCHECK(it != observed_windows_.end()); |
361 observed_windows_.erase(it); | 361 observed_windows_.erase(it); |
362 window->RemoveObserver(this); | 362 window->RemoveObserver(this); |
363 | 363 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 int task_id, | 468 int task_id, |
469 const std::string& package_name, | 469 const std::string& package_name, |
470 const std::string& activity_name) { | 470 const std::string& activity_name) { |
471 DCHECK(!GetAppWindowForTask(task_id)); | 471 DCHECK(!GetAppWindowForTask(task_id)); |
472 const std::string arc_app_id = | 472 const std::string arc_app_id = |
473 ArcAppListPrefs::GetAppId(package_name, activity_name); | 473 ArcAppListPrefs::GetAppId(package_name, activity_name); |
474 const std::string shelf_app_id = GetShelfAppIdFromArcAppId(arc_app_id); | 474 const std::string shelf_app_id = GetShelfAppIdFromArcAppId(arc_app_id); |
475 task_id_to_app_window_info_[task_id] = | 475 task_id_to_app_window_info_[task_id] = |
476 base::MakeUnique<AppWindowInfo>(shelf_app_id); | 476 base::MakeUnique<AppWindowInfo>(shelf_app_id); |
477 // Don't create shelf icon for non-primary user. | 477 // Don't create shelf icon for non-primary user. |
478 if (observed_profile_ != owner()->GetProfile()) | 478 if (observed_profile_ != owner()->profile()) |
479 return; | 479 return; |
480 | 480 |
481 AttachControllerToWindowsIfNeeded(); | 481 AttachControllerToWindowsIfNeeded(); |
482 | 482 |
483 // Some tasks can be started in background and might have no window until | 483 // Some tasks can be started in background and might have no window until |
484 // pushed to the front. We need its representation on the shelf to give a user | 484 // pushed to the front. We need its representation on the shelf to give a user |
485 // control over it. | 485 // control over it. |
486 AttachControllerToTask(shelf_app_id, task_id); | 486 AttachControllerToTask(shelf_app_id, task_id); |
487 } | 487 } |
488 | 488 |
(...skipping 14 matching lines...) Expand all Loading... |
503 if (!controller->window_count()) { | 503 if (!controller->window_count()) { |
504 owner()->CloseLauncherItem(controller->shelf_id()); | 504 owner()->CloseLauncherItem(controller->shelf_id()); |
505 app_controller_map_.erase(it_controller); | 505 app_controller_map_.erase(it_controller); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 task_id_to_app_window_info_.erase(it); | 509 task_id_to_app_window_info_.erase(it); |
510 } | 510 } |
511 | 511 |
512 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { | 512 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { |
513 if (observed_profile_ != owner()->GetProfile()) { | 513 if (observed_profile_ != owner()->profile()) { |
514 active_task_id_ = task_id; | 514 active_task_id_ = task_id; |
515 return; | 515 return; |
516 } | 516 } |
517 | 517 |
518 AppWindow* previous_app_window = GetAppWindowForTask(active_task_id_); | 518 AppWindow* previous_app_window = GetAppWindowForTask(active_task_id_); |
519 if (previous_app_window) { | 519 if (previous_app_window) { |
520 owner()->SetItemStatus(previous_app_window->shelf_id(), | 520 owner()->SetItemStatus(previous_app_window->shelf_id(), |
521 ash::STATUS_RUNNING); | 521 ash::STATUS_RUNNING); |
522 previous_app_window->SetFullscreenMode( | 522 previous_app_window->SetFullscreenMode( |
523 previous_app_window->widget() && | 523 previous_app_window->widget() && |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 716 |
717 if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { | 717 if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { |
718 // Resolve the orientation when it first resolved. | 718 // Resolve the orientation when it first resolved. |
719 orientation_lock = GetCurrentOrientation(); | 719 orientation_lock = GetCurrentOrientation(); |
720 info->set_requested_orientation_lock(orientation_lock); | 720 info->set_requested_orientation_lock(orientation_lock); |
721 } | 721 } |
722 ash::Shell* shell = ash::Shell::GetInstance(); | 722 ash::Shell* shell = ash::Shell::GetInstance(); |
723 shell->screen_orientation_controller()->LockOrientationForWindow( | 723 shell->screen_orientation_controller()->LockOrientationForWindow( |
724 window, BlinkOrientationLockFromMojom(orientation_lock)); | 724 window, BlinkOrientationLockFromMojom(orientation_lock)); |
725 } | 725 } |
OLD | NEW |