OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 { | 99 { |
100 INC_STATS("DOM.Location.host._set"); | 100 INC_STATS("DOM.Location.host._set"); |
101 v8::Handle<v8::Object> holder = info.Holder(); | 101 v8::Handle<v8::Object> holder = info.Holder(); |
102 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 102 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
103 String host = toWebCoreString(value); | 103 String host = toWebCoreString(value); |
104 | 104 |
105 Frame* frame = imp->frame(); | 105 Frame* frame = imp->frame(); |
106 if (!frame) | 106 if (!frame) |
107 return; | 107 return; |
108 | 108 |
109 KURL url = frame->loader()->url(); | 109 KURL url = frame->loader()->url(); |
110 String newHost = host.left(host.find(":")); | 110 String newHost = host.left(host.find(":")); |
111 String newPort = host.substring(host.find(":") + 1); | 111 String newPort = host.substring(host.find(":") + 1); |
112 url.setHost(newHost); | 112 url.setHost(newHost); |
113 url.setPort(newPort.toUInt()); | 113 url.setPort(newPort.toUInt()); |
114 | 114 |
115 navigateIfAllowed(frame, url, false, false); | 115 navigateIfAllowed(frame, url, false, false); |
116 } | 116 } |
117 | 117 |
118 ACCESSOR_SETTER(LocationHostname) | 118 ACCESSOR_SETTER(LocationHostname) |
119 { | 119 { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 { | 157 { |
158 INC_STATS("DOM.Location.pathname._set"); | 158 INC_STATS("DOM.Location.pathname._set"); |
159 v8::Handle<v8::Object> holder = info.Holder(); | 159 v8::Handle<v8::Object> holder = info.Holder(); |
160 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 160 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
161 String pathname = toWebCoreString(value); | 161 String pathname = toWebCoreString(value); |
162 | 162 |
163 Frame* frame = imp->frame(); | 163 Frame* frame = imp->frame(); |
164 if (!frame) | 164 if (!frame) |
165 return; | 165 return; |
166 | 166 |
167 KURL url = frame->loader()->url(); | 167 KURL url = frame->loader()->url(); |
168 url.setPath(pathname); | 168 url.setPath(pathname); |
169 | 169 |
170 navigateIfAllowed(frame, url, false, false); | 170 navigateIfAllowed(frame, url, false, false); |
171 } | 171 } |
172 | 172 |
173 ACCESSOR_SETTER(LocationPort) | 173 ACCESSOR_SETTER(LocationPort) |
174 { | 174 { |
175 INC_STATS("DOM.Location.port._set"); | 175 INC_STATS("DOM.Location.port._set"); |
176 v8::Handle<v8::Object> holder = info.Holder(); | 176 v8::Handle<v8::Object> holder = info.Holder(); |
177 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 177 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
178 String port = toWebCoreString(value); | 178 String port = toWebCoreString(value); |
179 | 179 |
180 Frame* frame = imp->frame(); | 180 Frame* frame = imp->frame(); |
181 if (!frame) | 181 if (!frame) |
182 return; | 182 return; |
183 | 183 |
184 KURL url = frame->loader()->url(); | 184 KURL url = frame->loader()->url(); |
185 url.setPort(port.toUInt()); | 185 url.setPort(port.toUInt()); |
186 | 186 |
187 navigateIfAllowed(frame, url, false, false); | 187 navigateIfAllowed(frame, url, false, false); |
188 } | 188 } |
189 | 189 |
190 ACCESSOR_SETTER(LocationProtocol) | 190 ACCESSOR_SETTER(LocationProtocol) |
191 { | 191 { |
192 INC_STATS("DOM.Location.protocol._set"); | 192 INC_STATS("DOM.Location.protocol._set"); |
193 v8::Handle<v8::Object> holder = info.Holder(); | 193 v8::Handle<v8::Object> holder = info.Holder(); |
194 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 194 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCA
TION, info.This()); | 228 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCA
TION, info.This()); |
229 if (holder.IsEmpty()) { | 229 if (holder.IsEmpty()) { |
230 // can only reach here by 'object.__proto__.func', and it should passed | 230 // can only reach here by 'object.__proto__.func', and it should passed |
231 // domain security check already | 231 // domain security check already |
232 return privateTemplate->GetFunction(); | 232 return privateTemplate->GetFunction(); |
233 } | 233 } |
234 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 234 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
235 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { | 235 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { |
236 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persist
ent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReloadCallbac
k, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); | 236 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persist
ent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReloadCallbac
k, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); |
237 return sharedTemplate->GetFunction(); | 237 return sharedTemplate->GetFunction(); |
238 } else { | 238 } else |
239 return privateTemplate->GetFunction(); | 239 return privateTemplate->GetFunction(); |
240 } | |
241 } | 240 } |
242 | 241 |
243 ACCESSOR_GETTER(LocationReplace) | 242 ACCESSOR_GETTER(LocationReplace) |
244 { | 243 { |
245 INC_STATS("DOM.Location.replace._get"); | 244 INC_STATS("DOM.Location.replace._get"); |
246 static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent
<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReplaceCallback,
v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); | 245 static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent
<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReplaceCallback,
v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); |
247 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCA
TION, info.This()); | 246 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCA
TION, info.This()); |
248 if (holder.IsEmpty()) { | 247 if (holder.IsEmpty()) { |
249 // can only reach here by 'object.__proto__.func', and it should passed | 248 // can only reach here by 'object.__proto__.func', and it should passed |
250 // domain security check already | 249 // domain security check already |
251 return privateTemplate->GetFunction(); | 250 return privateTemplate->GetFunction(); |
252 } | 251 } |
253 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 252 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
254 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { | 253 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { |
255 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persist
ent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReplaceCallba
ck, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); | 254 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persist
ent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationReplaceCallba
ck, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); |
256 return sharedTemplate->GetFunction(); | 255 return sharedTemplate->GetFunction(); |
257 } else { | 256 } else |
258 return privateTemplate->GetFunction(); | 257 return privateTemplate->GetFunction(); |
259 } | |
260 } | 258 } |
261 | 259 |
262 ACCESSOR_GETTER(LocationAssign) | 260 ACCESSOR_GETTER(LocationAssign) |
263 { | 261 { |
264 INC_STATS("DOM.Location.assign._get"); | 262 INC_STATS("DOM.Location.assign._get"); |
265 static v8::Persistent<v8::FunctionTemplate> privateTemplate = | 263 static v8::Persistent<v8::FunctionTemplate> privateTemplate = |
266 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8Locati
onAssignCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRaw
Template()))); | 264 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8Locati
onAssignCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRaw
Template()))); |
267 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCA
TION, info.This()); | 265 v8::Handle<v8::Object> holder = V8Proxy::LookupDOMWrapper(V8ClassIndex::LOCA
TION, info.This()); |
268 if (holder.IsEmpty()) { | 266 if (holder.IsEmpty()) { |
269 // can only reach here by 'object.__proto__.func', and it should passed | 267 // can only reach here by 'object.__proto__.func', and it should passed |
270 // domain security check already | 268 // domain security check already |
271 return privateTemplate->GetFunction(); | 269 return privateTemplate->GetFunction(); |
272 } | 270 } |
273 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 271 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
274 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { | 272 if (!V8Proxy::CanAccessFrame(imp->frame(), false)) { |
275 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persist
ent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationAssignCallbac
k, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); | 273 static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persist
ent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(v8LocationAssignCallbac
k, v8::Handle<v8::Value>(), v8::Signature::New(V8Location::GetRawTemplate()))); |
276 return sharedTemplate->GetFunction(); | 274 return sharedTemplate->GetFunction(); |
277 } else { | 275 } else |
278 return privateTemplate->GetFunction(); | 276 return privateTemplate->GetFunction(); |
279 } | |
280 } | 277 } |
281 | 278 |
282 CALLBACK_FUNC_DECL(LocationReload) | 279 CALLBACK_FUNC_DECL(LocationReload) |
283 { | 280 { |
284 // FIXME: we ignore the "forceget" parameter. | 281 // FIXME: we ignore the "forceget" parameter. |
285 | 282 |
286 INC_STATS("DOM.Location.reload"); | 283 INC_STATS("DOM.Location.reload"); |
287 v8::Handle<v8::Value> holder = args.Holder(); | 284 v8::Handle<v8::Value> holder = args.Holder(); |
288 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); | 285 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
lder); |
289 | 286 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 375 |
379 NAMED_ACCESS_CHECK(Location) | 376 NAMED_ACCESS_CHECK(Location) |
380 { | 377 { |
381 ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::LOCATION); | 378 ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::LOCATION); |
382 // Only allow same origin access | 379 // Only allow same origin access |
383 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
st); | 380 Location* imp = V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, ho
st); |
384 return V8Proxy::CanAccessFrame(imp->frame(), false); | 381 return V8Proxy::CanAccessFrame(imp->frame(), false); |
385 } | 382 } |
386 | 383 |
387 } // namespace WebCore | 384 } // namespace WebCore |
OLD | NEW |