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

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

Issue 2175353002: [arc-intents] Adjust link-click detection code. Base URL: https://chromium.googlesource.com/chromium/src.git@2785
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 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "components/arc/arc_bridge_service.h" 11 #include "components/arc/arc_bridge_service.h"
12 #include "components/arc/arc_service_manager.h" 12 #include "components/arc/arc_service_manager.h"
13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" 13 #include "components/arc/intent_helper/arc_intent_helper_bridge.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/navigation_handle.h" 15 #include "content/public/browser/navigation_handle.h"
16 #include "ui/base/page_transition_types.h"
16 17
17 namespace arc { 18 namespace arc {
18 19
19 namespace { 20 namespace {
20 21
21 constexpr int kMinInstanceVersion = 7; 22 constexpr int kMinInstanceVersion = 7;
22 23
23 scoped_refptr<ActivityIconLoader> GetIconLoader() { 24 scoped_refptr<ActivityIconLoader> GetIconLoader() {
24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
25 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); 26 ArcServiceManager* arc_service_manager = ArcServiceManager::Get();
(...skipping 29 matching lines...) Expand all
55 const ShowDisambigDialogCallback& show_disambig_dialog_cb) 56 const ShowDisambigDialogCallback& show_disambig_dialog_cb)
56 : content::NavigationThrottle(navigation_handle), 57 : content::NavigationThrottle(navigation_handle),
57 show_disambig_dialog_callback_(show_disambig_dialog_cb), 58 show_disambig_dialog_callback_(show_disambig_dialog_cb),
58 weak_ptr_factory_(this) {} 59 weak_ptr_factory_(this) {}
59 60
60 ArcNavigationThrottle::~ArcNavigationThrottle() = default; 61 ArcNavigationThrottle::~ArcNavigationThrottle() = default;
61 62
62 content::NavigationThrottle::ThrottleCheckResult 63 content::NavigationThrottle::ThrottleCheckResult
63 ArcNavigationThrottle::WillStartRequest() { 64 ArcNavigationThrottle::WillStartRequest() {
64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
65 if (!navigation_handle()->HasUserGesture()) 66
67 const ui::PageTransition transition =
68 navigation_handle()->GetPageTransition();
69
70 if (!ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK)) {
71 // If this navigation event wasn't spawned by the user clicking on a link.
66 return content::NavigationThrottle::PROCEED; 72 return content::NavigationThrottle::PROCEED;
73 }
74
75 if (ui::PageTransitionGetQualifier(transition) != 0) {
76 // Qualifiers indicate that this navigation was the result of a click on a
77 // forward/back button, or a redirect, or typing in the URL bar, etc. Don't
78 // pass any of those types of navigations to the intent helper (see
79 // crbug.com/630072).
80 return content::NavigationThrottle::PROCEED;
81 }
67 82
68 const GURL& url = navigation_handle()->GetURL(); 83 const GURL& url = navigation_handle()->GetURL();
69 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); 84 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper();
70 if (!bridge_instance) 85 if (!bridge_instance)
71 return content::NavigationThrottle::PROCEED; 86 return content::NavigationThrottle::PROCEED;
72 bridge_instance->RequestUrlHandlerList( 87 bridge_instance->RequestUrlHandlerList(
73 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, 88 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived,
74 weak_ptr_factory_.GetWeakPtr())); 89 weak_ptr_factory_.GetWeakPtr()));
75 return content::NavigationThrottle::DEFER; 90 return content::NavigationThrottle::DEFER;
76 } 91 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return; 216 return;
202 } 217 }
203 } 218 }
204 219
205 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", 220 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction",
206 static_cast<int>(close_reason), 221 static_cast<int>(close_reason),
207 static_cast<int>(CloseReason::SIZE)); 222 static_cast<int>(CloseReason::SIZE));
208 } 223 }
209 224
210 } // namespace arc 225 } // 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