| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 GetAppInstance(kShowPackageInfoOnPageMinVersion, kShowPackageInfoStr); | 379 GetAppInstance(kShowPackageInfoOnPageMinVersion, kShowPackageInfoStr); |
| 371 if (!app_instance) | 380 if (!app_instance) |
| 372 return false; | 381 return false; |
| 373 | 382 |
| 374 app_instance->ShowPackageInfoOnPage( | 383 app_instance->ShowPackageInfoOnPage( |
| 375 package_name, page, | 384 package_name, page, |
| 376 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); | 385 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); |
| 377 return true; | 386 return true; |
| 378 } | 387 } |
| 379 | 388 |
| 389 void PrioritizeArcInstance() { |
| 390 VLOG(2) << "Prioritizing the instance"; |
| 391 chromeos::SessionManagerClient* session_manager_client = |
| 392 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 393 session_manager_client->PrioritizeArcInstance( |
| 394 base::Bind(PrioritizeArcInstanceCallback)); |
| 395 } |
| 396 |
| 380 } // namespace arc | 397 } // namespace arc |
| OLD | NEW |