| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 void History::trace(Visitor* visitor) | 50 void History::trace(Visitor* visitor) |
| 51 { | 51 { |
| 52 DOMWindowProperty::trace(visitor); | 52 DOMWindowProperty::trace(visitor); |
| 53 } | 53 } |
| 54 | 54 |
| 55 unsigned History::length() const | 55 unsigned History::length() const |
| 56 { | 56 { |
| 57 if (!m_frame || !m_frame->loader().client()) | 57 if (!localFrame() || !localFrame()->loader().client()) |
| 58 return 0; | 58 return 0; |
| 59 return m_frame->loader().client()->backForwardLength(); | 59 return localFrame()->loader().client()->backForwardLength(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 SerializedScriptValue* History::state() | 62 SerializedScriptValue* History::state() |
| 63 { | 63 { |
| 64 m_lastStateObjectRequested = stateInternal(); | 64 m_lastStateObjectRequested = stateInternal(); |
| 65 return m_lastStateObjectRequested.get(); | 65 return m_lastStateObjectRequested.get(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 SerializedScriptValue* History::stateInternal() const | 68 SerializedScriptValue* History::stateInternal() const |
| 69 { | 69 { |
| 70 if (!m_frame) | 70 if (!localFrame()) |
| 71 return 0; | 71 return 0; |
| 72 | 72 |
| 73 if (HistoryItem* historyItem = m_frame->loader().currentItem()) | 73 if (HistoryItem* historyItem = localFrame()->loader().currentItem()) |
| 74 return historyItem->stateObject(); | 74 return historyItem->stateObject(); |
| 75 | 75 |
| 76 return 0; | 76 return 0; |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool History::stateChanged() const | 79 bool History::stateChanged() const |
| 80 { | 80 { |
| 81 return m_lastStateObjectRequested != stateInternal(); | 81 return m_lastStateObjectRequested != stateInternal(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool History::isSameAsCurrentState(SerializedScriptValue* state) const | 84 bool History::isSameAsCurrentState(SerializedScriptValue* state) const |
| 85 { | 85 { |
| 86 return state == stateInternal(); | 86 return state == stateInternal(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void History::back(ExecutionContext* context) | 89 void History::back(ExecutionContext* context) |
| 90 { | 90 { |
| 91 go(context, -1); | 91 go(context, -1); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void History::forward(ExecutionContext* context) | 94 void History::forward(ExecutionContext* context) |
| 95 { | 95 { |
| 96 go(context, 1); | 96 go(context, 1); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void History::go(ExecutionContext* context, int distance) | 99 void History::go(ExecutionContext* context, int distance) |
| 100 { | 100 { |
| 101 if (!m_frame || !m_frame->loader().client()) | 101 if (!localFrame() || !localFrame()->loader().client()) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 ASSERT(isMainThread()); | 104 ASSERT(isMainThread()); |
| 105 Document* activeDocument = toDocument(context); | 105 Document* activeDocument = toDocument(context); |
| 106 if (!activeDocument) | 106 if (!activeDocument) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*m_fra
me)) | 109 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*m_fra
me)) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 if (distance) | 112 if (distance) |
| 113 m_frame->loader().client()->navigateBackForward(distance); | 113 localFrame()->loader().client()->navigateBackForward(distance); |
| 114 else | 114 else |
| 115 m_frame->reload(NormalReload, ClientRedirect); | 115 m_frame->reload(NormalReload, ClientRedirect); |
| 116 } | 116 } |
| 117 | 117 |
| 118 KURL History::urlForState(const String& urlString) | 118 KURL History::urlForState(const String& urlString) |
| 119 { | 119 { |
| 120 Document* document = m_frame->document(); | 120 Document* document = localFrame()->document(); |
| 121 | 121 |
| 122 if (urlString.isNull()) | 122 if (urlString.isNull()) |
| 123 return document->url(); | 123 return document->url(); |
| 124 if (urlString.isEmpty()) | 124 if (urlString.isEmpty()) |
| 125 return document->baseURL(); | 125 return document->baseURL(); |
| 126 | 126 |
| 127 return KURL(document->baseURL(), urlString); | 127 return KURL(document->baseURL(), urlString); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
ing& /* title */, const String& urlString, FrameLoadType type, ExceptionState& e
xceptionState) | 130 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
ing& /* title */, const String& urlString, FrameLoadType type, ExceptionState& e
xceptionState) |
| 131 { | 131 { |
| 132 if (!m_frame || !m_frame->page() || !m_frame->loader().documentLoader()) | 132 if (!localFrame() || !localFrame()->page() || !localFrame()->loader().docume
ntLoader()) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 KURL fullURL = urlForState(urlString); | 135 KURL fullURL = urlForState(urlString); |
| 136 if (!fullURL.isValid() || !m_frame->document()->securityOrigin()->canRequest
(fullURL)) { | 136 if (!fullURL.isValid() || !m_frame->securityContext()->securityOrigin()->can
Request(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. | 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. |
| 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() + "'."); | 138 exceptionState.throwSecurityError("A history state object with URL '" +
fullURL.elidedString() + "' cannot be created in a document with origin '" + m_f
rame->securityContext()->securityOrigin()->toString() + "'."); |
| 139 return; | 139 return; |
| 140 } | 140 } |
| 141 m_frame->loader().updateForSameDocumentNavigation(fullURL, SameDocumentNavig
ationHistoryApi, data, type); | 141 localFrame()->loader().updateForSameDocumentNavigation(fullURL, SameDocument
NavigationHistoryApi, data, type); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace blink | 144 } // namespace blink |
| OLD | NEW |