Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 52 |
| 53 const String& aString = a.getString(); | 53 const String& aString = a.getString(); |
| 54 const String& bString = b.getString(); | 54 const String& bString = b.getString(); |
| 55 for (int i = 0; i < aLength; ++i) { | 55 for (int i = 0; i < aLength; ++i) { |
| 56 if (aString[i] != bString[i]) | 56 if (aString[i] != bString[i]) |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool equalIgnoringQueryAndFragment(const KURL& a, const KURL& b) | |
| 63 { | |
| 64 int aLength = (a.parsed().query.len >= 0) ? (a.parsed().query.begin - 1) : ( (a.parsed().ref.len >= 0) ? (a.parsed().ref.begin - 1) : (a.getString().length() )); | |
|
Mike West
2016/06/16 09:23:13
Is `a.pathEnd()` not correct here? I don't underst
Peng Xinchao
2016/06/17 11:09:52
Done.
You are right , i misunderstand path of URL
| |
| 65 int bLength = (b.parsed().query.len >= 0) ? (b.parsed().query.begin - 1) : ( (b.parsed().ref.len >= 0) ? (b.parsed().ref.begin - 1) : (b.getString().length() )); | |
|
Mike West
2016/06/16 09:23:13
Ditto.
| |
| 66 | |
| 67 if (aLength != bLength) | |
| 68 return false; | |
| 69 | |
| 70 const String& aString = a.getString(); | |
| 71 const String& bString = b.getString(); | |
| 72 for (int i = 0; i < aLength; ++i) { | |
| 73 if (aString[i] != bString[i]) | |
| 74 return false; | |
| 75 } | |
| 76 return true; | |
| 77 } | |
|
Mike West
2016/06/16 09:23:13
Nit: Newline.
Peng Xinchao
2016/06/17 11:09:52
Done.
| |
| 62 } // namespace | 78 } // namespace |
| 63 | 79 |
| 64 History::History(LocalFrame* frame) | 80 History::History(LocalFrame* frame) |
| 65 : DOMWindowProperty(frame) | 81 : DOMWindowProperty(frame) |
| 66 , m_lastStateObjectRequested(nullptr) | 82 , m_lastStateObjectRequested(nullptr) |
| 67 { | 83 { |
| 68 } | 84 } |
| 69 | 85 |
| 70 DEFINE_TRACE(History) | 86 DEFINE_TRACE(History) |
| 71 { | 87 { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 if (!url.isValid()) | 205 if (!url.isValid()) |
| 190 return false; | 206 return false; |
| 191 | 207 |
| 192 if (documentOrigin->isGrantedUniversalAccess()) | 208 if (documentOrigin->isGrantedUniversalAccess()) |
| 193 return true; | 209 return true; |
| 194 | 210 |
| 195 // We allow sandboxed documents, `data:`/`file:` URLs, etc. to use | 211 // We allow sandboxed documents, `data:`/`file:` URLs, etc. to use |
| 196 // 'pushState'/'replaceState' to modify the URL fragment: see | 212 // 'pushState'/'replaceState' to modify the URL fragment: see |
| 197 // https://crbug.com/528681 for the compatibility concerns. | 213 // https://crbug.com/528681 for the compatibility concerns. |
| 198 if (documentOrigin->isUnique() || documentOrigin->isLocal()) | 214 if (documentOrigin->isUnique() || documentOrigin->isLocal()) |
| 199 return equalIgnoringFragmentIdentifier(url, documentURL); | 215 return equalIgnoringQueryAndFragment(url, documentURL); |
| 200 | 216 |
| 201 if (!equalIgnoringPathQueryAndFragment(url, documentURL)) | 217 if (!equalIgnoringPathQueryAndFragment(url, documentURL)) |
| 202 return false; | 218 return false; |
| 203 | 219 |
| 204 RefPtr<SecurityOrigin> requestedOrigin = SecurityOrigin::create(url); | 220 RefPtr<SecurityOrigin> requestedOrigin = SecurityOrigin::create(url); |
| 205 if (requestedOrigin->isUnique() || !requestedOrigin->isSameSchemeHostPort(do cumentOrigin)) | 221 if (requestedOrigin->isUnique() || !requestedOrigin->isSameSchemeHostPort(do cumentOrigin)) |
| 206 return false; | 222 return false; |
| 207 | 223 |
| 208 return true; | 224 return true; |
| 209 } | 225 } |
| 210 | 226 |
| 211 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str ing& /* title */, const String& urlString, HistoryScrollRestorationType restorat ionType, FrameLoadType type, ExceptionState& exceptionState) | 227 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str ing& /* title */, const String& urlString, HistoryScrollRestorationType restorat ionType, FrameLoadType type, ExceptionState& exceptionState) |
| 212 { | 228 { |
| 213 if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader()) | 229 if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader()) |
| 214 return; | 230 return; |
| 215 | 231 |
| 216 KURL fullURL = urlForState(urlString); | 232 KURL fullURL = urlForState(urlString); |
| 217 if (!canChangeToUrl(fullURL, m_frame->document()->getSecurityOrigin(), m_fra me->document()->url())) { | 233 if (!canChangeToUrl(fullURL, m_frame->document()->getSecurityOrigin(), m_fra me->document()->url())) { |
| 218 // We can safely expose the URL to JavaScript, as a) no redirection take s place: JavaScript already had this URL, b) JavaScript can only access a same-o rigin History object. | 234 // We can safely expose the URL to JavaScript, as a) no redirection take s place: JavaScript already had this URL, b) JavaScript can only access a same-o rigin History object. |
| 219 exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f rame->document()->getSecurityOrigin()->toString() + "' and URL '" + m_frame->doc ument()->url().elidedString() + "'."); | 235 exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f rame->document()->getSecurityOrigin()->toString() + "' and URL '" + m_frame->doc ument()->url().elidedString() + "'."); |
| 220 return; | 236 return; |
| 221 } | 237 } |
| 222 | 238 |
| 223 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig ationHistoryApi, data, restorationType, type, m_frame->document()); | 239 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig ationHistoryApi, data, restorationType, type, m_frame->document()); |
| 224 } | 240 } |
| 225 | 241 |
| 226 } // namespace blink | 242 } // namespace blink |
| OLD | NEW |