| 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/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 void Show() override { | 166 void Show() override { |
| 167 // TODO(khmel): support window minimizing. | 167 // TODO(khmel): support window minimizing. |
| 168 } | 168 } |
| 169 | 169 |
| 170 void ShowInactive() override { NOTREACHED(); } | 170 void ShowInactive() override { NOTREACHED(); } |
| 171 | 171 |
| 172 void Hide() override { NOTREACHED(); } | 172 void Hide() override { NOTREACHED(); } |
| 173 | 173 |
| 174 void Close() override { | 174 void Close() override { arc::CloseTask(task_id_); } |
| 175 arc::mojom::AppInstance* app_instance = GetAppInstance(); | |
| 176 if (!app_instance) | |
| 177 return; | |
| 178 app_instance->CloseTask(task_id_); | |
| 179 } | |
| 180 | 175 |
| 181 void Activate() override { | 176 void Activate() override { arc::SetTaskActive(task_id_); } |
| 182 arc::mojom::AppInstance* app_instance = GetAppInstance(); | |
| 183 if (!app_instance) | |
| 184 return; | |
| 185 app_instance->SetTaskActive(task_id_); | |
| 186 if (widget_) | |
| 187 widget_->Activate(); | |
| 188 } | |
| 189 | 177 |
| 190 void Deactivate() override { NOTREACHED(); } | 178 void Deactivate() override { NOTREACHED(); } |
| 191 | 179 |
| 192 void Maximize() override { NOTREACHED(); } | 180 void Maximize() override { NOTREACHED(); } |
| 193 | 181 |
| 194 void Minimize() override { | 182 void Minimize() override { |
| 195 if (widget_) | 183 if (widget_) |
| 196 widget_->Minimize(); | 184 widget_->Minimize(); |
| 197 } | 185 } |
| 198 | 186 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 216 void set_requested_orientation_lock(arc::mojom::OrientationLock lock) { | 204 void set_requested_orientation_lock(arc::mojom::OrientationLock lock) { |
| 217 has_requested_orientation_lock_ = true; | 205 has_requested_orientation_lock_ = true; |
| 218 requested_orientation_lock_ = lock; | 206 requested_orientation_lock_ = lock; |
| 219 } | 207 } |
| 220 | 208 |
| 221 bool has_requested_orientation_lock() const { | 209 bool has_requested_orientation_lock() const { |
| 222 return has_requested_orientation_lock_; | 210 return has_requested_orientation_lock_; |
| 223 } | 211 } |
| 224 | 212 |
| 225 private: | 213 private: |
| 226 arc::mojom::AppInstance* GetAppInstance() { | |
| 227 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | |
| 228 arc::mojom::AppInstance* app_instance = | |
| 229 bridge_service ? bridge_service->app()->instance() : nullptr; | |
| 230 if (!app_instance) { | |
| 231 VLOG(2) << "Arc Bridge is not available."; | |
| 232 return nullptr; | |
| 233 } | |
| 234 | |
| 235 if (bridge_service->app()->version() < 3) { | |
| 236 VLOG(2) << "Arc Bridge has old version for apps." | |
| 237 << bridge_service->app()->version(); | |
| 238 return nullptr; | |
| 239 } | |
| 240 return app_instance; | |
| 241 } | |
| 242 | |
| 243 int task_id_; | 214 int task_id_; |
| 244 ash::ShelfID shelf_id_ = 0; | 215 ash::ShelfID shelf_id_ = 0; |
| 245 std::string app_id_; | 216 std::string app_id_; |
| 246 FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; | 217 FullScreenMode fullscreen_mode_ = FullScreenMode::NOT_DEFINED; |
| 247 // Unowned pointers | 218 // Unowned pointers |
| 248 ArcAppWindowLauncherController* owner_; | 219 ArcAppWindowLauncherController* owner_; |
| 249 ArcAppWindowLauncherItemController* controller_ = nullptr; | 220 ArcAppWindowLauncherItemController* controller_ = nullptr; |
| 250 // Unowned pointer, represents host Arc window. | 221 // Unowned pointer, represents host Arc window. |
| 251 views::Widget* widget_ = nullptr; | 222 views::Widget* widget_ = nullptr; |
| 252 | 223 |
| 253 arc::mojom::OrientationLock requested_orientation_lock_ = | 224 arc::mojom::OrientationLock requested_orientation_lock_ = |
| 254 arc::mojom::OrientationLock::NONE; | 225 arc::mojom::OrientationLock::NONE; |
| 255 bool has_requested_orientation_lock_ = false; | 226 bool has_requested_orientation_lock_ = false; |
| 256 | 227 |
| 257 DISALLOW_COPY_AND_ASSIGN(AppWindow); | 228 DISALLOW_COPY_AND_ASSIGN(AppWindow); |
| 258 }; | 229 }; |
| 259 | 230 |
| 260 struct ArcAppWindowLauncherController::TaskInfo { | |
| 261 TaskInfo(const std::string& package_name, const std::string& activity_name) | |
| 262 : package_name(package_name), activity_name(activity_name) {} | |
| 263 ~TaskInfo() {} | |
| 264 | |
| 265 std::string package_name; | |
| 266 std::string activity_name; | |
| 267 }; | |
| 268 | |
| 269 ArcAppWindowLauncherController::ArcAppWindowLauncherController( | 231 ArcAppWindowLauncherController::ArcAppWindowLauncherController( |
| 270 ChromeLauncherController* owner, | 232 ChromeLauncherController* owner, |
| 271 ash::ShelfDelegate* shelf_delegate) | 233 ash::ShelfDelegate* shelf_delegate) |
| 272 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { | 234 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { |
| 273 if (arc::ArcAuthService::IsAllowedForProfile(owner->GetProfile())) { | 235 if (arc::ArcAuthService::IsAllowedForProfile(owner->GetProfile())) { |
| 274 observed_profile_ = owner->GetProfile(); | 236 observed_profile_ = owner->GetProfile(); |
| 275 StartObserving(observed_profile_); | 237 StartObserving(observed_profile_); |
| 276 } | 238 } |
| 277 } | 239 } |
| 278 | 240 |
| 279 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { | 241 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { |
| 280 if (observed_profile_) | 242 if (observed_profile_) |
| 281 StopObserving(observed_profile_); | 243 StopObserving(observed_profile_); |
| 282 if (observing_shell_) | 244 if (observing_shell_) |
| 283 ash::WmShell::Get()->RemoveShellObserver(this); | 245 ash::WmShell::Get()->RemoveShellObserver(this); |
| 284 | 246 |
| 285 // Special for M53 branch. Due different deletion order of the shell | 247 // Special for M53 branch. Due different deletion order of the shell |
| 286 // and shelf launcher controllers we have to care about pending Arc | 248 // and shelf launcher controllers we have to care about pending Arc |
| 287 // items because we cannot observe window detroying events anymore. | 249 // items because we cannot observe window detroying events anymore. |
| 288 // This is the reason of crashing unit_tests: ArcOrientationLock | 250 // This is the reason of crashing unit_tests: ArcOrientationLock |
| 289 for (auto& it : task_id_to_app_window_) | 251 for (auto& it : task_id_to_app_window_) |
| 290 UnregisterApp(it.second.get()); | 252 UnregisterApp(it.second.get(), true); |
| 291 } | 253 } |
| 292 | 254 |
| 293 // static | 255 // static |
| 294 std::string ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( | 256 std::string ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( |
| 295 const std::string& arc_app_id) { | 257 const std::string& arc_app_id) { |
| 296 return arc_app_id == arc::kPlayStoreAppId ? ArcSupportHost::kHostAppId | 258 return arc_app_id == arc::kPlayStoreAppId ? ArcSupportHost::kHostAppId |
| 297 : arc_app_id; | 259 : arc_app_id; |
| 298 } | 260 } |
| 299 | 261 |
| 300 // static | 262 // static |
| 301 std::string ArcAppWindowLauncherController::GetArcAppIdFromShelfAppId( | 263 std::string ArcAppWindowLauncherController::GetArcAppIdFromShelfAppId( |
| 302 const std::string& shelf_app_id) { | 264 const std::string& shelf_app_id) { |
| 303 return shelf_app_id == ArcSupportHost::kHostAppId ? arc::kPlayStoreAppId | 265 return shelf_app_id == ArcSupportHost::kHostAppId ? arc::kPlayStoreAppId |
| 304 : shelf_app_id; | 266 : shelf_app_id; |
| 305 } | 267 } |
| 306 | 268 |
| 307 void ArcAppWindowLauncherController::ActiveUserChanged( | 269 void ArcAppWindowLauncherController::ActiveUserChanged( |
| 308 const std::string& user_email) { | 270 const std::string& user_email) { |
| 309 for (auto& it : task_id_to_app_window_) { | 271 for (auto& it : task_id_to_app_window_) { |
| 310 AppWindow* app_window = it.second.get(); | 272 AppWindow* app_window = it.second.get(); |
| 311 if (user_email == | 273 if (user_email == |
| 312 user_manager::UserManager::Get() | 274 user_manager::UserManager::Get() |
| 313 ->GetPrimaryUser() | 275 ->GetPrimaryUser() |
| 314 ->GetAccountId() | 276 ->GetAccountId() |
| 315 .GetUserEmail()) { | 277 .GetUserEmail()) { |
| 316 RegisterApp(app_window); | 278 RegisterApp(app_window); |
| 317 } else { | 279 } else { |
| 318 UnregisterApp(app_window); | 280 UnregisterApp(app_window, true); |
| 319 } | 281 } |
| 320 } | 282 } |
| 321 } | 283 } |
| 322 | 284 |
| 323 void ArcAppWindowLauncherController::AdditionalUserAddedToSession( | 285 void ArcAppWindowLauncherController::AdditionalUserAddedToSession( |
| 324 Profile* profile) { | 286 Profile* profile) { |
| 325 DCHECK(!arc::ArcAuthService::IsAllowedForProfile(profile)); | 287 DCHECK(!arc::ArcAuthService::IsAllowedForProfile(profile)); |
| 326 } | 288 } |
| 327 | 289 |
| 328 void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) { | 290 void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 341 MayAttachContollerToWindow(window); | 303 MayAttachContollerToWindow(window); |
| 342 } | 304 } |
| 343 | 305 |
| 344 void ArcAppWindowLauncherController::OnWindowDestroying(aura::Window* window) { | 306 void ArcAppWindowLauncherController::OnWindowDestroying(aura::Window* window) { |
| 345 auto it = | 307 auto it = |
| 346 std::find(observed_windows_.begin(), observed_windows_.end(), window); | 308 std::find(observed_windows_.begin(), observed_windows_.end(), window); |
| 347 DCHECK(it != observed_windows_.end()); | 309 DCHECK(it != observed_windows_.end()); |
| 348 observed_windows_.erase(it); | 310 observed_windows_.erase(it); |
| 349 window->RemoveObserver(this); | 311 window->RemoveObserver(this); |
| 350 | 312 |
| 351 for (auto& it : task_id_to_app_window_) { | 313 auto it_app_window = |
| 352 if (it.second->GetNativeWindow() == window) { | 314 std::find_if(task_id_to_app_window_.begin(), task_id_to_app_window_.end(), |
| 353 OnTaskDestroyed(it.second->task_id()); | 315 [window](const TaskIdToAppWindow::value_type& pair) { |
| 354 break; | 316 return pair.second->GetNativeWindow() == window; |
| 355 } | 317 }); |
| 318 if (it_app_window != task_id_to_app_window_.end()) { |
| 319 // Note, window may be recreated in some cases, so do not close controller |
| 320 // on window destroying. Controller will be closed onTaskDestroyed event |
| 321 // which is generated when actual task is destroyed. |
| 322 UnregisterApp(it_app_window->second.get(), false); |
| 323 task_id_to_app_window_.erase(it_app_window); |
| 356 } | 324 } |
| 357 } | 325 } |
| 358 | 326 |
| 359 ArcAppWindowLauncherController::AppWindow* | 327 ArcAppWindowLauncherController::AppWindow* |
| 360 ArcAppWindowLauncherController::GetAppWindowForTask(int task_id) { | 328 ArcAppWindowLauncherController::GetAppWindowForTask(int task_id) { |
| 361 TaskIdToAppWindow::iterator it = task_id_to_app_window_.find(task_id); | 329 TaskIdToAppWindow::iterator it = task_id_to_app_window_.find(task_id); |
| 362 if (it == task_id_to_app_window_.end()) | 330 if (it == task_id_to_app_window_.end()) |
| 363 return nullptr; | 331 return nullptr; |
| 364 return it->second.get(); | 332 return it->second.get(); |
| 365 } | 333 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 383 if (!observing_shell_) { | 351 if (!observing_shell_) { |
| 384 observing_shell_ = true; | 352 observing_shell_ = true; |
| 385 ash::WmShell::Get()->AddShellObserver(this); | 353 ash::WmShell::Get()->AddShellObserver(this); |
| 386 } | 354 } |
| 387 | 355 |
| 388 // Check if we have controller for this task. | 356 // Check if we have controller for this task. |
| 389 if (GetAppWindowForTask(task_id)) | 357 if (GetAppWindowForTask(task_id)) |
| 390 return; | 358 return; |
| 391 | 359 |
| 392 // Create controller if we have task info. | 360 // Create controller if we have task info. |
| 393 TaskIdToTaskInfoMap::iterator it = task_id_to_task_info_.find(task_id); | 361 TaskIdToShelfAppIdMap::iterator it = task_id_to_shelf_app_id_.find(task_id); |
| 394 if (it == task_id_to_task_info_.end()) | 362 if (it == task_id_to_shelf_app_id_.end()) |
| 395 return; | 363 return; |
| 396 | 364 |
| 397 const TaskInfo& task_info = *it->second; | 365 const std::string& app_id = it->second; |
| 398 const std::string app_id = | |
| 399 GetShelfAppIdFromArcAppId(ArcAppListPrefs::GetAppId( | |
| 400 task_info.package_name, task_info.activity_name)); | |
| 401 | 366 |
| 402 std::unique_ptr<AppWindow> app_window(new AppWindow(task_id, app_id, this)); | 367 std::unique_ptr<AppWindow> app_window(new AppWindow(task_id, app_id, this)); |
| 403 app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window)); | 368 app_window->set_widget(views::Widget::GetWidgetForNativeWindow(window)); |
| 404 RegisterApp(app_window.get()); | 369 RegisterApp(app_window.get()); |
| 405 DCHECK(app_window->controller()); | 370 DCHECK(app_window->controller()); |
| 406 ash::SetShelfIDForWindow(app_window->shelf_id(), window); | 371 ash::SetShelfIDForWindow(app_window->shelf_id(), window); |
| 407 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( | 372 chrome::MultiUserWindowManager::GetInstance()->SetWindowOwner( |
| 408 window, | 373 window, |
| 409 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); | 374 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId()); |
| 410 if (ash::Shell::GetInstance() | 375 if (ash::Shell::GetInstance() |
| 411 ->maximize_mode_controller() | 376 ->maximize_mode_controller() |
| 412 ->IsMaximizeModeWindowManagerEnabled()) { | 377 ->IsMaximizeModeWindowManagerEnabled()) { |
| 413 SetOrientationLockForAppWindow(app_window.get()); | 378 SetOrientationLockForAppWindow(app_window.get()); |
| 414 } | 379 } |
| 415 task_id_to_app_window_[task_id] = std::move(app_window); | 380 task_id_to_app_window_[task_id] = std::move(app_window); |
| 416 | |
| 417 // TaskInfo is no longer needed. Discard it. | |
| 418 task_id_to_task_info_.erase(task_id); | |
| 419 } | 381 } |
| 420 | 382 |
| 421 void ArcAppWindowLauncherController::OnAppReadyChanged( | 383 void ArcAppWindowLauncherController::OnAppReadyChanged( |
| 422 const std::string& app_id, | 384 const std::string& app_id, |
| 423 bool ready) { | 385 bool ready) { |
| 424 if (!ready) | 386 if (!ready) |
| 425 OnAppRemoved(app_id); | 387 OnAppRemoved(app_id); |
| 426 } | 388 } |
| 427 | 389 |
| 428 void ArcAppWindowLauncherController::OnAppRemoved(const std::string& app_id) { | 390 void ArcAppWindowLauncherController::OnAppRemoved(const std::string& app_id) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 444 OnTaskDestroyed(task_id); | 406 OnTaskDestroyed(task_id); |
| 445 | 407 |
| 446 DCHECK(app_controller_map_.find(shelf_app_id) == app_controller_map_.end()); | 408 DCHECK(app_controller_map_.find(shelf_app_id) == app_controller_map_.end()); |
| 447 } | 409 } |
| 448 | 410 |
| 449 void ArcAppWindowLauncherController::OnTaskCreated( | 411 void ArcAppWindowLauncherController::OnTaskCreated( |
| 450 int task_id, | 412 int task_id, |
| 451 const std::string& package_name, | 413 const std::string& package_name, |
| 452 const std::string& activity_name) { | 414 const std::string& activity_name) { |
| 453 DCHECK(!GetAppWindowForTask(task_id)); | 415 DCHECK(!GetAppWindowForTask(task_id)); |
| 454 std::unique_ptr<TaskInfo> task_info( | 416 task_id_to_shelf_app_id_[task_id] = GetShelfAppIdFromArcAppId( |
| 455 new TaskInfo(package_name, activity_name)); | 417 ArcAppListPrefs::GetAppId(package_name, activity_name)); |
| 456 task_id_to_task_info_[task_id] = std::move(task_info); | |
| 457 | 418 |
| 458 for (auto* window : observed_windows_) | 419 for (auto* window : observed_windows_) |
| 459 MayAttachContollerToWindow(window); | 420 MayAttachContollerToWindow(window); |
| 460 } | 421 } |
| 461 | 422 |
| 462 void ArcAppWindowLauncherController::OnTaskDestroyed(int task_id) { | 423 void ArcAppWindowLauncherController::OnTaskDestroyed(int task_id) { |
| 463 task_id_to_task_info_.erase(task_id); | 424 auto it = task_id_to_app_window_.find(task_id); |
| 425 if (it != task_id_to_app_window_.end()) { |
| 426 AppWindow* app_window = it->second.get(); |
| 427 UnregisterApp(app_window, true); |
| 428 task_id_to_app_window_.erase(it); |
| 429 } |
| 464 | 430 |
| 465 TaskIdToAppWindow::iterator it = task_id_to_app_window_.find(task_id); | 431 // Check if we may close controller now, at this point we can safely remove |
| 466 if (it == task_id_to_app_window_.end()) | 432 // controllers without window. |
| 433 auto it_app_id = task_id_to_shelf_app_id_.find(task_id); |
| 434 if (it_app_id == task_id_to_shelf_app_id_.end()) |
| 467 return; | 435 return; |
| 468 | 436 |
| 469 AppWindow* app_window = it->second.get(); | 437 const std::string& app_id = it_app_id->second; |
| 470 UnregisterApp(app_window); | 438 AppControllerMap::iterator it_controller = app_controller_map_.find(app_id); |
| 439 if (it_controller != app_controller_map_.end()) { |
| 440 ArcAppWindowLauncherItemController* controller = it_controller->second; |
| 441 controller->RemoveTaskId(task_id); |
| 442 if (!controller->window_count()) { |
| 443 owner()->CloseLauncherItem(controller->shelf_id()); |
| 444 app_controller_map_.erase(it_controller); |
| 445 } |
| 446 } |
| 471 | 447 |
| 472 task_id_to_app_window_.erase(it); | 448 task_id_to_shelf_app_id_.erase(it_app_id); |
| 473 } | 449 } |
| 474 | 450 |
| 475 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { | 451 void ArcAppWindowLauncherController::OnTaskSetActive(int32_t task_id) { |
| 476 if (observed_profile_ != owner()->GetProfile()) | 452 if (observed_profile_ != owner()->GetProfile()) |
| 477 return; | 453 return; |
| 478 | 454 |
| 479 TaskIdToAppWindow::iterator previous_active_app_it = | 455 TaskIdToAppWindow::iterator previous_active_app_it = |
| 480 task_id_to_app_window_.find(active_task_id_); | 456 task_id_to_app_window_.find(active_task_id_); |
| 481 if (previous_active_app_it != task_id_to_app_window_.end()) { | 457 if (previous_active_app_it != task_id_to_app_window_.end()) { |
| 482 owner()->SetItemStatus(previous_active_app_it->second->shelf_id(), | 458 owner()->SetItemStatus(previous_active_app_it->second->shelf_id(), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (shelf_id == 0) { | 573 if (shelf_id == 0) { |
| 598 // Map Play Store shelf icon to Arc Support host, to share one entry. | 574 // Map Play Store shelf icon to Arc Support host, to share one entry. |
| 599 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, | 575 shelf_id = owner()->CreateAppLauncherItem(controller, app_id, |
| 600 ash::STATUS_RUNNING); | 576 ash::STATUS_RUNNING); |
| 601 } else { | 577 } else { |
| 602 owner()->SetItemController(shelf_id, controller); | 578 owner()->SetItemController(shelf_id, controller); |
| 603 } | 579 } |
| 604 app_controller_map_[app_id] = controller; | 580 app_controller_map_[app_id] = controller; |
| 605 } | 581 } |
| 606 controller->AddWindow(app_window); | 582 controller->AddWindow(app_window); |
| 583 controller->AddTaskId(app_window->task_id()); |
| 607 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 584 owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 608 app_window->SetController(controller); | 585 app_window->SetController(controller); |
| 609 app_window->set_shelf_id(shelf_id); | 586 app_window->set_shelf_id(shelf_id); |
| 610 } | 587 } |
| 611 | 588 |
| 612 void ArcAppWindowLauncherController::UnregisterApp(AppWindow* app_window) { | 589 void ArcAppWindowLauncherController::UnregisterApp(AppWindow* app_window, |
| 590 bool close_controller) { |
| 613 const std::string app_id = app_window->app_id(); | 591 const std::string app_id = app_window->app_id(); |
| 614 DCHECK(!app_id.empty()); | 592 DCHECK(!app_id.empty()); |
| 615 AppControllerMap::iterator it = app_controller_map_.find(app_id); | 593 AppControllerMap::iterator it = app_controller_map_.find(app_id); |
| 616 DCHECK(it != app_controller_map_.end()); | 594 DCHECK(it != app_controller_map_.end()); |
| 617 | 595 |
| 618 ArcAppWindowLauncherItemController* controller = it->second; | 596 ArcAppWindowLauncherItemController* controller = it->second; |
| 619 controller->RemoveWindow(app_window); | 597 controller->RemoveWindow(app_window); |
| 620 if (!controller->window_count()) { | 598 if (close_controller && !controller->window_count()) { |
| 621 ash::ShelfID shelf_id = app_window->shelf_id(); | 599 ash::ShelfID shelf_id = app_window->shelf_id(); |
| 622 owner()->CloseLauncherItem(shelf_id); | 600 owner()->CloseLauncherItem(shelf_id); |
| 623 app_controller_map_.erase(it); | 601 app_controller_map_.erase(it); |
| 624 } | 602 } |
| 625 app_window->ResetController(); | 603 app_window->ResetController(); |
| 626 } | 604 } |
| 627 | 605 |
| 628 void ArcAppWindowLauncherController::SetOrientationLockForAppWindow( | 606 void ArcAppWindowLauncherController::SetOrientationLockForAppWindow( |
| 629 AppWindow* app_window) { | 607 AppWindow* app_window) { |
| 630 ash::Shell* shell = ash::Shell::GetInstance(); | 608 ash::Shell* shell = ash::Shell::GetInstance(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 645 | 623 |
| 646 if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { | 624 if (orientation_lock == arc::mojom::OrientationLock::CURRENT) { |
| 647 // Resolve the orientation when it first resolved. | 625 // Resolve the orientation when it first resolved. |
| 648 orientation_lock = GetCurrentOrientation(); | 626 orientation_lock = GetCurrentOrientation(); |
| 649 app_window->set_requested_orientation_lock(orientation_lock); | 627 app_window->set_requested_orientation_lock(orientation_lock); |
| 650 } | 628 } |
| 651 | 629 |
| 652 shell->screen_orientation_controller()->LockOrientationForWindow( | 630 shell->screen_orientation_controller()->LockOrientationForWindow( |
| 653 window, BlinkOrientationLockFromMojom(orientation_lock)); | 631 window, BlinkOrientationLockFromMojom(orientation_lock)); |
| 654 } | 632 } |
| OLD | NEW |