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