Commit afb34a67 authored by mbelshe@google.com's avatar mbelshe@google.com

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
parent 5fa72daa
......@@ -19,7 +19,7 @@ deps = {
"http://googletest.googlecode.com/svn/trunk@167",
"src/third_party/WebKit":
"/trunk/deps/third_party/WebKit@10527",
"/trunk/deps/third_party/WebKit@10557",
"src/third_party/icu38":
"/trunk/deps/third_party/icu38@10364",
......
......@@ -360,6 +360,7 @@ inputs = [
'$WEBCORE_DIR/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8HTMLSelectElementCustom.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8HTMLSelectElementCustom.h',
'$WEBCORE_DIR/bindings/v8/custom/V8LocationCustom.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8NamedNodesCollection.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8NamedNodesCollection.h',
'$WEBCORE_DIR/bindings/v8/custom/V8SVGElementInstanceCustom.cpp',
......
......@@ -167,6 +167,10 @@
RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLSelectElementCustom.h"
>
</File>
<File
RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8LocationCustom.cpp"
>
</File>
<File
RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodesCollection.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
......
......@@ -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
......
......@@ -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: {
......
......@@ -1373,6 +1373,7 @@
E4A238C70E3FA19C002BDE14 /* image_decoder.cc in Sources */ = {isa = PBXBuildFile; fileRef = E4A238C50E3FA19C002BDE14 /* image_decoder.cc */; };
E4E4C94A0E797648009A687C /* ImageSourceCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E8FBD0D7F3CC1001ECF42 /* ImageSourceCG.cpp */; };
E7CC722700DA5F7E55527582 /* resource_loader_bridge.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5D2A55FF5C399F9800256956 /* resource_loader_bridge.cc */; };
E8AC24D9A18D0246326D9842 /* V8LocationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7F1694059937550AA36C00F /* V8LocationCustom.cpp */; };
FBBBF2E4099C8EA9BDAF80F9 /* CurrentTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCBDDEF91A55ACE86471036E /* CurrentTime.cpp */; };
/* End PBXBuildFile section */
......@@ -4477,6 +4478,7 @@
E48A06D90E3F840F00172919 /* image_resource_fetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = image_resource_fetcher.h; sourceTree = "<group>"; };
E4A238C50E3FA19C002BDE14 /* image_decoder.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = image_decoder.cc; sourceTree = "<group>"; };
E4A238C60E3FA19C002BDE14 /* image_decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = image_decoder.h; sourceTree = "<group>"; };
F7F1694059937550AA36C00F /* V8LocationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = V8LocationCustom.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -4625,6 +4627,7 @@
41DE7B6B0F40EA5F0049BC24 /* V8HTMLOptionsCollectionCustom.cpp */,
41DE7CA40F424BEE0049BC24 /* V8HTMLSelectElementCustom.h */,
41DE7C9F0F424AE80049BC24 /* V8HTMLSelectElementCustom.cpp */,
F7F1694059937550AA36C00F /* V8LocationCustom.cpp */,
41DE7CA20F424B020049BC24 /* V8NamedNodesCollection.cpp */,
41DE7CA10F424B020049BC24 /* V8NamedNodesCollection.h */,
41DE74890F3CDBCB0049BC24 /* V8SVGElementInstanceCustom.cpp */,
......@@ -9812,6 +9815,7 @@
453FFDF935221CD484A3AFED /* Interval.cpp in Sources */,
3C9197C6A7DABB989CBDBF81 /* Playback.cpp in Sources */,
E40060DB0EA69E0B0055B38E /* ScriptController.cpp in Sources */,
E8AC24D9A18D0246326D9842 /* V8LocationCustom.cpp in Sources */,
4DB7F55D0E9BD66300C66CE0 /* V8XMLHttpRequestCustom.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment