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

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

Issue 2113123002: Filters out URL clicks based on host matching only. (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 unified diff | Download patch
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"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 weak_ptr_factory_(this) {} 58 weak_ptr_factory_(this) {}
59 59
60 ArcNavigationThrottle::~ArcNavigationThrottle() = default; 60 ArcNavigationThrottle::~ArcNavigationThrottle() = default;
61 61
62 content::NavigationThrottle::ThrottleCheckResult 62 content::NavigationThrottle::ThrottleCheckResult
63 ArcNavigationThrottle::WillStartRequest() { 63 ArcNavigationThrottle::WillStartRequest() {
64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
65 if (!navigation_handle()->HasUserGesture()) 65 if (!navigation_handle()->HasUserGesture())
66 return content::NavigationThrottle::PROCEED; 66 return content::NavigationThrottle::PROCEED;
67 67
68 if (!ShouldOverrideUrlLoading())
69 return content::NavigationThrottle::PROCEED;
70
68 const GURL& url = navigation_handle()->GetURL(); 71 const GURL& url = navigation_handle()->GetURL();
69 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper(); 72 mojom::IntentHelperInstance* bridge_instance = GetIntentHelper();
70 if (!bridge_instance) 73 if (!bridge_instance)
71 return content::NavigationThrottle::PROCEED; 74 return content::NavigationThrottle::PROCEED;
72 bridge_instance->RequestUrlHandlerList( 75 bridge_instance->RequestUrlHandlerList(
73 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived, 76 url.spec(), base::Bind(&ArcNavigationThrottle::OnAppCandidatesReceived,
74 weak_ptr_factory_.GetWeakPtr())); 77 weak_ptr_factory_.GetWeakPtr()));
75 return content::NavigationThrottle::DEFER; 78 return content::NavigationThrottle::DEFER;
76 } 79 }
77 80
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 NOTREACHED(); 203 NOTREACHED();
201 return; 204 return;
202 } 205 }
203 } 206 }
204 207
205 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction", 208 UMA_HISTOGRAM_ENUMERATION("Arc.IntentHandlerAction",
206 static_cast<int>(close_reason), 209 static_cast<int>(close_reason),
207 static_cast<int>(CloseReason::SIZE)); 210 static_cast<int>(CloseReason::SIZE));
208 } 211 }
209 212
213 bool ArcNavigationThrottle::ShouldOverrideUrlLoading() {
Yusuke Sato 2016/07/01 14:05:24 Is it possible to add unit tests for this?
malaykeshav 2016/07/01 23:20:41 Can be made unit testable. Just need to pass navig
214 std::string previous_url = navigation_handle()->GetReferrer().url.host();
215 std::string current_url = navigation_handle()->GetURL().host();
216 if (current_url == previous_url)
Yusuke Sato 2016/07/01 14:05:24 I think this function should also return false whe
malaykeshav 2016/07/01 23:20:41 If we are going from mail.google.com to maps.googl
Yusuke Sato 2016/07/01 23:35:56 The original Clank code seems to properly handle s
217 return false;
218 return true;
219 }
220
210 } // namespace arc 221 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698