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

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

Issue 2449213006: Factor out ShouldIgnoreNavigation and add tests for the function (Closed)
Patch Set: Created 4 years, 2 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/intent_helper/arc_external_protocol_dialog.cc
diff --git a/chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog.cc b/chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog.cc
index 05a401638115229c81e8668d2bd1356bed4a9c9e..f49f39f6e5b238741031a5bb3addcbba703ad0c2 100644
--- a/chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog.cc
+++ b/chrome/browser/chromeos/arc/intent_helper/arc_external_protocol_dialog.cc
@@ -339,6 +339,20 @@ void OnUrlHandlerList(int render_process_host_id,
routing_id, url, base::Passed(&handlers)));
}
+// Returns true if ARC should ignore the navigation with the |page_transition|.
+bool ShouldIgnoreNavigation(ui::PageTransition page_transition) {
+ // Handle client-side redirections. Forwarding such navigations to ARC is
+ // better than just showing the "can't open" dialog.
+ // TODO(djacobo): Check if doing this in arc::ShouldIgnoreNavigation is safe,
+ // and move it to the function if it is. (b/32442730#comment3)
+ page_transition = ui::PageTransitionFromInt(
+ page_transition & ~ui::PAGE_TRANSITION_CLIENT_REDIRECT);
+
+ // Try to forward <form> submissions to ARC when possible.
+ constexpr bool kAllowFormSubmit = true;
+ return arc::ShouldIgnoreNavigation(page_transition, kAllowFormSubmit);
+}
+
} // namespace
bool RunArcExternalProtocolDialog(const GURL& url,
@@ -349,16 +363,7 @@ bool RunArcExternalProtocolDialog(const GURL& url,
// This function is for external protocols that Chrome cannot handle.
DCHECK(!url.SchemeIsHTTPOrHTTPS()) << url;
- // Handle client-side redirections. Forwarding such navigations to ARC is
- // better than just showing the "can't open" dialog.
- // TODO(djacobo): Check if doing this in arc::ShouldIgnoreNavigation is safe,
- // and move it to the function if it is. (b/32442730#comment3)
- page_transition = ui::PageTransitionFromInt(
- page_transition & ~ui::PAGE_TRANSITION_CLIENT_REDIRECT);
-
- // Try to forward <form> submissions to ARC when possible.
- constexpr bool kAllowFormSubmit = true;
- if (ShouldIgnoreNavigation(page_transition, kAllowFormSubmit))
+ if (ShouldIgnoreNavigation(page_transition))
return false;
auto* instance = ArcIntentHelperBridge::GetIntentHelperInstance(
@@ -381,6 +386,10 @@ bool RunArcExternalProtocolDialog(const GURL& url,
return true;
}
+bool ShouldIgnoreNavigationForTesting(ui::PageTransition page_transition) {
+ return ShouldIgnoreNavigation(page_transition);
+}
+
GetActionResult GetActionForTesting(
const GURL& original_url,
const mojo::Array<mojom::IntentHandlerInfoPtr>& handlers,

Powered by Google App Engine
This is Rietveld 408576698