OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Harri Porten (porten@kde.org) | 2 * Copyright (C) 2000 Harri Porten (porten@kde.org) |
3 * Copyright (C) 2006 Jon Shier (jshier@iastate.edu) | 3 * Copyright (C) 2006 Jon Shier (jshier@iastate.edu) |
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights resev
ed. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights resev
ed. |
5 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Frame* frame = impl()->frame(); | 147 Frame* frame = impl()->frame(); |
148 ASSERT(frame); | 148 ASSERT(frame); |
149 | 149 |
150 Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->fra
me(); | 150 Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->fra
me(); |
151 if (!activeFrame) | 151 if (!activeFrame) |
152 return; | 152 return; |
153 if (!activeFrame->loader()->shouldAllowNavigation(frame)) | 153 if (!activeFrame->loader()->shouldAllowNavigation(frame)) |
154 return; | 154 return; |
155 | 155 |
156 KURL url = activeFrame->loader()->completeURL(value.toString(exec)); | 156 KURL url = activeFrame->loader()->completeURL(value.toString(exec)); |
157 navigateIfAllowed(exec, frame, url, false, false); | 157 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
158 } | 158 } |
159 | 159 |
160 void JSLocation::setProtocol(ExecState* exec, JSValuePtr value) | 160 void JSLocation::setProtocol(ExecState* exec, JSValuePtr value) |
161 { | 161 { |
162 Frame* frame = impl()->frame(); | 162 Frame* frame = impl()->frame(); |
163 ASSERT(frame); | 163 ASSERT(frame); |
164 | 164 |
165 KURL url = frame->loader()->url(); | 165 KURL url = frame->loader()->url(); |
166 url.setProtocol(value.toString(exec)); | 166 url.setProtocol(value.toString(exec)); |
167 | 167 |
168 navigateIfAllowed(exec, frame, url, false, false); | 168 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
169 } | 169 } |
170 | 170 |
171 void JSLocation::setHost(ExecState* exec, JSValuePtr value) | 171 void JSLocation::setHost(ExecState* exec, JSValuePtr value) |
172 { | 172 { |
173 Frame* frame = impl()->frame(); | 173 Frame* frame = impl()->frame(); |
174 ASSERT(frame); | 174 ASSERT(frame); |
175 | 175 |
176 KURL url = frame->loader()->url(); | 176 KURL url = frame->loader()->url(); |
177 url.setHostAndPort(value.toString(exec)); | 177 url.setHostAndPort(value.toString(exec)); |
178 | 178 |
179 navigateIfAllowed(exec, frame, url, false, false); | 179 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
180 } | 180 } |
181 | 181 |
182 void JSLocation::setHostname(ExecState* exec, JSValuePtr value) | 182 void JSLocation::setHostname(ExecState* exec, JSValuePtr value) |
183 { | 183 { |
184 Frame* frame = impl()->frame(); | 184 Frame* frame = impl()->frame(); |
185 ASSERT(frame); | 185 ASSERT(frame); |
186 | 186 |
187 KURL url = frame->loader()->url(); | 187 KURL url = frame->loader()->url(); |
188 url.setHost(value.toString(exec)); | 188 url.setHost(value.toString(exec)); |
189 | 189 |
190 navigateIfAllowed(exec, frame, url, false, false); | 190 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
191 } | 191 } |
192 | 192 |
193 void JSLocation::setPort(ExecState* exec, JSValuePtr value) | 193 void JSLocation::setPort(ExecState* exec, JSValuePtr value) |
194 { | 194 { |
195 Frame* frame = impl()->frame(); | 195 Frame* frame = impl()->frame(); |
196 ASSERT(frame); | 196 ASSERT(frame); |
197 | 197 |
198 KURL url = frame->loader()->url(); | 198 KURL url = frame->loader()->url(); |
199 // FIXME: Could make this a little less ugly if String provided a toUnsigned
Short function. | 199 // FIXME: Could make this a little less ugly if String provided a toUnsigned
Short function. |
200 const UString& portString = value.toString(exec); | 200 const UString& portString = value.toString(exec); |
201 int port = charactersToInt(portString.data(), portString.size()); | 201 int port = charactersToInt(portString.data(), portString.size()); |
202 if (port < 0 || port > 0xFFFF) | 202 if (port < 0 || port > 0xFFFF) |
203 port = 0; | 203 port = 0; |
204 url.setPort(port); | 204 url.setPort(port); |
205 | 205 |
206 navigateIfAllowed(exec, frame, url, false, false); | 206 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
207 } | 207 } |
208 | 208 |
209 void JSLocation::setPathname(ExecState* exec, JSValuePtr value) | 209 void JSLocation::setPathname(ExecState* exec, JSValuePtr value) |
210 { | 210 { |
211 Frame* frame = impl()->frame(); | 211 Frame* frame = impl()->frame(); |
212 ASSERT(frame); | 212 ASSERT(frame); |
213 | 213 |
214 KURL url = frame->loader()->url(); | 214 KURL url = frame->loader()->url(); |
215 url.setPath(value.toString(exec)); | 215 url.setPath(value.toString(exec)); |
216 | 216 |
217 navigateIfAllowed(exec, frame, url, false, false); | 217 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
218 } | 218 } |
219 | 219 |
220 void JSLocation::setSearch(ExecState* exec, JSValuePtr value) | 220 void JSLocation::setSearch(ExecState* exec, JSValuePtr value) |
221 { | 221 { |
222 Frame* frame = impl()->frame(); | 222 Frame* frame = impl()->frame(); |
223 ASSERT(frame); | 223 ASSERT(frame); |
224 | 224 |
225 KURL url = frame->loader()->url(); | 225 KURL url = frame->loader()->url(); |
226 url.setQuery(value.toString(exec)); | 226 url.setQuery(value.toString(exec)); |
227 | 227 |
228 navigateIfAllowed(exec, frame, url, false, false); | 228 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
229 } | 229 } |
230 | 230 |
231 void JSLocation::setHash(ExecState* exec, JSValuePtr value) | 231 void JSLocation::setHash(ExecState* exec, JSValuePtr value) |
232 { | 232 { |
233 Frame* frame = impl()->frame(); | 233 Frame* frame = impl()->frame(); |
234 ASSERT(frame); | 234 ASSERT(frame); |
235 | 235 |
236 KURL url = frame->loader()->url(); | 236 KURL url = frame->loader()->url(); |
237 String oldRef = url.ref(); | 237 String oldRef = url.ref(); |
238 String str = value.toString(exec); | 238 String str = value.toString(exec); |
239 if (str.startsWith("#")) | 239 if (str.startsWith("#")) |
240 str = str.substring(1); | 240 str = str.substring(1); |
241 if (oldRef == str || (oldRef.isNull() && str.isEmpty())) | 241 if (oldRef == str || (oldRef.isNull() && str.isEmpty())) |
242 return; | 242 return; |
243 url.setRef(str); | 243 url.setRef(str); |
244 | 244 |
245 navigateIfAllowed(exec, frame, url, false, false); | 245 navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUse
rGesture(), false); |
246 } | 246 } |
247 | 247 |
248 JSValuePtr JSLocation::replace(ExecState* exec, const ArgList& args) | 248 JSValuePtr JSLocation::replace(ExecState* exec, const ArgList& args) |
249 { | 249 { |
250 Frame* frame = impl()->frame(); | 250 Frame* frame = impl()->frame(); |
251 if (!frame) | 251 if (!frame) |
252 return jsUndefined(); | 252 return jsUndefined(); |
253 | 253 |
254 Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->fra
me(); | 254 Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->fra
me(); |
255 if (!activeFrame) | 255 if (!activeFrame) |
(...skipping 28 matching lines...) Expand all Loading... |
284 if (!frame) | 284 if (!frame) |
285 return jsUndefined(); | 285 return jsUndefined(); |
286 | 286 |
287 Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->fra
me(); | 287 Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->fra
me(); |
288 if (!activeFrame) | 288 if (!activeFrame) |
289 return jsUndefined(); | 289 return jsUndefined(); |
290 if (!activeFrame->loader()->shouldAllowNavigation(frame)) | 290 if (!activeFrame->loader()->shouldAllowNavigation(frame)) |
291 return jsUndefined(); | 291 return jsUndefined(); |
292 | 292 |
293 // We want a new history item if this JS was called via a user gesture | 293 // We want a new history item if this JS was called via a user gesture |
294 navigateIfAllowed(exec, frame, activeFrame->loader()->completeURL(args.at(ex
ec, 0).toString(exec)), false, false); | 294 navigateIfAllowed(exec, frame, activeFrame->loader()->completeURL(args.at(ex
ec, 0).toString(exec)), !frame->script()->anyPageIsProcessingUserGesture(), fals
e); |
295 return jsUndefined(); | 295 return jsUndefined(); |
296 } | 296 } |
297 | 297 |
298 JSValuePtr JSLocation::toString(ExecState* exec, const ArgList&) | 298 JSValuePtr JSLocation::toString(ExecState* exec, const ArgList&) |
299 { | 299 { |
300 Frame* frame = impl()->frame(); | 300 Frame* frame = impl()->frame(); |
301 if (!frame) | 301 if (!frame) |
302 return jsUndefined(); | 302 return jsUndefined(); |
303 if (!allowsAccessFromFrame(exec, frame)) | 303 if (!allowsAccessFromFrame(exec, frame)) |
304 return jsUndefined(); | 304 return jsUndefined(); |
305 | 305 |
306 return jsString(exec, impl()->toString()); | 306 return jsString(exec, impl()->toString()); |
307 } | 307 } |
308 | 308 |
309 } // namespace WebCore | 309 } // namespace WebCore |
OLD | NEW |