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" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Default sizes to use. | 27 // Default sizes to use. |
28 constexpr int kNexus7Width = 960; | 28 constexpr int kNexus7Width = 960; |
29 constexpr int kNexus7Height = 600; | 29 constexpr int kNexus7Height = 600; |
30 constexpr int kNexus5Width = 410; | 30 constexpr int kNexus5Width = 410; |
31 constexpr int kNexus5Height = 690; | 31 constexpr int kNexus5Height = 690; |
32 | 32 |
33 // Minimum required versions. | 33 // Minimum required versions. |
34 constexpr int kMinVersion = 0; | 34 constexpr int kMinVersion = 0; |
Yusuke Sato
2016/09/16 23:58:48
uint32_t (line 34-41)
Luis Héctor Chávez
2016/09/17 00:30:53
Good catch, done.
| |
35 constexpr int kCanHandleResolutionMinVersion = 1; | 35 constexpr int kCanHandleResolutionMinVersion = 1; |
36 constexpr int kSendBroadcastMinVersion = 1; | 36 constexpr int kSendBroadcastMinVersion = 1; |
37 constexpr int kUninstallPackageMinVersion = 2; | 37 constexpr int kUninstallPackageMinVersion = 2; |
38 constexpr int kTaskSupportMinVersion = 3; | 38 constexpr int kTaskSupportMinVersion = 3; |
39 constexpr int kShowPackageInfoMinVersion = 5; | 39 constexpr int kShowPackageInfoMinVersion = 5; |
40 constexpr int kRemoveIconMinVersion = 9; | 40 constexpr int kRemoveIconMinVersion = 9; |
41 constexpr int kShowPackageInfoOnPageMinVersion = 10; | 41 constexpr int kShowPackageInfoOnPageMinVersion = 10; |
42 | 42 |
43 // Service name strings. | 43 // Service name strings. |
44 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; | 44 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; |
45 constexpr char kCloseTaskStr[] = "close task"; | 45 constexpr char kCloseTaskStr[] = "close task"; |
46 constexpr char kLaunchAppStr[] = "launch app"; | 46 constexpr char kLaunchAppStr[] = "launch app"; |
47 constexpr char kRemoveIconStr[] = "remove icon"; | 47 constexpr char kRemoveIconStr[] = "remove icon"; |
48 constexpr char kSetActiveTaskStr[] = "set active task"; | 48 constexpr char kSetActiveTaskStr[] = "set active task"; |
49 constexpr char kShowPackageInfoStr[] = "show package info"; | 49 constexpr char kShowPackageInfoStr[] = "show package info"; |
50 constexpr char kUninstallPackageStr[] = "uninstall package"; | 50 constexpr char kUninstallPackageStr[] = "uninstall package"; |
51 | 51 |
52 // Helper function which returns the AppInstance. Create related logs when error | 52 // Helper function which returns the AppInstance. Create related logs when error |
53 // happens. | 53 // happens. |
54 arc::mojom::AppInstance* GetAppInstance(int required_version, | 54 arc::mojom::AppInstance* GetAppInstance(int required_version, |
Yusuke Sato
2016/09/16 23:58:48
What about changing the type to uint32_t while you
Luis Héctor Chávez
2016/09/17 00:30:53
Done.
| |
55 const std::string& service_name) { | 55 const std::string& service_name) { |
56 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 56 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
57 if (!bridge_service) { | 57 if (!bridge_service) { |
58 VLOG(2) << "Request to " << service_name | 58 VLOG(2) << "Request to " << service_name |
59 << " when bridge service is not ready."; | 59 << " when bridge service is not ready."; |
60 return nullptr; | 60 return nullptr; |
61 } | 61 } |
62 | 62 |
63 arc::mojom::AppInstance* app_instance = bridge_service->app()->instance(); | 63 return bridge_service->app()->GetInstanceForVersion(required_version, |
64 if (!app_instance) { | 64 service_name.c_str()); |
65 VLOG(2) << "Request to " << service_name | |
66 << " when mojom::app_instance is not ready."; | |
67 return nullptr; | |
68 } | |
69 | |
70 int bridge_version = bridge_service->app()->version(); | |
71 if (bridge_version < required_version) { | |
72 VLOG(2) << "Request to " << service_name << " when Arc version " | |
73 << bridge_version << " does not support it."; | |
74 return nullptr; | |
75 } | |
76 | |
77 return app_instance; | |
78 } | 65 } |
79 | 66 |
80 void PrioritizeArcInstanceCallback(bool success) { | 67 void PrioritizeArcInstanceCallback(bool success) { |
81 VLOG(2) << "Finished prioritizing the instance: result=" << success; | 68 VLOG(2) << "Finished prioritizing the instance: result=" << success; |
82 if (!success) | 69 if (!success) |
83 LOG(ERROR) << "Failed to prioritize ARC"; | 70 LOG(ERROR) << "Failed to prioritize ARC"; |
84 } | 71 } |
85 | 72 |
86 // Find a proper size and position for a given rectangle on the screen. | 73 // Find a proper size and position for a given rectangle on the screen. |
87 // TODO(skuhne): This needs more consideration, but it is lacking | 74 // TODO(skuhne): This needs more consideration, but it is lacking |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 app_instance->CloseTask(task_id); | 284 app_instance->CloseTask(task_id); |
298 } | 285 } |
299 | 286 |
300 void ShowTalkBackSettings() { | 287 void ShowTalkBackSettings() { |
301 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 288 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
302 if (!bridge_service) { | 289 if (!bridge_service) { |
303 VLOG(2) << "ARC bridge is not ready"; | 290 VLOG(2) << "ARC bridge is not ready"; |
304 return; | 291 return; |
305 } | 292 } |
306 | 293 |
307 arc::mojom::IntentHelperInstance *intent_helper_instance = | 294 auto* intent_helper_instance = |
308 bridge_service->intent_helper()->instance(); | 295 bridge_service->intent_helper()->GetInstanceForVersion( |
309 if (!intent_helper_instance) { | 296 kSendBroadcastMinVersion, "SendBroadcast"); |
310 VLOG(2) << "ARC intent helper instance is not ready"; | 297 if (!intent_helper_instance) |
311 return; | 298 return; |
312 } | |
313 if (bridge_service->intent_helper()->version() < kSendBroadcastMinVersion) { | |
314 VLOG(2) << "ARC intent helper instance is too old"; | |
315 return; | |
316 } | |
317 | 299 |
318 intent_helper_instance->SendBroadcast( | 300 intent_helper_instance->SendBroadcast( |
319 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS", | 301 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS", |
320 "org.chromium.arc.intent_helper", | 302 "org.chromium.arc.intent_helper", |
321 "org.chromium.arc.intent_helper.SettingsReceiver", | 303 "org.chromium.arc.intent_helper.SettingsReceiver", |
322 "{}"); | 304 "{}"); |
323 } | 305 } |
324 | 306 |
325 bool CanHandleResolution(content::BrowserContext* context, | 307 bool CanHandleResolution(content::BrowserContext* context, |
326 const std::string& app_id, | 308 const std::string& app_id, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 if (!app_instance) | 372 if (!app_instance) |
391 return false; | 373 return false; |
392 | 374 |
393 app_instance->ShowPackageInfoOnPage( | 375 app_instance->ShowPackageInfoOnPage( |
394 package_name, page, | 376 package_name, page, |
395 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); | 377 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); |
396 return true; | 378 return true; |
397 } | 379 } |
398 | 380 |
399 } // namespace arc | 381 } // namespace arc |
OLD | NEW |