| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/frame/LocalFrame.h" | 30 #include "core/frame/LocalFrame.h" |
| 31 #include "core/loader/DocumentLoader.h" | 31 #include "core/loader/DocumentLoader.h" |
| 32 #include "core/loader/FrameLoader.h" | 32 #include "core/loader/FrameLoader.h" |
| 33 #include "core/loader/FrameLoaderClient.h" | 33 #include "core/loader/FrameLoaderClient.h" |
| 34 #include "core/loader/HistoryItem.h" | 34 #include "core/loader/HistoryItem.h" |
| 35 #include "core/loader/NavigationScheduler.h" | 35 #include "core/loader/NavigationScheduler.h" |
| 36 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
| 37 #include "platform/RuntimeEnabledFeatures.h" | 37 #include "platform/RuntimeEnabledFeatures.h" |
| 38 #include "platform/weborigin/KURL.h" | 38 #include "platform/weborigin/KURL.h" |
| 39 #include "platform/weborigin/SecurityOrigin.h" | 39 #include "platform/weborigin/SecurityOrigin.h" |
| 40 #include "wtf/text/StringView.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 bool equalIgnoringPathQueryAndFragment(const KURL& a, const KURL& b) | 46 bool equalIgnoringPathQueryAndFragment(const KURL& a, const KURL& b) |
| 46 { | 47 { |
| 47 int aLength = a.pathStart(); | 48 return StringView(a.getString(), 0, a.pathStart()) == StringView(b.getString
(), 0, b.pathStart()); |
| 48 int bLength = b.pathStart(); | |
| 49 | |
| 50 if (aLength != bLength) | |
| 51 return false; | |
| 52 | |
| 53 const String& aString = a.getString(); | |
| 54 const String& bString = b.getString(); | |
| 55 for (int i = 0; i < aLength; ++i) { | |
| 56 if (aString[i] != bString[i]) | |
| 57 return false; | |
| 58 } | |
| 59 return true; | |
| 60 } | 49 } |
| 61 | 50 |
| 62 bool equalIgnoringQueryAndFragment(const KURL& a, const KURL& b) | 51 bool equalIgnoringQueryAndFragment(const KURL& a, const KURL& b) |
| 63 { | 52 { |
| 64 int aLength = a.pathEnd(); | 53 return StringView(a.getString(), 0, a.pathEnd()) == StringView(b.getString()
, 0, b.pathEnd()); |
| 65 int bLength = b.pathEnd(); | |
| 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 } | 54 } |
| 78 | 55 |
| 79 } // namespace | 56 } // namespace |
| 80 | 57 |
| 81 History::History(LocalFrame* frame) | 58 History::History(LocalFrame* frame) |
| 82 : DOMWindowProperty(frame) | 59 : DOMWindowProperty(frame) |
| 83 , m_lastStateObjectRequested(nullptr) | 60 , m_lastStateObjectRequested(nullptr) |
| 84 { | 61 { |
| 85 } | 62 } |
| 86 | 63 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (!canChangeToUrl(fullURL, m_frame->document()->getSecurityOrigin(), m_fra
me->document()->url())) { | 211 if (!canChangeToUrl(fullURL, m_frame->document()->getSecurityOrigin(), m_fra
me->document()->url())) { |
| 235 // 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. | 212 // 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. |
| 236 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() + "'."); | 213 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() + "'."); |
| 237 return; | 214 return; |
| 238 } | 215 } |
| 239 | 216 |
| 240 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig
ationHistoryApi, data, restorationType, type, m_frame->document()); | 217 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig
ationHistoryApi, data, restorationType, type, m_frame->document()); |
| 241 } | 218 } |
| 242 | 219 |
| 243 } // namespace blink | 220 } // namespace blink |
| OLD | NEW |