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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return; | 79 return; |
80 m_frame->redirectScheduler()->scheduleHistoryNavigation(distance); | 80 m_frame->redirectScheduler()->scheduleHistoryNavigation(distance); |
81 } | 81 } |
82 | 82 |
83 KURL History::urlForState(const String& urlString) | 83 KURL History::urlForState(const String& urlString) |
84 { | 84 { |
85 KURL baseURL = m_frame->loader()->baseURL(); | 85 KURL baseURL = m_frame->loader()->baseURL(); |
86 if (urlString.isEmpty()) | 86 if (urlString.isEmpty()) |
87 return baseURL; | 87 return baseURL; |
88 | 88 |
89 KURL absoluteURL(baseURL, urlString); | 89 return KURL(baseURL, urlString); |
90 if (!absoluteURL.isValid()) | |
91 return KURL(); | |
92 | |
93 if (absoluteURL.string().left(absoluteURL.pathStart()) != baseURL.string().l
eft(baseURL.pathStart())) | |
94 return KURL(); | |
95 | |
96 return absoluteURL; | |
97 } | 90 } |
98 | 91 |
99 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
ing& title, const String& urlString, StateObjectType stateObjectType, ExceptionC
ode& ec) | 92 void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const Str
ing& title, const String& urlString, StateObjectType stateObjectType, ExceptionC
ode& ec) |
100 { | 93 { |
101 if (!m_frame || !m_frame->page()) | 94 if (!m_frame || !m_frame->page()) |
102 return; | 95 return; |
103 | 96 |
104 KURL fullURL = urlForState(urlString); | 97 KURL fullURL = urlForState(urlString); |
105 if (!fullURL.isValid()) { | 98 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(fullURL); |
| 99 if (!fullURL.isValid() || !m_frame->document()->securityOrigin()->isSameSche
meHostPort(origin.get())) { |
106 ec = SECURITY_ERR; | 100 ec = SECURITY_ERR; |
107 return; | 101 return; |
108 } | 102 } |
109 | 103 |
110 if (stateObjectType == StateObjectPush) | 104 if (stateObjectType == StateObjectPush) |
111 m_frame->loader()->history()->pushState(data, title, fullURL.string()); | 105 m_frame->loader()->history()->pushState(data, title, fullURL.string()); |
112 else if (stateObjectType == StateObjectReplace) | 106 else if (stateObjectType == StateObjectReplace) |
113 m_frame->loader()->history()->replaceState(data, title, fullURL.string()
); | 107 m_frame->loader()->history()->replaceState(data, title, fullURL.string()
); |
114 | 108 |
115 if (!urlString.isEmpty()) | 109 if (!urlString.isEmpty()) |
116 m_frame->document()->updateURLForPushOrReplaceState(fullURL); | 110 m_frame->document()->updateURLForPushOrReplaceState(fullURL); |
117 | 111 |
118 if (stateObjectType == StateObjectPush) | 112 if (stateObjectType == StateObjectPush) |
119 m_frame->loader()->client()->dispatchDidPushStateWithinPage(); | 113 m_frame->loader()->client()->dispatchDidPushStateWithinPage(); |
120 else if (stateObjectType == StateObjectReplace) | 114 else if (stateObjectType == StateObjectReplace) |
121 m_frame->loader()->client()->dispatchDidReplaceStateWithinPage(); | 115 m_frame->loader()->client()->dispatchDidReplaceStateWithinPage(); |
122 } | 116 } |
123 | 117 |
124 } // namespace WebCore | 118 } // namespace WebCore |
OLD | NEW |