| 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 | 4 |
| 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 | 9 |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 13 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chromeos/dbus/session_manager_client.h" |
| 15 #include "components/arc/arc_bridge_service.h" | 18 #include "components/arc/arc_bridge_service.h" |
| 16 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 17 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
| 18 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
| 19 | 22 |
| 20 namespace arc { | 23 namespace arc { |
| 21 | 24 |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| 24 // Default sizes to use. | 27 // Default sizes to use. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 int bridge_version = bridge_service->app()->version(); | 70 int bridge_version = bridge_service->app()->version(); |
| 68 if (bridge_version < required_version) { | 71 if (bridge_version < required_version) { |
| 69 VLOG(2) << "Request to " << service_name << " when Arc version " | 72 VLOG(2) << "Request to " << service_name << " when Arc version " |
| 70 << bridge_version << " does not support it."; | 73 << bridge_version << " does not support it."; |
| 71 return nullptr; | 74 return nullptr; |
| 72 } | 75 } |
| 73 | 76 |
| 74 return app_instance; | 77 return app_instance; |
| 75 } | 78 } |
| 76 | 79 |
| 80 void PrioritizeArcInstanceCallback(bool success) { |
| 81 VLOG(2) << "Finished prioritizing the instance: result=" << success; |
| 82 if (!success) |
| 83 LOG(ERROR) << "Failed to prioritize ARC"; |
| 84 } |
| 85 |
| 77 // Find a proper size and position for a given rectangle on the screen. | 86 // Find a proper size and position for a given rectangle on the screen. |
| 78 // TODO(skuhne): This needs more consideration, but it is lacking | 87 // TODO(skuhne): This needs more consideration, but it is lacking |
| 79 // WindowPositioner functionality since we do not have an Aura::Window yet. | 88 // WindowPositioner functionality since we do not have an Aura::Window yet. |
| 80 gfx::Rect GetTargetRect(const gfx::Size& size) { | 89 gfx::Rect GetTargetRect(const gfx::Size& size) { |
| 81 // Make sure that the window will fit into our workspace. | 90 // Make sure that the window will fit into our workspace. |
| 82 // Note that Arc++ will always be on the primary screen (for now). | 91 // Note that Arc++ will always be on the primary screen (for now). |
| 83 // Note that Android's coordinate system is only valid inside the working | 92 // Note that Android's coordinate system is only valid inside the working |
| 84 // area. We can therefore ignore the provided left / top offsets. | 93 // area. We can therefore ignore the provided left / top offsets. |
| 85 aura::Window* root = ash::Shell::GetPrimaryRootWindow(); | 94 aura::Window* root = ash::Shell::GetPrimaryRootWindow(); |
| 86 gfx::Rect work_area = | 95 gfx::Rect work_area = |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 // PlayStore item has special handling for shelf controllers. In order to | 254 // PlayStore item has special handling for shelf controllers. In order to |
| 246 // avoid unwanted initial animation for PlayStore item do not create | 255 // avoid unwanted initial animation for PlayStore item do not create |
| 247 // deferred launch request when PlayStore item enables Arc. | 256 // deferred launch request when PlayStore item enables Arc. |
| 248 if (!arc_activated || app_id != kPlayStoreAppId) { | 257 if (!arc_activated || app_id != kPlayStoreAppId) { |
| 249 ChromeLauncherController* chrome_controller = | 258 ChromeLauncherController* chrome_controller = |
| 250 ChromeLauncherController::instance(); | 259 ChromeLauncherController::instance(); |
| 251 DCHECK(chrome_controller || !ash::Shell::HasInstance()); | 260 DCHECK(chrome_controller || !ash::Shell::HasInstance()); |
| 252 if (chrome_controller) { | 261 if (chrome_controller) { |
| 253 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( | 262 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( |
| 254 app_id); | 263 app_id); |
| 264 |
| 265 // On some boards, ARC is booted with a restricted set of resources by |
| 266 // default to avoid slowing down Chrome's user session restoration. |
| 267 // However, the restriction should be lifted once the user explicitly |
| 268 // tries to launch an ARC app. |
| 269 VLOG(2) << "Prioritizing the instance"; |
| 270 chromeos::SessionManagerClient* session_manager_client = |
| 271 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 272 session_manager_client->PrioritizeArcInstance( |
| 273 base::Bind(PrioritizeArcInstanceCallback)); |
| 255 } | 274 } |
| 256 } | 275 } |
| 257 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 276 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 258 return true; | 277 return true; |
| 259 } | 278 } |
| 260 | 279 |
| 261 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) | 280 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) |
| 262 ->LaunchAndRelease(); | 281 ->LaunchAndRelease(); |
| 263 } | 282 } |
| 264 | 283 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if (!app_instance) | 390 if (!app_instance) |
| 372 return false; | 391 return false; |
| 373 | 392 |
| 374 app_instance->ShowPackageInfoOnPage( | 393 app_instance->ShowPackageInfoOnPage( |
| 375 package_name, page, | 394 package_name, page, |
| 376 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); | 395 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); |
| 377 return true; | 396 return true; |
| 378 } | 397 } |
| 379 | 398 |
| 380 } // namespace arc | 399 } // namespace arc |
| OLD | NEW |