OLD | NEW |
---|---|
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 Loading... | |
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. We don't use GetVisibleURL() since it may contains a still | |
Yusuke Sato
2016/10/20 15:20:53
nit: contain?
djacobo_
2016/10/20 18:38:14
Done.
| |
130 // non-committed URL (i.e. it can be the same as GetURL()). | |
131 const GURL previous_url = | |
132 referrer_url.is_empty() ? last_committed_url : referrer_url; | |
Yusuke Sato
2016/10/20 15:20:52
qq: We still need the is_empty() check because the
djacobo_
2016/10/20 18:38:14
Correct, the navigation started with target="_blan
Yusuke Sato
2016/10/20 19:32:05
Can you mention this in the code comment?
djacobo_
2016/10/20 20:07:31
Done.
| |
133 | |
124 if (!ShouldOverrideUrlLoading(previous_url, current_url)) | 134 if (!ShouldOverrideUrlLoading(previous_url, current_url)) |
125 return content::NavigationThrottle::PROCEED; | 135 return content::NavigationThrottle::PROCEED; |
126 | 136 |
127 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); | 137 ArcServiceManager* arc_service_manager = ArcServiceManager::Get(); |
128 DCHECK(arc_service_manager); | 138 DCHECK(arc_service_manager); |
129 scoped_refptr<LocalActivityResolver> local_resolver = | 139 scoped_refptr<LocalActivityResolver> local_resolver = |
130 arc_service_manager->activity_resolver(); | 140 arc_service_manager->activity_resolver(); |
131 if (local_resolver->ShouldChromeHandleUrl(url)) { | 141 if (local_resolver->ShouldChromeHandleUrl(url)) { |
132 // Allow navigation to proceed if there isn't an android app that handles | 142 // Allow navigation to proceed if there isn't an android app that handles |
133 // the given URL. | 143 // the given URL. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 } | 303 } |
294 | 304 |
295 // static | 305 // static |
296 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( | 306 bool ArcNavigationThrottle::ShouldOverrideUrlLoadingForTesting( |
297 const GURL& previous_url, | 307 const GURL& previous_url, |
298 const GURL& current_url) { | 308 const GURL& current_url) { |
299 return ShouldOverrideUrlLoading(previous_url, current_url); | 309 return ShouldOverrideUrlLoading(previous_url, current_url); |
300 } | 310 } |
301 | 311 |
302 } // namespace arc | 312 } // namespace arc |
OLD | NEW |