| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (!frame()) | 77 if (!frame()) |
| 78 return 0; | 78 return 0; |
| 79 | 79 |
| 80 if (HistoryItem* historyItem = frame()->loader().currentItem()) | 80 if (HistoryItem* historyItem = frame()->loader().currentItem()) |
| 81 return historyItem->stateObject(); | 81 return historyItem->stateObject(); |
| 82 | 82 |
| 83 return 0; | 83 return 0; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void History::setScrollRestoration(const String& value) { | 86 void History::setScrollRestoration(const String& value) { |
| 87 ASSERT(value == "manual" || value == "auto"); | 87 DCHECK(value == "manual" || value == "auto"); |
| 88 if (!frame() || !frame()->loader().client()) | 88 if (!frame() || !frame()->loader().client()) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 HistoryScrollRestorationType scrollRestoration = | 91 HistoryScrollRestorationType scrollRestoration = |
| 92 value == "manual" ? ScrollRestorationManual : ScrollRestorationAuto; | 92 value == "manual" ? ScrollRestorationManual : ScrollRestorationAuto; |
| 93 if (scrollRestoration == scrollRestorationInternal()) | 93 if (scrollRestoration == scrollRestorationInternal()) |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 if (HistoryItem* historyItem = frame()->loader().currentItem()) { | 96 if (HistoryItem* historyItem = frame()->loader().currentItem()) { |
| 97 historyItem->setScrollRestorationType(scrollRestoration); | 97 historyItem->setScrollRestorationType(scrollRestoration); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 void History::forward(ExecutionContext* context) { | 128 void History::forward(ExecutionContext* context) { |
| 129 go(context, 1); | 129 go(context, 1); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void History::go(ExecutionContext* context, int delta) { | 132 void History::go(ExecutionContext* context, int delta) { |
| 133 if (!frame() || !frame()->loader().client()) | 133 if (!frame() || !frame()->loader().client()) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 ASSERT(isMainThread()); | 136 DCHECK(isMainThread()); |
| 137 Document* activeDocument = toDocument(context); | 137 Document* activeDocument = toDocument(context); |
| 138 if (!activeDocument) | 138 if (!activeDocument) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 if (!activeDocument->frame() || | 141 if (!activeDocument->frame() || |
| 142 !activeDocument->frame()->canNavigate(*frame())) | 142 !activeDocument->frame()->canNavigate(*frame())) { |
| 143 return; | 143 return; |
| 144 } |
| 144 if (!NavigationDisablerForUnload::isNavigationAllowed()) | 145 if (!NavigationDisablerForUnload::isNavigationAllowed()) |
| 145 return; | 146 return; |
| 146 | 147 |
| 147 // We intentionally call reload() for the current frame if delta is zero. | 148 // We intentionally call reload() for the current frame if delta is zero. |
| 148 // Otherwise, navigation happens on the root frame. | 149 // Otherwise, navigation happens on the root frame. |
| 149 // This behavior is designed in the following spec. | 150 // This behavior is designed in the following spec. |
| 150 // https://html.spec.whatwg.org/multipage/browsers.html#dom-history-go | 151 // https://html.spec.whatwg.org/multipage/browsers.html#dom-history-go |
| 151 if (delta) | 152 if (delta) |
| 152 frame()->loader().client()->navigateBackForward(delta); | 153 frame()->loader().client()->navigateBackForward(delta); |
| 153 else | 154 else |
| (...skipping 24 matching lines...) Expand all Loading... |
| 178 // 'pushState'/'replaceState' to modify the URL fragment: see | 179 // 'pushState'/'replaceState' to modify the URL fragment: see |
| 179 // https://crbug.com/528681 for the compatibility concerns. | 180 // https://crbug.com/528681 for the compatibility concerns. |
| 180 if (documentOrigin->isUnique() || documentOrigin->isLocal()) | 181 if (documentOrigin->isUnique() || documentOrigin->isLocal()) |
| 181 return equalIgnoringQueryAndFragment(url, documentURL); | 182 return equalIgnoringQueryAndFragment(url, documentURL); |
| 182 | 183 |
| 183 if (!equalIgnoringPathQueryAndFragment(url, documentURL)) | 184 if (!equalIgnoringPathQueryAndFragment(url, documentURL)) |
| 184 return false; | 185 return false; |
| 185 | 186 |
| 186 RefPtr<SecurityOrigin> requestedOrigin = SecurityOrigin::create(url); | 187 RefPtr<SecurityOrigin> requestedOrigin = SecurityOrigin::create(url); |
| 187 if (requestedOrigin->isUnique() || | 188 if (requestedOrigin->isUnique() || |
| 188 !requestedOrigin->isSameSchemeHostPort(documentOrigin)) | 189 !requestedOrigin->isSameSchemeHostPort(documentOrigin)) { |
| 189 return false; | 190 return false; |
| 191 } |
| 190 | 192 |
| 191 return true; | 193 return true; |
| 192 } | 194 } |
| 193 | 195 |
| 194 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, | 196 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, |
| 195 const String& /* title */, | 197 const String& /* title */, |
| 196 const String& urlString, | 198 const String& urlString, |
| 197 HistoryScrollRestorationType restorationType, | 199 HistoryScrollRestorationType restorationType, |
| 198 FrameLoadType type, | 200 FrameLoadType type, |
| 199 ExceptionState& exceptionState) { | 201 ExceptionState& exceptionState) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 213 frame()->document()->url().elidedString() + "'."); | 215 frame()->document()->url().elidedString() + "'."); |
| 214 return; | 216 return; |
| 215 } | 217 } |
| 216 | 218 |
| 217 frame()->loader().updateForSameDocumentNavigation( | 219 frame()->loader().updateForSameDocumentNavigation( |
| 218 fullURL, SameDocumentNavigationHistoryApi, std::move(data), | 220 fullURL, SameDocumentNavigationHistoryApi, std::move(data), |
| 219 restorationType, type, frame()->document()); | 221 restorationType, type, frame()->document()); |
| 220 } | 222 } |
| 221 | 223 |
| 222 } // namespace blink | 224 } // namespace blink |
| OLD | NEW |