| Index: chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
|
| index 2cafcec882b1b7e1f84aa16a8b25673650ac3296..484e15dcf50291d4fbe254946a1fadefee67015d 100644
|
| --- a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
|
| @@ -32,7 +32,9 @@ namespace arc {
|
|
|
| namespace {
|
|
|
| -constexpr uint32_t kMinInstanceVersion = 3; // RequestActivityIcons' MinVersion
|
| +constexpr uint32_t kMinVersionForHandleUrl = 2;
|
| +constexpr uint32_t kMinVersionForRequestUrlHandlerList = 2;
|
| +constexpr uint32_t kMinVersionForAddPreferredPackage = 7;
|
|
|
| // Shows the Chrome OS' original external protocol dialog as a fallback.
|
| void ShowFallbackExternalProtocolDialog(int render_process_host_id,
|
| @@ -43,10 +45,6 @@ void ShowFallbackExternalProtocolDialog(int render_process_host_id,
|
| new ExternalProtocolDialog(web_contents, url);
|
| }
|
|
|
| -mojom::IntentHelperInstance* GetIntentHelper() {
|
| - return ArcIntentHelperBridge::GetIntentHelperInstance(kMinInstanceVersion);
|
| -}
|
| -
|
| scoped_refptr<ActivityIconLoader> GetIconLoader() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| ArcServiceManager* arc_service_manager = ArcServiceManager::Get();
|
| @@ -62,21 +60,27 @@ void OnIntentPickerClosed(int render_process_host_id,
|
| ArcNavigationThrottle::CloseReason close_reason) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| - mojom::IntentHelperInstance* intent_helper = GetIntentHelper();
|
| - if (!intent_helper || selected_app_index >= handlers.size())
|
| + // Make sure that the instance at least supports HandleUrl.
|
| + auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
|
| + "HandleUrl", kMinVersionForHandleUrl);
|
| + if (!instance || selected_app_index >= handlers.size())
|
| close_reason = ArcNavigationThrottle::CloseReason::ERROR;
|
|
|
| switch (close_reason) {
|
| case ArcNavigationThrottle::CloseReason::ALWAYS_PRESSED: {
|
| - intent_helper->AddPreferredPackage(
|
| - handlers[selected_app_index]->package_name);
|
| + // Call AddPreferredPackage if it is supported.
|
| + if (ArcIntentHelperBridge::GetIntentHelperInstance(
|
| + "AddPreferredPackage", kMinVersionForAddPreferredPackage)) {
|
| + instance->AddPreferredPackage(
|
| + handlers[selected_app_index]->package_name);
|
| + }
|
| // fall through.
|
| }
|
| case ArcNavigationThrottle::CloseReason::JUST_ONCE_PRESSED:
|
| case ArcNavigationThrottle::CloseReason::PREFERRED_ACTIVITY_FOUND: {
|
| // Launch the selected app.
|
| - intent_helper->HandleUrl(url.spec(),
|
| - handlers[selected_app_index]->package_name);
|
| + instance->HandleUrl(url.spec(),
|
| + handlers[selected_app_index]->package_name);
|
| break;
|
| }
|
| case ArcNavigationThrottle::CloseReason::ERROR:
|
| @@ -129,10 +133,11 @@ void OnUrlHandlerList(int render_process_host_id,
|
| mojo::Array<mojom::UrlHandlerInfoPtr> handlers) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| - mojom::IntentHelperInstance* intent_helper = GetIntentHelper();
|
| + auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
|
| + "HandleUrl", kMinVersionForHandleUrl);
|
| scoped_refptr<ActivityIconLoader> icon_loader = GetIconLoader();
|
|
|
| - if (!intent_helper || !icon_loader || !handlers.size()) {
|
| + if (!instance || !icon_loader || !handlers.size()) {
|
| // No handler is available on ARC side. Show the Chrome OS dialog.
|
| ShowFallbackExternalProtocolDialog(render_process_host_id, routing_id, url);
|
| return;
|
| @@ -142,7 +147,7 @@ void OnUrlHandlerList(int render_process_host_id,
|
| // Special case. When ARC has only one activity for the |url|, silently
|
| // launch the app to be consistent with Android's behavior. No UI needed
|
| // in this case.
|
| - intent_helper->HandleUrl(url.spec(), handlers[0]->package_name);
|
| + instance->HandleUrl(url.spec(), handlers[0]->package_name);
|
| return;
|
| }
|
|
|
| @@ -166,8 +171,9 @@ bool RunArcExternalProtocolDialog(const GURL& url,
|
| if (ShouldIgnoreNavigation(page_transition))
|
| return false;
|
|
|
| - mojom::IntentHelperInstance* intent_helper = GetIntentHelper();
|
| - if (!intent_helper)
|
| + auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
|
| + "RequestUrlHandlerList", kMinVersionForRequestUrlHandlerList);
|
| + if (!instance)
|
| return false; // ARC is either not supported or not yet ready.
|
|
|
| WebContents* web_contents =
|
| @@ -179,7 +185,7 @@ bool RunArcExternalProtocolDialog(const GURL& url,
|
|
|
| // Show ARC version of the dialog, which is IntentPickerBubbleView. To show
|
| // the bubble view, we need to ask ARC for a handler list first.
|
| - intent_helper->RequestUrlHandlerList(
|
| + instance->RequestUrlHandlerList(
|
| url.spec(),
|
| base::Bind(OnUrlHandlerList, render_process_host_id, routing_id, url));
|
| return true;
|
|
|