Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/web/history_state_util.h" | 5 #import "ios/web/history_state_util.h" |
|
sdefresne
2016/11/21 12:34:30
This file has no Objective-C AFAICT. I think it wo
stkhapugin
2016/11/21 15:38:31
Done.
| |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 11 #error "This file requires ARC support." | |
| 12 #endif | |
| 13 | |
| 10 namespace web { | 14 namespace web { |
| 11 namespace history_state_util { | 15 namespace history_state_util { |
| 12 | 16 |
| 13 bool IsHistoryStateChangeValid(const GURL& currentUrl, | 17 bool IsHistoryStateChangeValid(const GURL& currentUrl, |
| 14 const GURL& toUrl) { | 18 const GURL& toUrl) { |
| 15 // These two checks are very important to the security of the page. We cannot | 19 // These two checks are very important to the security of the page. We cannot |
| 16 // allow the page to change the state to an invalid URL. | 20 // allow the page to change the state to an invalid URL. |
| 17 CHECK(currentUrl.is_valid()); | 21 CHECK(currentUrl.is_valid()); |
| 18 CHECK(toUrl.is_valid()); | 22 CHECK(toUrl.is_valid()); |
| 19 | 23 |
| 20 return toUrl.GetOrigin() == currentUrl.GetOrigin(); | 24 return toUrl.GetOrigin() == currentUrl.GetOrigin(); |
| 21 } | 25 } |
| 22 | 26 |
| 23 GURL GetHistoryStateChangeUrl(const GURL& currentUrl, | 27 GURL GetHistoryStateChangeUrl(const GURL& currentUrl, |
| 24 const GURL& baseUrl, | 28 const GURL& baseUrl, |
| 25 const std::string& destination) { | 29 const std::string& destination) { |
| 26 if (!baseUrl.is_valid()) | 30 if (!baseUrl.is_valid()) |
| 27 return GURL(); | 31 return GURL(); |
| 28 GURL toUrl = baseUrl.Resolve(destination); | 32 GURL toUrl = baseUrl.Resolve(destination); |
| 29 | 33 |
| 30 if (!toUrl.is_valid() || !IsHistoryStateChangeValid(currentUrl, toUrl)) | 34 if (!toUrl.is_valid() || !IsHistoryStateChangeValid(currentUrl, toUrl)) |
| 31 return GURL(); | 35 return GURL(); |
| 32 | 36 |
| 33 return toUrl; | 37 return toUrl; |
| 34 } | 38 } |
| 35 | 39 |
| 36 } // namespace history_state_util | 40 } // namespace history_state_util |
| 37 } // namespace web | 41 } // namespace web |
| OLD | NEW |