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 12 matching lines...) Expand all Loading... | |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/frame/History.h" | 27 #include "core/frame/History.h" |
28 | 28 |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
32 #include "core/frame/LocalFrame.h" | 32 #include "core/frame/LocalFrame.h" |
33 #include "core/frame/StateOptions.h" | |
33 #include "core/loader/DocumentLoader.h" | 34 #include "core/loader/DocumentLoader.h" |
34 #include "core/loader/FrameLoader.h" | 35 #include "core/loader/FrameLoader.h" |
35 #include "core/loader/FrameLoaderClient.h" | 36 #include "core/loader/FrameLoaderClient.h" |
36 #include "core/loader/HistoryItem.h" | 37 #include "core/loader/HistoryItem.h" |
37 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
39 #include "platform/RuntimeEnabledFeatures.h" | |
38 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
39 #include "platform/weborigin/SecurityOrigin.h" | 41 #include "platform/weborigin/SecurityOrigin.h" |
40 #include "wtf/MainThread.h" | 42 #include "wtf/MainThread.h" |
41 | 43 |
42 namespace blink { | 44 namespace blink { |
43 | 45 |
44 History::History(LocalFrame* frame) | 46 History::History(LocalFrame* frame) |
45 : DOMWindowProperty(frame) | 47 : DOMWindowProperty(frame) |
46 , m_lastStateObjectRequested(nullptr) | 48 , m_lastStateObjectRequested(nullptr) |
47 { | 49 { |
(...skipping 21 matching lines...) Expand all Loading... | |
69 { | 71 { |
70 if (!m_frame) | 72 if (!m_frame) |
71 return 0; | 73 return 0; |
72 | 74 |
73 if (HistoryItem* historyItem = m_frame->loader().currentItem()) | 75 if (HistoryItem* historyItem = m_frame->loader().currentItem()) |
74 return historyItem->stateObject(); | 76 return historyItem->stateObject(); |
75 | 77 |
76 return 0; | 78 return 0; |
77 } | 79 } |
78 | 80 |
81 void History::options(StateOptions& options) | |
82 { | |
83 if (!m_frame) | |
84 return; | |
85 | |
86 if (HistoryItem* historyItem = m_frame->loader().currentItem()) { | |
87 options.setWillRestoreScroll(!historyItem->shouldRestoreScroll()); | |
Nate Chapin
2015/05/07 20:26:59
The name of this function implies it's a getter, b
majidvp
2015/05/08 21:00:46
Done.
| |
88 } | |
89 } | |
90 | |
79 bool History::stateChanged() const | 91 bool History::stateChanged() const |
80 { | 92 { |
81 return m_lastStateObjectRequested != stateInternal(); | 93 return m_lastStateObjectRequested != stateInternal(); |
82 } | 94 } |
83 | 95 |
84 bool History::isSameAsCurrentState(SerializedScriptValue* state) const | 96 bool History::isSameAsCurrentState(SerializedScriptValue* state) const |
85 { | 97 { |
86 return state == stateInternal(); | 98 return state == stateInternal(); |
87 } | 99 } |
88 | 100 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 Document* document = m_frame->document(); | 132 Document* document = m_frame->document(); |
121 | 133 |
122 if (urlString.isNull()) | 134 if (urlString.isNull()) |
123 return document->url(); | 135 return document->url(); |
124 if (urlString.isEmpty()) | 136 if (urlString.isEmpty()) |
125 return document->baseURL(); | 137 return document->baseURL(); |
126 | 138 |
127 return KURL(document->baseURL(), urlString); | 139 return KURL(document->baseURL(), urlString); |
128 } | 140 } |
129 | 141 |
130 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str ing& /* title */, const String& urlString, FrameLoadType type, ExceptionState& e xceptionState) | 142 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str ing& /* title */, const String& urlString, const StateOptions& options, FrameLoa dType type, ExceptionState& exceptionState) |
131 { | 143 { |
132 if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader()) | 144 if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader()) |
133 return; | 145 return; |
134 | 146 |
135 KURL fullURL = urlForState(urlString); | 147 KURL fullURL = urlForState(urlString); |
136 if (!fullURL.isValid() || !m_frame->document()->securityOrigin()->canRequest (fullURL)) { | 148 if (!fullURL.isValid() || !m_frame->document()->securityOrigin()->canRequest (fullURL)) { |
137 // 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. | 149 // 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. |
138 exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f rame->document()->securityOrigin()->toString() + "'."); | 150 exceptionState.throwSecurityError("A history state object with URL '" + fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f rame->document()->securityOrigin()->toString() + "'."); |
139 return; | 151 return; |
140 } | 152 } |
141 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig ationHistoryApi, data, type); | 153 |
154 bool shouldRestoreScroll = true; | |
155 if (RuntimeEnabledFeatures::scrollRestorationEnabled()) | |
156 shouldRestoreScroll = !options.willRestoreScroll(); | |
Nate Chapin
2015/05/07 20:26:59
This inversion doesn't make sense, given the names
majidvp
2015/05/08 21:00:46
Done.
| |
157 | |
158 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig ationHistoryApi, data, shouldRestoreScroll, type); | |
142 } | 159 } |
143 | 160 |
144 } // namespace blink | 161 } // namespace blink |
OLD | NEW |