| 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/shelf/shelf_delegate.h" | 8 #include "ash/common/shelf/shelf_delegate.h" |
| 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm_lookup.h" | 11 #include "ash/common/wm_lookup.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/common/wm_window.h" | 13 #include "ash/common/wm_window.h" |
| 14 #include "ash/common/wm_window_property.h" | 14 #include "ash/common/wm_window_property.h" |
| 15 #include "ash/display/screen_orientation_controller_chromeos.h" | 15 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 16 #include "ash/shared/app_types.h" | 16 #include "ash/shared/app_types.h" |
| 17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 18 #include "ash/wm/window_state_aura.h" | 18 #include "ash/wm/window_state_aura.h" |
| 19 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 20 #include "base/bind.h" | 20 #include "base/bind.h" |
| 21 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 22 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 22 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 23 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 23 #include "chrome/browser/chromeos/arc/arc_util.h" | |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 25 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 26 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller
.h" | 26 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller
.h" |
| 27 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 27 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 28 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 28 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 29 #include "components/arc/arc_bridge_service.h" | 29 #include "components/arc/arc_bridge_service.h" |
| 30 #include "components/exo/shell_surface.h" | 30 #include "components/exo/shell_surface.h" |
| 31 #include "components/signin/core/account_id/account_id.h" | 31 #include "components/signin/core/account_id/account_id.h" |
| 32 #include "components/user_manager/user_manager.h" | 32 #include "components/user_manager/user_manager.h" |
| 33 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" | 33 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 ArcAppWindowLauncherItemController* controller_ = nullptr; | 248 ArcAppWindowLauncherItemController* controller_ = nullptr; |
| 249 // Unowned pointer, represents host Arc window. | 249 // Unowned pointer, represents host Arc window. |
| 250 | 250 |
| 251 DISALLOW_COPY_AND_ASSIGN(AppWindow); | 251 DISALLOW_COPY_AND_ASSIGN(AppWindow); |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 ArcAppWindowLauncherController::ArcAppWindowLauncherController( | 254 ArcAppWindowLauncherController::ArcAppWindowLauncherController( |
| 255 ChromeLauncherController* owner, | 255 ChromeLauncherController* owner, |
| 256 ash::ShelfDelegate* shelf_delegate) | 256 ash::ShelfDelegate* shelf_delegate) |
| 257 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { | 257 : AppWindowLauncherController(owner), shelf_delegate_(shelf_delegate) { |
| 258 if (arc::IsArcAllowedForProfile(owner->profile())) { | 258 if (arc::ArcSessionManager::IsAllowedForProfile(owner->profile())) { |
| 259 observed_profile_ = owner->profile(); | 259 observed_profile_ = owner->profile(); |
| 260 StartObserving(observed_profile_); | 260 StartObserving(observed_profile_); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { | 264 ArcAppWindowLauncherController::~ArcAppWindowLauncherController() { |
| 265 if (observed_profile_) | 265 if (observed_profile_) |
| 266 StopObserving(observed_profile_); | 266 StopObserving(observed_profile_); |
| 267 if (observing_shell_) | 267 if (observing_shell_) |
| 268 ash::WmShell::Get()->RemoveShellObserver(this); | 268 ash::WmShell::Get()->RemoveShellObserver(this); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // Some controllers might have no windows attached, for example background | 308 // Some controllers might have no windows attached, for example background |
| 309 // task when foreground tasks is in full screen. | 309 // task when foreground tasks is in full screen. |
| 310 for (const auto& it : app_shelf_group_to_controller_map_) | 310 for (const auto& it : app_shelf_group_to_controller_map_) |
| 311 owner()->CloseLauncherItem(it.second->shelf_id()); | 311 owner()->CloseLauncherItem(it.second->shelf_id()); |
| 312 app_shelf_group_to_controller_map_.clear(); | 312 app_shelf_group_to_controller_map_.clear(); |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 void ArcAppWindowLauncherController::AdditionalUserAddedToSession( | 316 void ArcAppWindowLauncherController::AdditionalUserAddedToSession( |
| 317 Profile* profile) { | 317 Profile* profile) { |
| 318 DCHECK(!arc::IsArcAllowedForProfile(profile)); | 318 DCHECK(!arc::ArcSessionManager::IsAllowedForProfile(profile)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) { | 321 void ArcAppWindowLauncherController::OnWindowInitialized(aura::Window* window) { |
| 322 // An arc window has type WINDOW_TYPE_NORMAL, a WindowDelegate and | 322 // An arc window has type WINDOW_TYPE_NORMAL, a WindowDelegate and |
| 323 // is a top level views widget. | 323 // is a top level views widget. |
| 324 if (window->type() != ui::wm::WINDOW_TYPE_NORMAL || !window->delegate()) | 324 if (window->type() != ui::wm::WINDOW_TYPE_NORMAL || !window->delegate()) |
| 325 return; | 325 return; |
| 326 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 326 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 327 if (!widget || !widget->is_top_level()) | 327 if (!widget || !widget->is_top_level()) |
| 328 return; | 328 return; |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); | 720 const std::string arc_app_id = exo::ShellSurface::GetApplicationId(window); |
| 721 if (arc_app_id.empty()) | 721 if (arc_app_id.empty()) |
| 722 return -1; | 722 return -1; |
| 723 | 723 |
| 724 int task_id = -1; | 724 int task_id = -1; |
| 725 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) | 725 if (sscanf(arc_app_id.c_str(), "org.chromium.arc.%d", &task_id) != 1) |
| 726 return -1; | 726 return -1; |
| 727 | 727 |
| 728 return task_id; | 728 return task_id; |
| 729 } | 729 } |
| OLD | NEW |