| 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 <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" | 16 #include "chrome/browser/chromeos/arc/arc_migration_guide_notification.h" |
| 17 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 17 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 18 #include "chrome/browser/chromeos/arc/arc_util.h" | 18 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 21 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 21 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
| 22 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" | 22 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" |
| 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 23 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 24 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 25 #include "chromeos/dbus/session_manager_client.h" | |
| 26 #include "components/arc/arc_bridge_service.h" | 24 #include "components/arc/arc_bridge_service.h" |
| 27 #include "components/arc/arc_features.h" | 25 #include "components/arc/arc_features.h" |
| 28 #include "components/arc/arc_service_manager.h" | 26 #include "components/arc/arc_service_manager.h" |
| 29 #include "components/arc/arc_util.h" | 27 #include "components/arc/arc_util.h" |
| 30 #include "components/arc/common/intent_helper.mojom.h" | 28 #include "components/arc/common/intent_helper.mojom.h" |
| 31 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
| 32 #include "ui/display/display.h" | 30 #include "ui/display/display.h" |
| 33 #include "ui/display/screen.h" | 31 #include "ui/display/screen.h" |
| 34 #include "ui/events/event_constants.h" | 32 #include "ui/events/event_constants.h" |
| 35 | 33 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 62 | 60 |
| 63 // Intent helper strings. | 61 // Intent helper strings. |
| 64 constexpr char kIntentHelperClassName[] = | 62 constexpr char kIntentHelperClassName[] = |
| 65 "org.chromium.arc.intent_helper.SettingsReceiver"; | 63 "org.chromium.arc.intent_helper.SettingsReceiver"; |
| 66 constexpr char kIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; | 64 constexpr char kIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; |
| 67 constexpr char kSetInTouchModeIntent[] = | 65 constexpr char kSetInTouchModeIntent[] = |
| 68 "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE"; | 66 "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE"; |
| 69 constexpr char kShowTalkbackSettingsIntent[] = | 67 constexpr char kShowTalkbackSettingsIntent[] = |
| 70 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS"; | 68 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS"; |
| 71 | 69 |
| 72 void SetArcCpuRestrictionCallback(bool success) { | |
| 73 VLOG(2) << "Finished prioritizing the instance: result=" << success; | |
| 74 if (!success) | |
| 75 LOG(ERROR) << "Failed to prioritize ARC"; | |
| 76 } | |
| 77 | |
| 78 // Find a proper size and position for a given rectangle on the screen. | 70 // Find a proper size and position for a given rectangle on the screen. |
| 79 // TODO(skuhne): This needs more consideration, but it is lacking | 71 // TODO(skuhne): This needs more consideration, but it is lacking |
| 80 // WindowPositioner functionality since we do not have an Aura::Window yet. | 72 // WindowPositioner functionality since we do not have an Aura::Window yet. |
| 81 gfx::Rect GetTargetRect(const gfx::Size& size) { | 73 gfx::Rect GetTargetRect(const gfx::Size& size) { |
| 82 // Make sure that the window will fit into our workspace. | 74 // Make sure that the window will fit into our workspace. |
| 83 // Note that ARC will always be on the primary screen (for now). | 75 // Note that ARC will always be on the primary screen (for now). |
| 84 // Note that Android's coordinate system is only valid inside the working | 76 // Note that Android's coordinate system is only valid inside the working |
| 85 // area. We can therefore ignore the provided left / top offsets. | 77 // area. We can therefore ignore the provided left / top offsets. |
| 86 aura::Window* root = ash::Shell::GetPrimaryRootWindow(); | 78 aura::Window* root = ash::Shell::GetPrimaryRootWindow(); |
| 87 gfx::Rect work_area = | 79 gfx::Rect work_area = |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 ChromeLauncherController::instance(); | 320 ChromeLauncherController::instance(); |
| 329 DCHECK(chrome_controller || !ash::Shell::HasInstance()); | 321 DCHECK(chrome_controller || !ash::Shell::HasInstance()); |
| 330 if (chrome_controller) { | 322 if (chrome_controller) { |
| 331 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( | 323 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( |
| 332 app_id, event_flags); | 324 app_id, event_flags); |
| 333 | 325 |
| 334 // On some boards, ARC is booted with a restricted set of resources by | 326 // On some boards, ARC is booted with a restricted set of resources by |
| 335 // default to avoid slowing down Chrome's user session restoration. | 327 // default to avoid slowing down Chrome's user session restoration. |
| 336 // However, the restriction should be lifted once the user explicitly | 328 // However, the restriction should be lifted once the user explicitly |
| 337 // tries to launch an ARC app. | 329 // tries to launch an ARC app. |
| 338 VLOG(2) << "Prioritizing the instance"; | 330 PrioritizeArcContainer(); |
| 339 chromeos::SessionManagerClient* session_manager_client = | |
| 340 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | |
| 341 session_manager_client->SetArcCpuRestriction( | |
| 342 login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND, | |
| 343 base::Bind(SetArcCpuRestrictionCallback)); | |
| 344 } | 331 } |
| 345 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 332 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 346 return true; | 333 return true; |
| 347 } | 334 } |
| 348 return (new LaunchAppWithoutSize(context, app_id, landscape_layout, | 335 return (new LaunchAppWithoutSize(context, app_id, landscape_layout, |
| 349 event_flags)) | 336 event_flags)) |
| 350 ->LaunchAndRelease(); | 337 ->LaunchAndRelease(); |
| 351 } | 338 } |
| 352 | 339 |
| 353 void SetTaskActive(int task_id) { | 340 void SetTaskActive(int task_id) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return false; | 457 return false; |
| 471 | 458 |
| 472 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); | 459 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); |
| 473 if (!arc_prefs) | 460 if (!arc_prefs) |
| 474 return false; | 461 return false; |
| 475 | 462 |
| 476 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); | 463 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); |
| 477 } | 464 } |
| 478 | 465 |
| 479 } // namespace arc | 466 } // namespace arc |
| OLD | NEW |