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/json/json_writer.h" |
12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/values.h" |
13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" | 16 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
15 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "chromeos/dbus/session_manager_client.h" | 19 #include "chromeos/dbus/session_manager_client.h" |
18 #include "components/arc/arc_bridge_service.h" | 20 #include "components/arc/arc_bridge_service.h" |
19 #include "components/arc/common/intent_helper.mojom.h" | 21 #include "components/arc/common/intent_helper.mojom.h" |
20 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
21 #include "ui/display/display.h" | 23 #include "ui/display/display.h" |
22 #include "ui/display/screen.h" | 24 #include "ui/display/screen.h" |
| 25 #include "ui/events/event_constants.h" |
23 | 26 |
24 namespace arc { | 27 namespace arc { |
25 | 28 |
26 namespace { | 29 namespace { |
27 | 30 |
28 // Default sizes to use. | 31 // Default sizes to use. |
29 constexpr int kNexus7Width = 960; | 32 constexpr int kNexus7Width = 960; |
30 constexpr int kNexus7Height = 600; | 33 constexpr int kNexus7Height = 600; |
31 constexpr int kNexus5Width = 410; | 34 constexpr int kNexus5Width = 410; |
32 constexpr int kNexus5Height = 690; | 35 constexpr int kNexus5Height = 690; |
(...skipping 10 matching lines...) Expand all Loading... |
43 | 46 |
44 // Service name strings. | 47 // Service name strings. |
45 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; | 48 constexpr char kCanHandleResolutionStr[] = "get resolution capability"; |
46 constexpr char kCloseTaskStr[] = "close task"; | 49 constexpr char kCloseTaskStr[] = "close task"; |
47 constexpr char kLaunchAppStr[] = "launch app"; | 50 constexpr char kLaunchAppStr[] = "launch app"; |
48 constexpr char kRemoveIconStr[] = "remove icon"; | 51 constexpr char kRemoveIconStr[] = "remove icon"; |
49 constexpr char kSetActiveTaskStr[] = "set active task"; | 52 constexpr char kSetActiveTaskStr[] = "set active task"; |
50 constexpr char kShowPackageInfoStr[] = "show package info"; | 53 constexpr char kShowPackageInfoStr[] = "show package info"; |
51 constexpr char kUninstallPackageStr[] = "uninstall package"; | 54 constexpr char kUninstallPackageStr[] = "uninstall package"; |
52 | 55 |
| 56 // Intent helper strings. |
| 57 constexpr char kIntentHelperClassName[] = |
| 58 "org.chromium.arc.intent_helper.SettingsReceiver"; |
| 59 constexpr char kIntentHelperPackageName[] = "org.chromium.arc.intent_helper"; |
| 60 constexpr char kSendBroadcastStr[] = "SendBroadcast"; |
| 61 constexpr char kSetInTouchModeIntent[] = |
| 62 "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE"; |
| 63 constexpr char kShowTalkbackSettingsIntent[] = |
| 64 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS"; |
| 65 |
53 // Helper function which returns the AppInstance. Create related logs when error | 66 // Helper function which returns the AppInstance. Create related logs when error |
54 // happens. | 67 // happens. |
55 arc::mojom::AppInstance* GetAppInstance(uint32_t required_version, | 68 arc::mojom::AppInstance* GetAppInstance(uint32_t required_version, |
56 const std::string& service_name) { | 69 const std::string& service_name) { |
57 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 70 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
58 if (!bridge_service) { | 71 if (!bridge_service) { |
59 VLOG(2) << "Request to " << service_name | 72 VLOG(2) << "Request to " << service_name |
60 << " when bridge service is not ready."; | 73 << " when bridge service is not ready."; |
61 return nullptr; | 74 return nullptr; |
62 } | 75 } |
63 | 76 |
64 return bridge_service->app()->GetInstanceForMethod(service_name.c_str(), | 77 return bridge_service->app()->GetInstanceForMethod(service_name.c_str(), |
65 required_version); | 78 required_version); |
66 } | 79 } |
67 | 80 |
| 81 // Helper function which returns the IntentHelperInstance. Create related logs |
| 82 // when error happens. |
| 83 arc::mojom::IntentHelperInstance* GetIntentHelperInstance( |
| 84 uint32_t required_version, |
| 85 const std::string& service_name) { |
| 86 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
| 87 if (!bridge_service) { |
| 88 VLOG(2) << "Request to " << service_name |
| 89 << " when bridge service is not ready."; |
| 90 return nullptr; |
| 91 } |
| 92 |
| 93 return bridge_service->intent_helper()->GetInstanceForMethod( |
| 94 service_name.c_str(), required_version); |
| 95 } |
| 96 |
68 void PrioritizeArcInstanceCallback(bool success) { | 97 void PrioritizeArcInstanceCallback(bool success) { |
69 VLOG(2) << "Finished prioritizing the instance: result=" << success; | 98 VLOG(2) << "Finished prioritizing the instance: result=" << success; |
70 if (!success) | 99 if (!success) |
71 LOG(ERROR) << "Failed to prioritize ARC"; | 100 LOG(ERROR) << "Failed to prioritize ARC"; |
72 } | 101 } |
73 | 102 |
74 // Find a proper size and position for a given rectangle on the screen. | 103 // Find a proper size and position for a given rectangle on the screen. |
75 // TODO(skuhne): This needs more consideration, but it is lacking | 104 // TODO(skuhne): This needs more consideration, but it is lacking |
76 // WindowPositioner functionality since we do not have an Aura::Window yet. | 105 // WindowPositioner functionality since we do not have an Aura::Window yet. |
77 gfx::Rect GetTargetRect(const gfx::Size& size) { | 106 gfx::Rect GetTargetRect(const gfx::Size& size) { |
(...skipping 17 matching lines...) Expand all Loading... |
95 // WindowPositioner::GetDefaultWindowBounds does for now. | 124 // WindowPositioner::GetDefaultWindowBounds does for now. |
96 // Note: Android's positioning will not overlap the shelf - as such we can | 125 // Note: Android's positioning will not overlap the shelf - as such we can |
97 // ignore the given workspace inset. | 126 // ignore the given workspace inset. |
98 // TODO(skuhne): Replace this with some more useful logic from the | 127 // TODO(skuhne): Replace this with some more useful logic from the |
99 // WindowPositioner. | 128 // WindowPositioner. |
100 result.set_x((work_area.width() - result.width()) / 2); | 129 result.set_x((work_area.width() - result.width()) / 2); |
101 result.set_y((work_area.height() - result.height()) / 2); | 130 result.set_y((work_area.height() - result.height()) / 2); |
102 return result; | 131 return result; |
103 } | 132 } |
104 | 133 |
| 134 // Returns true if |event_flags| came from a mouse or touch event. |
| 135 bool IsMouseOrTouchEventFromFlags(int event_flags) { |
| 136 return (event_flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | |
| 137 ui::EF_RIGHT_MOUSE_BUTTON | ui::EF_BACK_MOUSE_BUTTON | |
| 138 ui::EF_FORWARD_MOUSE_BUTTON | ui::EF_FROM_TOUCH)) != 0; |
| 139 } |
| 140 |
105 // A class which handles the asynchronous ARC runtime callback to figure out if | 141 // A class which handles the asynchronous ARC runtime callback to figure out if |
106 // an app can handle a certain resolution or not. | 142 // an app can handle a certain resolution or not. |
107 // After LaunchAndRelease() got called, the object will destroy itself once | 143 // After LaunchAndRelease() got called, the object will destroy itself once |
108 // done. | 144 // done. |
109 class LaunchAppWithoutSize { | 145 class LaunchAppWithoutSize { |
110 public: | 146 public: |
111 LaunchAppWithoutSize(content::BrowserContext* context, | 147 LaunchAppWithoutSize(content::BrowserContext* context, |
112 const std::string& app_id, | 148 const std::string& app_id, |
113 bool landscape_mode) | 149 bool landscape_mode, |
114 : context_(context), app_id_(app_id), landscape_mode_(landscape_mode) {} | 150 int event_flags) |
| 151 : context_(context), |
| 152 app_id_(app_id), |
| 153 landscape_mode_(landscape_mode), |
| 154 event_flags_(event_flags) {} |
115 | 155 |
116 // This will launch the request and after the return the creator does not | 156 // This will launch the request and after the return the creator does not |
117 // need to delete the object anymore. | 157 // need to delete the object anymore. |
118 bool LaunchAndRelease() { | 158 bool LaunchAndRelease() { |
119 landscape_ = landscape_mode_ ? gfx::Rect(0, 0, kNexus7Width, kNexus7Height) | 159 landscape_ = landscape_mode_ ? gfx::Rect(0, 0, kNexus7Width, kNexus7Height) |
120 : gfx::Rect(0, 0, kNexus5Width, kNexus5Height); | 160 : gfx::Rect(0, 0, kNexus5Width, kNexus5Height); |
121 if (!ash::Shell::HasInstance()) { | 161 if (!ash::Shell::HasInstance()) { |
122 // Skip this if there is no Ash shell. | 162 // Skip this if there is no Ash shell. |
123 LaunchAppWithRect(context_, app_id_, landscape_); | 163 LaunchAppWithRect(context_, app_id_, landscape_, event_flags_); |
124 delete this; | 164 delete this; |
125 return true; | 165 return true; |
126 } | 166 } |
127 | 167 |
128 // TODO(skuhne): Change CanHandleResolution into a call which returns | 168 // TODO(skuhne): Change CanHandleResolution into a call which returns |
129 // capability flags like [PHONE/TABLET]_[LANDSCAPE/PORTRAIT] and which | 169 // capability flags like [PHONE/TABLET]_[LANDSCAPE/PORTRAIT] and which |
130 // might also return the used DP->PIX conversion constant to do better | 170 // might also return the used DP->PIX conversion constant to do better |
131 // size calculations. | 171 // size calculations. |
132 bool result = CanHandleResolution( | 172 bool result = CanHandleResolution( |
133 context_, app_id_, landscape_, | 173 context_, app_id_, landscape_, |
134 base::Bind(&LaunchAppWithoutSize::Callback, base::Unretained(this))); | 174 base::Bind(&LaunchAppWithoutSize::Callback, base::Unretained(this))); |
135 if (!result) | 175 if (!result) |
136 delete this; | 176 delete this; |
137 | 177 |
138 return result; | 178 return result; |
139 } | 179 } |
140 | 180 |
141 private: | 181 private: |
142 content::BrowserContext* context_; | 182 content::BrowserContext* context_; |
143 const std::string app_id_; | 183 const std::string app_id_; |
144 const bool landscape_mode_; | 184 const bool landscape_mode_; |
145 gfx::Rect landscape_; | 185 gfx::Rect landscape_; |
| 186 const int event_flags_; |
146 | 187 |
147 // The callback handler which gets called from the CanHandleResolution | 188 // The callback handler which gets called from the CanHandleResolution |
148 // function. | 189 // function. |
149 void Callback(bool can_handle) { | 190 void Callback(bool can_handle) { |
150 gfx::Size target_size = | 191 gfx::Size target_size = |
151 can_handle ? landscape_.size() : gfx::Size(kNexus5Width, kNexus5Height); | 192 can_handle ? landscape_.size() : gfx::Size(kNexus5Width, kNexus5Height); |
152 LaunchAppWithRect(context_, app_id_, GetTargetRect(target_size)); | 193 LaunchAppWithRect(context_, app_id_, GetTargetRect(target_size), |
| 194 event_flags_); |
153 // Now that we are done, we can delete ourselves. | 195 // Now that we are done, we can delete ourselves. |
154 delete this; | 196 delete this; |
155 } | 197 } |
156 | 198 |
157 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); | 199 DISALLOW_COPY_AND_ASSIGN(LaunchAppWithoutSize); |
158 }; | 200 }; |
159 | 201 |
160 } // namespace | 202 } // namespace |
161 | 203 |
162 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; | 204 const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; |
163 const char kPlayStorePackage[] = "com.android.vending"; | 205 const char kPlayStorePackage[] = "com.android.vending"; |
164 const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity"; | 206 const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity"; |
165 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; | 207 const char kSettingsAppId[] = "mconboelelhjpkbdhhiijkgcimoangdj"; |
166 | 208 |
167 bool ShouldShowInLauncher(const std::string& app_id) { | 209 bool ShouldShowInLauncher(const std::string& app_id) { |
168 return (app_id != kSettingsAppId); | 210 return (app_id != kSettingsAppId); |
169 } | 211 } |
170 | 212 |
171 bool LaunchAppWithRect(content::BrowserContext* context, | 213 bool LaunchAppWithRect(content::BrowserContext* context, |
172 const std::string& app_id, | 214 const std::string& app_id, |
173 const gfx::Rect& target_rect) { | 215 const gfx::Rect& target_rect, |
| 216 int event_flags) { |
174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 217 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
175 CHECK(prefs); | 218 CHECK(prefs); |
176 | 219 |
177 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 220 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
178 if (!app_info) { | 221 if (!app_info) { |
179 VLOG(2) << "Cannot launch unavailable app: " << app_id << "."; | 222 VLOG(2) << "Cannot launch unavailable app: " << app_id << "."; |
180 return false; | 223 return false; |
181 } | 224 } |
182 | 225 |
183 if (!app_info->ready) { | 226 if (!app_info->ready) { |
184 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; | 227 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; |
185 return false; | 228 return false; |
186 } | 229 } |
187 | 230 |
188 if (!app_info->launchable) { | 231 if (!app_info->launchable) { |
189 VLOG(2) << "Cannot launch non-launchable app: " << app_id << "."; | 232 VLOG(2) << "Cannot launch non-launchable app: " << app_id << "."; |
190 return false; | 233 return false; |
191 } | 234 } |
192 | 235 |
193 arc::mojom::AppInstance* app_instance = | 236 arc::mojom::AppInstance* app_instance = |
194 GetAppInstance(kMinVersion, kLaunchAppStr); | 237 GetAppInstance(kMinVersion, kLaunchAppStr); |
195 if (!app_instance) | 238 if (!app_instance) |
196 return false; | 239 return false; |
197 | 240 |
| 241 arc::mojom::IntentHelperInstance* intent_helper_instance = |
| 242 GetIntentHelperInstance(kSendBroadcastMinVersion, kSendBroadcastStr); |
| 243 if (intent_helper_instance) { |
| 244 base::DictionaryValue extras; |
| 245 extras.SetBoolean("inTouchMode", IsMouseOrTouchEventFromFlags(event_flags)); |
| 246 std::string extras_string; |
| 247 base::JSONWriter::Write(extras, &extras_string); |
| 248 intent_helper_instance->SendBroadcast( |
| 249 kSetInTouchModeIntent, kIntentHelperPackageName, kIntentHelperClassName, |
| 250 extras_string); |
| 251 } |
| 252 |
198 if (app_info->shortcut) { | 253 if (app_info->shortcut) { |
199 app_instance->LaunchIntent(app_info->intent_uri, target_rect); | 254 app_instance->LaunchIntent(app_info->intent_uri, target_rect); |
200 } else { | 255 } else { |
201 app_instance->LaunchApp(app_info->package_name, app_info->activity, | 256 app_instance->LaunchApp(app_info->package_name, app_info->activity, |
202 target_rect); | 257 target_rect); |
203 } | 258 } |
204 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 259 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
205 | 260 |
206 return true; | 261 return true; |
207 } | 262 } |
208 | 263 |
209 bool LaunchAndroidSettingsApp(content::BrowserContext* context) { | 264 bool LaunchAndroidSettingsApp(content::BrowserContext* context, |
| 265 int event_flags) { |
210 constexpr bool kUseLandscapeLayout = true; | 266 constexpr bool kUseLandscapeLayout = true; |
211 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout); | 267 return arc::LaunchApp(context, kSettingsAppId, kUseLandscapeLayout, |
212 } | 268 event_flags); |
213 | |
214 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { | |
215 return LaunchApp(context, app_id, true); | |
216 } | 269 } |
217 | 270 |
218 bool LaunchApp(content::BrowserContext* context, | 271 bool LaunchApp(content::BrowserContext* context, |
219 const std::string& app_id, | 272 const std::string& app_id, |
220 bool landscape_layout) { | 273 int event_flags) { |
| 274 constexpr bool kUseLandscapeLayout = true; |
| 275 return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags); |
| 276 } |
| 277 |
| 278 bool LaunchApp(content::BrowserContext* context, |
| 279 const std::string& app_id, |
| 280 bool landscape_layout, |
| 281 int event_flags) { |
221 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 282 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
222 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 283 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
223 if (app_info && !app_info->ready) { | 284 if (app_info && !app_info->ready) { |
224 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); | 285 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); |
225 DCHECK(arc_session_manager); | 286 DCHECK(arc_session_manager); |
226 | 287 |
227 bool arc_activated = false; | 288 bool arc_activated = false; |
228 if (!arc_session_manager->IsArcEnabled()) { | 289 if (!arc_session_manager->IsArcEnabled()) { |
229 if (!prefs->IsDefault(app_id)) { | 290 if (!prefs->IsDefault(app_id)) { |
230 NOTREACHED(); | 291 NOTREACHED(); |
(...skipping 10 matching lines...) Expand all Loading... |
241 | 302 |
242 // PlayStore item has special handling for shelf controllers. In order to | 303 // PlayStore item has special handling for shelf controllers. In order to |
243 // avoid unwanted initial animation for PlayStore item do not create | 304 // avoid unwanted initial animation for PlayStore item do not create |
244 // deferred launch request when PlayStore item enables Arc. | 305 // deferred launch request when PlayStore item enables Arc. |
245 if (!arc_activated || app_id != kPlayStoreAppId) { | 306 if (!arc_activated || app_id != kPlayStoreAppId) { |
246 ChromeLauncherController* chrome_controller = | 307 ChromeLauncherController* chrome_controller = |
247 ChromeLauncherController::instance(); | 308 ChromeLauncherController::instance(); |
248 DCHECK(chrome_controller || !ash::Shell::HasInstance()); | 309 DCHECK(chrome_controller || !ash::Shell::HasInstance()); |
249 if (chrome_controller) { | 310 if (chrome_controller) { |
250 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( | 311 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( |
251 app_id); | 312 app_id, event_flags); |
252 | 313 |
253 // On some boards, ARC is booted with a restricted set of resources by | 314 // On some boards, ARC is booted with a restricted set of resources by |
254 // default to avoid slowing down Chrome's user session restoration. | 315 // default to avoid slowing down Chrome's user session restoration. |
255 // However, the restriction should be lifted once the user explicitly | 316 // However, the restriction should be lifted once the user explicitly |
256 // tries to launch an ARC app. | 317 // tries to launch an ARC app. |
257 VLOG(2) << "Prioritizing the instance"; | 318 VLOG(2) << "Prioritizing the instance"; |
258 chromeos::SessionManagerClient* session_manager_client = | 319 chromeos::SessionManagerClient* session_manager_client = |
259 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 320 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
260 session_manager_client->PrioritizeArcInstance( | 321 session_manager_client->PrioritizeArcInstance( |
261 base::Bind(PrioritizeArcInstanceCallback)); | 322 base::Bind(PrioritizeArcInstanceCallback)); |
262 } | 323 } |
263 } | 324 } |
264 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 325 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
265 return true; | 326 return true; |
266 } | 327 } |
267 | 328 |
268 return (new LaunchAppWithoutSize(context, app_id, landscape_layout)) | 329 return (new LaunchAppWithoutSize(context, app_id, landscape_layout, |
| 330 event_flags)) |
269 ->LaunchAndRelease(); | 331 ->LaunchAndRelease(); |
270 } | 332 } |
271 | 333 |
272 void SetTaskActive(int task_id) { | 334 void SetTaskActive(int task_id) { |
273 arc::mojom::AppInstance* app_instance = | 335 arc::mojom::AppInstance* app_instance = |
274 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); | 336 GetAppInstance(kTaskSupportMinVersion, kSetActiveTaskStr); |
275 if (!app_instance) | 337 if (!app_instance) |
276 return; | 338 return; |
277 app_instance->SetTaskActive(task_id); | 339 app_instance->SetTaskActive(task_id); |
278 } | 340 } |
279 | 341 |
280 void CloseTask(int task_id) { | 342 void CloseTask(int task_id) { |
281 arc::mojom::AppInstance* app_instance = | 343 arc::mojom::AppInstance* app_instance = |
282 GetAppInstance(kTaskSupportMinVersion, kCloseTaskStr); | 344 GetAppInstance(kTaskSupportMinVersion, kCloseTaskStr); |
283 if (!app_instance) | 345 if (!app_instance) |
284 return; | 346 return; |
285 app_instance->CloseTask(task_id); | 347 app_instance->CloseTask(task_id); |
286 } | 348 } |
287 | 349 |
288 void ShowTalkBackSettings() { | 350 void ShowTalkBackSettings() { |
289 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 351 arc::mojom::IntentHelperInstance* intent_helper_instance = |
290 if (!bridge_service) { | 352 GetIntentHelperInstance(kSendBroadcastMinVersion, kSendBroadcastStr); |
291 VLOG(2) << "ARC bridge is not ready"; | |
292 return; | |
293 } | |
294 | |
295 auto* intent_helper_instance = | |
296 bridge_service->intent_helper()->GetInstanceForMethod( | |
297 "SendBroadcast", kSendBroadcastMinVersion); | |
298 if (!intent_helper_instance) | 353 if (!intent_helper_instance) |
299 return; | 354 return; |
300 | 355 |
301 intent_helper_instance->SendBroadcast( | 356 intent_helper_instance->SendBroadcast(kShowTalkbackSettingsIntent, |
302 "org.chromium.arc.intent_helper.SHOW_TALKBACK_SETTINGS", | 357 kIntentHelperPackageName, |
303 "org.chromium.arc.intent_helper", | 358 kIntentHelperClassName, "{}"); |
304 "org.chromium.arc.intent_helper.SettingsReceiver", | |
305 "{}"); | |
306 } | 359 } |
307 | 360 |
308 bool CanHandleResolution(content::BrowserContext* context, | 361 bool CanHandleResolution(content::BrowserContext* context, |
309 const std::string& app_id, | 362 const std::string& app_id, |
310 const gfx::Rect& rect, | 363 const gfx::Rect& rect, |
311 const CanHandleResolutionCallback& callback) { | 364 const CanHandleResolutionCallback& callback) { |
312 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 365 const ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
313 DCHECK(prefs); | 366 DCHECK(prefs); |
314 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 367 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
315 if (!app_info) { | 368 if (!app_info) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 if (!app_instance) | 426 if (!app_instance) |
374 return false; | 427 return false; |
375 | 428 |
376 app_instance->ShowPackageInfoOnPage( | 429 app_instance->ShowPackageInfoOnPage( |
377 package_name, page, | 430 package_name, page, |
378 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); | 431 GetTargetRect(gfx::Size(kNexus7Width, kNexus7Height))); |
379 return true; | 432 return true; |
380 } | 433 } |
381 | 434 |
382 } // namespace arc | 435 } // namespace arc |
OLD | NEW |