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

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

Issue 2194523002: [arc-intents] Handle redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_navigation_throttle.cc
diff --git a/chrome/browser/chromeos/arc/arc_navigation_throttle.cc b/chrome/browser/chromeos/arc/arc_navigation_throttle.cc
index 0275bb7befbd74bc18a055f23cdf9096e811025e..66f6bee6bb86d10f69aaa95675b4822d08278ec2 100644
--- a/chrome/browser/chromeos/arc/arc_navigation_throttle.cc
+++ b/chrome/browser/chromeos/arc/arc_navigation_throttle.cc
@@ -13,6 +13,7 @@
#include "components/arc/arc_bridge_service.h"
#include "components/arc/arc_service_manager.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
+#include "components/arc/intent_helper/local_activity_resolver.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
@@ -57,16 +58,49 @@ ArcNavigationThrottle::ArcNavigationThrottle(
const ShowDisambigDialogCallback& show_disambig_dialog_cb)
: content::NavigationThrottle(navigation_handle),
show_disambig_dialog_callback_(show_disambig_dialog_cb),
- weak_ptr_factory_(this) {}
+ weak_ptr_factory_(this),
+ previous_user_action_(CloseReason::SIZE) {}
djacobo_ 2016/07/28 20:08:01 move before weak_ptr_factory pls.
ArcNavigationThrottle::~ArcNavigationThrottle() = default;
content::NavigationThrottle::ThrottleCheckResult
ArcNavigationThrottle::WillStartRequest() {
+ return HandleRequest();
+}
+
+content::NavigationThrottle::ThrottleCheckResult
+ArcNavigationThrottle::WillRedirectRequest() {
+ switch (previous_user_action_) {
+ case CloseReason::ERROR:
+ case CloseReason::DIALOG_DEACTIVATED:
+ // User dismissed the dialog, or some error occurred before. Don't
+ // repeatedly pop up the dialog.
+ return content::NavigationThrottle::PROCEED;
+
+ case CloseReason::ALWAYS_PRESSED:
+ case CloseReason::JUST_ONCE_PRESSED:
+ case CloseReason::PREFERRED_ACTIVITY_FOUND:
+ // Should never get here - if the user selected one of these previously,
+ // chrome should not see a redirect.
+ NOTREACHED();
+
+ case CloseReason::SIZE:
+ // No disambig has previously been popped up for this - continue.
+ break;
+ }
+ return HandleRequest();
+}
+
+content::NavigationThrottle::ThrottleCheckResult
+ArcNavigationThrottle::HandleRequest() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ const GURL& url = navigation_handle()->GetURL();
+ // Mask out any redirect qualifiers - this method handles navigation from
+ // redirect and non-redirect navigations equivalently.
const ui::PageTransition transition =
- navigation_handle()->GetPageTransition();
+ ui::PageTransitionFromInt(navigation_handle()->GetPageTransition() &
+ ~ui::PAGE_TRANSITION_IS_REDIRECT_MASK);
if (!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK)) {
// If this navigation event wasn't spawned by the user clicking on a link.
@@ -75,16 +109,24 @@ ArcNavigationThrottle::WillStartRequest() {
if (ui::PageTransitionGetQualifier(transition) != 0) {
// Qualifiers indicate that this navigation was the result of a click on a
- // forward/back button, or a redirect, or typing in the URL bar, etc. Don't
- // pass any of those types of navigations to the intent helper (see
- // crbug.com/630072).
+ // forward/back button, or typing in the URL bar, etc. Don't pass any of
+ // those types of navigations to the intent helper (see crbug.com/630072).
+ // Note that redirects, which we do pass on, are masked out above.
return content::NavigationThrottle::PROCEED;
}
if (!ShouldOverrideUrlLoading(navigation_handle()))
return content::NavigationThrottle::PROCEED;
- const GURL& url = navigation_handle()->GetURL();
+ arc::ArcServiceManager* arc_service_manager = arc::ArcServiceManager::Get();
+ DCHECK(arc_service_manager);
+ scoped_refptr<arc::LocalActivityResolver> local_resolver =
+ arc_service_manager->activity_resolver();
+ if (local_resolver->ShouldChromeHandleUrl(url)) {
+ // If this navigation event doesn't hit an android app.
+ return content::NavigationThrottle::PROCEED;
+ }
+
mojom::IntentHelperInstance* bridge_instance = GetIntentHelper();
if (!bridge_instance)
return content::NavigationThrottle::PROCEED;
@@ -94,12 +136,6 @@ ArcNavigationThrottle::WillStartRequest() {
return content::NavigationThrottle::DEFER;
}
-content::NavigationThrottle::ThrottleCheckResult
-ArcNavigationThrottle::WillRedirectRequest() {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- return content::NavigationThrottle::PROCEED;
-}
-
// We received the array of app candidates to handle this URL (even the Chrome
// app is included).
void ArcNavigationThrottle::OnAppCandidatesReceived(
@@ -194,6 +230,8 @@ void ArcNavigationThrottle::OnDisambigDialogClosed(
const GURL& url = navigation_handle()->GetURL();
content::NavigationHandle* handle = navigation_handle();
+ previous_user_action_ = close_reason;
+
mojom::IntentHelperInstance* bridge = GetIntentHelper();
if (!bridge || selected_app_index >= handlers.size()) {
close_reason = CloseReason::ERROR;

Powered by Google App Engine
This is Rietveld 408576698