diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 01:26:30 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 01:26:30 +0000 |
commit | afb34a6728f77a5e4b53e175a93791689535b3d2 (patch) | |
tree | 22518d57a1b4e8c48227bbb030fee3fa7d0835d4 /webkit/port | |
parent | 5fa72daa2d26daef980cfe16ba9f2440d7c0fd4a (diff) | |
download | chromium_src-afb34a6728f77a5e4b53e175a93791689535b3d2.zip chromium_src-afb34a6728f77a5e4b53e175a93791689535b3d2.tar.gz chromium_src-afb34a6728f77a5e4b53e175a93791689535b3d2.tar.bz2 |
Part of unforking Location. We make a bunch of Location related
APIs custom.
Review URL: http://codereview.chromium.org/27224
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r-- | webkit/port/bindings/v8/v8_custom.cpp | 26 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_custom.h | 15 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_proxy.cpp | 27 |
3 files changed, 42 insertions, 26 deletions
diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp index 86c2c01..6d05406 100644 --- a/webkit/port/bindings/v8/v8_custom.cpp +++ b/webkit/port/bindings/v8/v8_custom.cpp @@ -1639,16 +1639,7 @@ CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) { return V8Proxy::NodeToV8Object(result.get()); } -// Location -------------------------------------------------------------------- -CALLBACK_FUNC_DECL(LocationValueOf) { - // Just return the this object the way the normal valueOf function - // on the Object prototype would. The valueOf function is only - // added to make sure that it cannot be overwritten on location - // objects, since that would provide a hook to change the string - // conversion behavior of location objects. - return args.This(); -} // Attr ------------------------------------------------------------------------ @@ -2388,23 +2379,6 @@ NAMED_ACCESS_CHECK(History) { } -INDEXED_ACCESS_CHECK(Location) { - ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::LOCATION); - // Only allow same origin access - Location* imp = - V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host); - return V8Proxy::CanAccessFrame(imp->frame(), false); -} - - -NAMED_ACCESS_CHECK(Location) { - ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::LOCATION); - // Only allow same origin access - Location* imp = - V8Proxy::ToNativeObject<Location>(V8ClassIndex::LOCATION, host); - return V8Proxy::CanAccessFrame(imp->frame(), false); -} - #undef INDEXED_ACCESS_CHECK #undef NAMED_ACCESS_CHECK diff --git a/webkit/port/bindings/v8/v8_custom.h b/webkit/port/bindings/v8/v8_custom.h index a93c649..5ec3e98 100644 --- a/webkit/port/bindings/v8/v8_custom.h +++ b/webkit/port/bindings/v8/v8_custom.h @@ -338,6 +338,21 @@ DECLARE_CALLBACK(ElementSetAttributeNS) DECLARE_CALLBACK(ElementSetAttributeNodeNS) // Implementation of custom Location methods. +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationProtocol) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHost) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHostname) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationPort) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationPathname) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationSearch) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHash) +DECLARE_PROPERTY_ACCESSOR_SETTER(LocationHref) +DECLARE_PROPERTY_ACCESSOR_GETTER(LocationAssign) +DECLARE_PROPERTY_ACCESSOR_GETTER(LocationReplace) +DECLARE_PROPERTY_ACCESSOR_GETTER(LocationReload) +DECLARE_CALLBACK(LocationAssign) +DECLARE_CALLBACK(LocationReplace) +DECLARE_CALLBACK(LocationReload) +DECLARE_CALLBACK(LocationToString) DECLARE_CALLBACK(LocationValueOf) // Implementation of EventTarget::addEventListener diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp index 18101d6..010b2a6d 100644 --- a/webkit/port/bindings/v8/v8_proxy.cpp +++ b/webkit/port/bindings/v8/v8_proxy.cpp @@ -1760,6 +1760,33 @@ v8::Persistent<v8::FunctionTemplate> V8Proxy::GetTemplate( break; } case V8ClassIndex::LOCATION: { + // For security reasons, these functions are on the instance + // instead of on the prototype object to insure that they cannot + // be overwritten. + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); + instance->SetAccessor( + v8::String::New("reload"), + V8Custom::v8LocationReloadAccessorGetter, + 0, + v8::Handle<v8::Value>(), + v8::ALL_CAN_READ, + static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::ReadOnly)); + + instance->SetAccessor( + v8::String::New("replace"), + V8Custom::v8LocationReplaceAccessorGetter, + 0, + v8::Handle<v8::Value>(), + v8::ALL_CAN_READ, + static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::ReadOnly)); + + instance->SetAccessor( + v8::String::New("assign"), + V8Custom::v8LocationAssignAccessorGetter, + 0, + v8::Handle<v8::Value>(), + v8::ALL_CAN_READ, + static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::ReadOnly)); break; } case V8ClassIndex::HISTORY: { |