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

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

Issue 2436923002: Capture http to https navigations w/ intent picker (Closed)
Patch Set: Adding up to the code comments. 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 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"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // don't have a way to send POST data to ARC, and 2) intercepting http(s) form 112 // don't have a way to send POST data to ARC, and 2) intercepting http(s) form
113 // submissions is not very important because such submissions are usually 113 // submissions is not very important because such submissions are usually
114 // done within the same domain. ShouldOverrideUrlLoading() below filters out 114 // done within the same domain. ShouldOverrideUrlLoading() below filters out
115 // such submissions anyway. 115 // such submissions anyway.
116 constexpr bool kAllowFormSubmit = false; 116 constexpr bool kAllowFormSubmit = false;
117 117
118 if (ShouldIgnoreNavigation(navigation_handle()->GetPageTransition(), 118 if (ShouldIgnoreNavigation(navigation_handle()->GetPageTransition(),
119 kAllowFormSubmit)) 119 kAllowFormSubmit))
120 return content::NavigationThrottle::PROCEED; 120 return content::NavigationThrottle::PROCEED;
121 121
122 const GURL previous_url = navigation_handle()->GetReferrer().url; 122 const GURL referrer_url = navigation_handle()->GetReferrer().url;
123 const GURL current_url = navigation_handle()->GetURL(); 123 const GURL current_url = navigation_handle()->GetURL();
124 const GURL last_committed_url =
125 navigation_handle()->GetWebContents()->GetLastCommittedURL();
126
127 // For navigations from http to https we clean up the Referrer as part of the
128 // sanitization proccess, however we may still have access to the last
129 // committed URL. On the other hand, navigations started within a new tab
130 // (e.g. due to target="_blank") will keep no track of any previous entries
131 // and so GetLastCommittedURL() can be seen empty sometimes, this is why we
132 // use one or the other accordingly. Also we don't use GetVisibleURL() since
133 // it may contain a still non-committed URL (i.e. it can be the same as
134 // GetURL()).
135 const GURL previous_url =
136 referrer_url.is_empty() ? last_committed_url : referrer_url;
137
124 if (!ShouldOverrideUrlLoading(previous_url, current_url)) 138 if (!ShouldOverrideUrlLoading(previous_url, current_url))
125 return content::NavigationThrottle::PROCEED; 139 return content::NavigationThrottle::PROCEED;
126 140
127 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); 141 ArcServiceManager* arc_service_manager = ArcServiceManager::Get();
128 DCHECK(arc_service_manager); 142 DCHECK(arc_service_manager);
129 scoped_refptr<LocalActivityResolver> local_resolver = 143 scoped_refptr<LocalActivityResolver> local_resolver =
130 arc_service_manager->activity_resolver(); 144 arc_service_manager->activity_resolver();
131 if (local_resolver->ShouldChromeHandleUrl(url)) { 145 if (local_resolver->ShouldChromeHandleUrl(url)) {
132 // Allow navigation to proceed if there isn't an android app that handles 146 // Allow navigation to proceed if there isn't an android app that handles
133 // the given URL. 147 // the given URL.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 307 }
294 308
295 // static 309 // static
296 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( 310 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting(
297 const GURL& previous_url, 311 const GURL& previous_url,
298 const GURL& current_url) { 312 const GURL& current_url) {
299 return ShouldOverrideUrlLoading(previous_url, current_url); 313 return ShouldOverrideUrlLoading(previous_url, current_url);
300 } 314 }
301 315
302 } // namespace arc 316 } // 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