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

Side by Side Diff: chrome/browser/chromeos/arc/arc_navigation_throttle.cc

Issue 2165193002: [arc-intents] Adjust link-click detection code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exclude qualified page transitions. 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chromeos/arc/arc_navigation_throttle.h" 5 #include "chrome/browser/chromeos/arc/arc_navigation_throttle.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "components/arc/arc_bridge_service.h" 13 #include "components/arc/arc_bridge_service.h"
14 #include "components/arc/arc_service_manager.h" 14 #include "components/arc/arc_service_manager.h"
15 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 15 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/navigation_handle.h" 17 #include "content/public/browser/navigation_handle.h"
18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
19 #include "ui/base/page_transition_types.h"
19 20
20 namespace arc { 21 namespace arc {
21 22
22 namespace { 23 namespace {
23 24
24 constexpr int kMinInstanceVersion = 7; 25 constexpr int kMinInstanceVersion = 7;
25 26
26 scoped_refptr<ActivityIconLoader> GetIconLoader() { 27 scoped_refptr<ActivityIconLoader> GetIconLoader() {
27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
28 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); 29 ArcServiceManager* arc_service_manager = ArcServiceManager::Get();
(...skipping 27 matching lines...) Expand all
56 const ShowDisambigDialogCallback& show_disambig_dialog_cb) 57 const ShowDisambigDialogCallback& show_disambig_dialog_cb)
57 : content::NavigationThrottle(navigation_handle), 58 : content::NavigationThrottle(navigation_handle),
58 show_disambig_dialog_callback_(show_disambig_dialog_cb), 59 show_disambig_dialog_callback_(show_disambig_dialog_cb),
59 weak_ptr_factory_(this) {} 60 weak_ptr_factory_(this) {}
60 61
61 ArcNavigationThrottle::~ArcNavigationThrottle() = default; 62 ArcNavigationThrottle::~ArcNavigationThrottle() = default;
62 63
63 content::NavigationThrottle::ThrottleCheckResult 64 content::NavigationThrottle::ThrottleCheckResult
64 ArcNavigationThrottle::WillStartRequest() { 65 ArcNavigationThrottle::WillStartRequest() {
65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
66 if (!navigation_handle()->HasUserGesture()) 67
68 const ui::PageTransition transition =
69 navigation_handle()->GetPageTransition();
70
71 if (!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK)) {
72 // If this navigation event wasn't spawned by the user clicking on a link.
67 return content::NavigationThrottle::PROCEED; 73 return content::NavigationThrottle::PROCEED;
74 }
68 75
69 if (!ShouldOverrideUrlLoading(navigation_handle())) 76 if (ui::PageTransitionGetQualifier(transition) != 0) {
77 // Qualifiers indicate that this navigation was the result of a click on a
78 // forward/back button, or a redirect, or typing in the URL bar, etc. Don't
79 // pass any of those types of navigations to the intent helper (but see
80 // b/29250054).
Luis Héctor Chávez 2016/07/22 19:08:18 Can you put all the accumulated knowledge in crbug
Ben Kwa 2016/07/22 20:16:43 Done.
70 return content::NavigationThrottle::PROCEED; 81 return content::NavigationThrottle::PROCEED;
82 }
83
84 if (!ShouldOverrideUrlLoading(navigation_handle())) {
85 return content::NavigationThrottle::PROCEED;
Luis Héctor Chávez 2016/07/22 19:08:18 nit: remove the braces to see if the diff becomes
Ben Kwa 2016/07/22 20:16:43 Done.
86 }
71 87
72 const GURL& url = navigation_handle()->GetURL(); 88 const GURL& url = navigation_handle()->GetURL();
73 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); 89 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper();
74 if (!bridge_instance) 90 if (!bridge_instance)
75 return content::NavigationThrottle::PROCEED; 91 return content::NavigationThrottle::PROCEED;
76 bridge_instance->RequestUrlHandlerList( 92 bridge_instance->RequestUrlHandlerList(
77 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, 93 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived,
78 weak_ptr_factory_.GetWeakPtr())); 94 weak_ptr_factory_.GetWeakPtr()));
79 return content::NavigationThrottle::DEFER; 95 return content::NavigationThrottle::DEFER;
80 } 96 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 bool ArcNavigationThrottle::ShouldOverrideUrlLoading( 241 bool ArcNavigationThrottle::ShouldOverrideUrlLoading(
226 content::NavigationHandle* navigation_handle) { 242 content::NavigationHandle* navigation_handle) {
227 GURL previous_url = navigation_handle->GetReferrer().url; 243 GURL previous_url = navigation_handle->GetReferrer().url;
228 GURL current_url = navigation_handle->GetURL(); 244 GURL current_url = navigation_handle->GetURL();
229 return !net::registry_controlled_domains::SameDomainOrHost( 245 return !net::registry_controlled_domains::SameDomainOrHost(
230 current_url, previous_url, 246 current_url, previous_url,
231 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 247 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
232 } 248 }
233 249
234 } // namespace arc 250 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698