Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1296)

Unified Diff: chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: rebase, no code change Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 59a5c1b0a39c09a7e76831874522c2437076714e..39d5c1bc0dad5a4fa55d69af42a2a88782b6acf5 100644
--- a/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
+++ b/chrome/browser/chromeos/arc/arc_external_protocol_dialog.cc
@@ -32,7 +32,8 @@ namespace arc {
namespace {
-constexpr uint32_t kMinInstanceVersion = 3; // RequestActivityIcons' MinVersion
+constexpr uint32_t kMinVersionForHandleUrl = 2;
+constexpr uint32_t kMinVersionForRequestUrlHandlerList = 2;
// Shows the Chrome OS' original external protocol dialog as a fallback.
void ShowFallbackExternalProtocolDialog(int render_process_host_id,
@@ -43,10 +44,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();
@@ -69,8 +66,10 @@ 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) {
@@ -80,8 +79,8 @@ void OnIntentPickerClosed(int render_process_host_id,
}
case ArcNavigationThrottle::CloseReason::JUST_ONCE_PRESSED: {
// 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);
CloseTabIfNeeded(render_process_host_id, routing_id);
break;
}
@@ -140,10 +139,11 @@ void OnUrlHandlerList(int render_process_host_id,
mojo::Array<mojom::IntentHandlerInfoPtr> 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;
@@ -169,8 +169,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 =
@@ -182,7 +183,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;

Powered by Google App Engine
This is Rietveld 408576698