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