Add PPB_URLUtil_Dev::GetDocumentURL
This also renames "Url" into "URL" for consistency. BUG=74569 TEST=http://www.espn.go.com/nba/ Review URL: http://codereview.chromium.org/6594107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76608 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/test/ui
ppapi
webkit/plugins/ppapi
@ -142,8 +142,8 @@ TEST_F(PPAPITest, FLAKY_Scrollbar) {
|
||||
RunTest("Scrollbar");
|
||||
}
|
||||
|
||||
TEST_F(PPAPITest, UrlUtil) {
|
||||
RunTest("UrlUtil");
|
||||
TEST_F(PPAPITest, URLUtil) {
|
||||
RunTest("URLUtil");
|
||||
}
|
||||
|
||||
TEST_F(PPAPITest, CharSet) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
@ -11,7 +11,7 @@
|
||||
#include "ppapi/c/pp_stdint.h"
|
||||
#include "ppapi/c/pp_var.h"
|
||||
|
||||
#define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.4"
|
||||
#define PPB_URLUTIL_DEV_INTERFACE "PPB_URLUtil(Dev);0.5"
|
||||
|
||||
// A component specifies the range of the part of the URL. The begin specifies
|
||||
// the index into the string of the first character of that component. The len
|
||||
@ -29,30 +29,30 @@
|
||||
// If the component is present but empty, the length will be 0 instead. Example:
|
||||
// http://foo/search -> query = (0, -1)
|
||||
// http://foo/search? -> query = (18, 0)
|
||||
struct PP_UrlComponent_Dev {
|
||||
struct PP_URLComponent_Dev {
|
||||
int32_t begin;
|
||||
int32_t len;
|
||||
};
|
||||
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_UrlComponent_Dev, 8);
|
||||
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponent_Dev, 8);
|
||||
|
||||
struct PP_UrlComponents_Dev {
|
||||
struct PP_UrlComponent_Dev scheme;
|
||||
struct PP_UrlComponent_Dev username;
|
||||
struct PP_UrlComponent_Dev password;
|
||||
struct PP_UrlComponent_Dev host;
|
||||
struct PP_UrlComponent_Dev port;
|
||||
struct PP_UrlComponent_Dev path;
|
||||
struct PP_UrlComponent_Dev query;
|
||||
struct PP_UrlComponent_Dev ref;
|
||||
struct PP_URLComponents_Dev {
|
||||
struct PP_URLComponent_Dev scheme;
|
||||
struct PP_URLComponent_Dev username;
|
||||
struct PP_URLComponent_Dev password;
|
||||
struct PP_URLComponent_Dev host;
|
||||
struct PP_URLComponent_Dev port;
|
||||
struct PP_URLComponent_Dev path;
|
||||
struct PP_URLComponent_Dev query;
|
||||
struct PP_URLComponent_Dev ref;
|
||||
};
|
||||
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_UrlComponents_Dev, 64);
|
||||
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponents_Dev, 64);
|
||||
|
||||
// URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit
|
||||
// strings. You can pass non-ASCII characters which will be interpreted as
|
||||
// UTF-8. Canonicalized URL strings returned by these functions will be ASCII
|
||||
// except for the reference fragment (stuff after the '#') which will be
|
||||
// encoded as UTF-8.
|
||||
struct PPB_UrlUtil_Dev {
|
||||
struct PPB_URLUtil_Dev {
|
||||
// Canonicalizes the given URL string according to the rules of the host
|
||||
// browser. If the URL is invalid or the var is not a string, this will
|
||||
// return a Null var and the components structure will be unchanged.
|
||||
@ -61,14 +61,14 @@ struct PPB_UrlUtil_Dev {
|
||||
// will identify the components of the resulting URL. Components may be NULL
|
||||
// to specify that no component information is necessary.
|
||||
struct PP_Var (*Canonicalize)(struct PP_Var url,
|
||||
struct PP_UrlComponents_Dev* components);
|
||||
struct PP_URLComponents_Dev* components);
|
||||
|
||||
// Resolves the given URL relative to the given base URL. The resulting URL
|
||||
// is returned as a string. If the resolution is invalid or either of the
|
||||
// inputs are not strings, a Null var will be returned. The resulting URL
|
||||
// will also be canonicalized according to the rules of the browser.
|
||||
//
|
||||
// Note that the "relative" URL bay in fact be absolute, in which case it
|
||||
// Note that the "relative" URL may in fact be absolute, in which case it
|
||||
// will be returned. This function is identical to resolving the full URL
|
||||
// for an <a href="..."> on a web page. Attempting to resolve a relative URL
|
||||
// on a base URL that doesn't support this (e.g. "data") will fail and will
|
||||
@ -77,12 +77,12 @@ struct PPB_UrlUtil_Dev {
|
||||
// The components pointer, if non-NULL and the canonicalized URL is valid,
|
||||
// will identify the components of the resulting URL. Components may be NULL
|
||||
// to specify that no component information is necessary.
|
||||
struct PP_Var (*ResolveRelativeToUrl)(
|
||||
struct PP_Var (*ResolveRelativeToURL)(
|
||||
struct PP_Var base_url,
|
||||
struct PP_Var relative_string,
|
||||
struct PP_UrlComponents_Dev* components);
|
||||
struct PP_URLComponents_Dev* components);
|
||||
|
||||
// Identical to ResolveRelativeToUrl except that the base URL is the base
|
||||
// Identical to ResolveRelativeToURL except that the base URL is the base
|
||||
// URL of the document containing the given plugin instance.
|
||||
//
|
||||
// Danger: This will be identical to resolving a relative URL on the page,
|
||||
@ -92,7 +92,7 @@ struct PPB_UrlUtil_Dev {
|
||||
struct PP_Var (*ResolveRelativeToDocument)(
|
||||
PP_Instance instance,
|
||||
struct PP_Var relative_string,
|
||||
struct PP_UrlComponents_Dev* components);
|
||||
struct PP_URLComponents_Dev* components);
|
||||
|
||||
// Checks whether the given two URLs are in the same security origin. Returns
|
||||
// FALSE if either of the URLs are invalid.
|
||||
@ -109,6 +109,14 @@ struct PPB_UrlUtil_Dev {
|
||||
// and any cross-origin capabilities enabled by the document. If either of
|
||||
// the plugin instances are invalid, returns PP_FALSE.
|
||||
PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target);
|
||||
|
||||
// Returns the URL for the document. This is a safe way to retrieve
|
||||
// window.location.href.
|
||||
// The components pointer, if non-NULL and the canonicalized URL is valid,
|
||||
// will identify the components of the resulting URL. Components may be NULL
|
||||
// to specify that no component information is necessary.
|
||||
struct PP_Var (*GetDocumentURL)(PP_Instance instance,
|
||||
struct PP_URLComponents_Dev* components);
|
||||
};
|
||||
|
||||
#endif /* PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
namespace pp {
|
||||
|
||||
// static
|
||||
const UrlUtil_Dev* UrlUtil_Dev::Get() {
|
||||
const URLUtil_Dev* URLUtil_Dev::Get() {
|
||||
static bool tried_to_init = false;
|
||||
static UrlUtil_Dev util;
|
||||
static URLUtil_Dev util;
|
||||
|
||||
if (!tried_to_init) {
|
||||
tried_to_init = true;
|
||||
util.interface_ = static_cast<const PPB_UrlUtil_Dev*>(
|
||||
util.interface_ = static_cast<const PPB_URLUtil_Dev*>(
|
||||
Module::Get()->GetBrowserInterface(PPB_URLUTIL_DEV_INTERFACE));
|
||||
}
|
||||
|
||||
@ -26,48 +26,54 @@ const UrlUtil_Dev* UrlUtil_Dev::Get() {
|
||||
return &util;
|
||||
}
|
||||
|
||||
Var UrlUtil_Dev::Canonicalize(const Var& url,
|
||||
PP_UrlComponents_Dev* components) const {
|
||||
Var URLUtil_Dev::Canonicalize(const Var& url,
|
||||
PP_URLComponents_Dev* components) const {
|
||||
return Var(Var::PassRef(),
|
||||
interface_->Canonicalize(url.pp_var(), components));
|
||||
}
|
||||
|
||||
Var UrlUtil_Dev::ResolveRelativeToUrl(const Var& base_url,
|
||||
Var URLUtil_Dev::ResolveRelativeToURL(const Var& base_url,
|
||||
const Var& relative_string,
|
||||
PP_UrlComponents_Dev* components) const {
|
||||
PP_URLComponents_Dev* components) const {
|
||||
return Var(Var::PassRef(),
|
||||
interface_->ResolveRelativeToUrl(base_url.pp_var(),
|
||||
interface_->ResolveRelativeToURL(base_url.pp_var(),
|
||||
relative_string.pp_var(),
|
||||
components));
|
||||
}
|
||||
|
||||
Var UrlUtil_Dev::ResoveRelativeToDocument(
|
||||
Var URLUtil_Dev::ResoveRelativeToDocument(
|
||||
const Instance& instance,
|
||||
const Var& relative_string,
|
||||
PP_UrlComponents_Dev* components) const {
|
||||
PP_URLComponents_Dev* components) const {
|
||||
return Var(Var::PassRef(),
|
||||
interface_->ResolveRelativeToDocument(instance.pp_instance(),
|
||||
relative_string.pp_var(),
|
||||
components));
|
||||
}
|
||||
|
||||
bool UrlUtil_Dev::IsSameSecurityOrigin(const Var& url_a,
|
||||
bool URLUtil_Dev::IsSameSecurityOrigin(const Var& url_a,
|
||||
const Var& url_b) const {
|
||||
return PPBoolToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(),
|
||||
url_b.pp_var()));
|
||||
}
|
||||
|
||||
bool UrlUtil_Dev::DocumentCanRequest(const Instance& instance,
|
||||
bool URLUtil_Dev::DocumentCanRequest(const Instance& instance,
|
||||
const Var& url) const {
|
||||
return PPBoolToBool(interface_->DocumentCanRequest(instance.pp_instance(),
|
||||
url.pp_var()));
|
||||
}
|
||||
|
||||
bool UrlUtil_Dev::DocumentCanAccessDocument(const Instance& active,
|
||||
bool URLUtil_Dev::DocumentCanAccessDocument(const Instance& active,
|
||||
const Instance& target) const {
|
||||
return PPBoolToBool(
|
||||
interface_->DocumentCanAccessDocument(active.pp_instance(),
|
||||
target.pp_instance()));
|
||||
}
|
||||
|
||||
Var URLUtil_Dev::GetDocumentURL(const Instance& instance,
|
||||
PP_URLComponents_Dev* components) const {
|
||||
return Var(Var::PassRef(),
|
||||
interface_->GetDocumentURL(instance.pp_instance(), components));
|
||||
}
|
||||
|
||||
} // namespace pp
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@ -13,39 +13,41 @@ namespace pp {
|
||||
class Instance;
|
||||
class Module;
|
||||
|
||||
// Simple wrapper around the PPB_UrlUtil interface.
|
||||
class UrlUtil_Dev {
|
||||
// Simple wrapper around the PPB_URLUtil interface.
|
||||
class URLUtil_Dev {
|
||||
public:
|
||||
// This class is just a collection of random functions that aren't
|
||||
// particularly attached to anything. So this getter returns a cached
|
||||
// instance of this interface. This may return NULL if the browser doesn't
|
||||
// support the UrlUtil inteface. Since this is a singleton, don't delete the
|
||||
// support the URLUtil inteface. Since this is a singleton, don't delete the
|
||||
// pointer.
|
||||
static const UrlUtil_Dev* Get();
|
||||
static const URLUtil_Dev* Get();
|
||||
|
||||
Var Canonicalize(const Var& url,
|
||||
PP_UrlComponents_Dev* components = NULL) const;
|
||||
PP_URLComponents_Dev* components = NULL) const;
|
||||
|
||||
Var ResolveRelativeToUrl(const Var& base_url,
|
||||
Var ResolveRelativeToURL(const Var& base_url,
|
||||
const Var& relative_string,
|
||||
PP_UrlComponents_Dev* components = NULL) const;
|
||||
PP_URLComponents_Dev* components = NULL) const;
|
||||
Var ResoveRelativeToDocument(const Instance& instance,
|
||||
const Var& relative_string,
|
||||
PP_UrlComponents_Dev* components = NULL) const;
|
||||
PP_URLComponents_Dev* components = NULL) const;
|
||||
|
||||
bool IsSameSecurityOrigin(const Var& url_a, const Var& url_b) const;
|
||||
bool DocumentCanRequest(const Instance& instance, const Var& url) const;
|
||||
bool DocumentCanAccessDocument(const Instance& active,
|
||||
const Instance& target) const;
|
||||
Var GetDocumentURL(const Instance& instance,
|
||||
PP_URLComponents_Dev* components = NULL) const;
|
||||
|
||||
private:
|
||||
UrlUtil_Dev() : interface_(NULL) {}
|
||||
URLUtil_Dev() : interface_(NULL) {}
|
||||
|
||||
// Copy and assignment are disallowed.
|
||||
UrlUtil_Dev(const UrlUtil_Dev& other);
|
||||
UrlUtil_Dev& operator=(const UrlUtil_Dev& other);
|
||||
URLUtil_Dev(const URLUtil_Dev& other);
|
||||
URLUtil_Dev& operator=(const URLUtil_Dev& other);
|
||||
|
||||
const PPB_UrlUtil_Dev* interface_;
|
||||
const PPB_URLUtil_Dev* interface_;
|
||||
};
|
||||
|
||||
} // namespace pp
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@ -8,33 +8,34 @@
|
||||
#include "ppapi/cpp/dev/url_util_dev.h"
|
||||
#include "ppapi/tests/testing_instance.h"
|
||||
|
||||
REGISTER_TEST_CASE(UrlUtil);
|
||||
REGISTER_TEST_CASE(URLUtil);
|
||||
|
||||
static bool ComponentEquals(const PP_UrlComponent_Dev& component,
|
||||
static bool ComponentEquals(const PP_URLComponent_Dev& component,
|
||||
int begin, int len) {
|
||||
return component.begin == begin && component.len == len;
|
||||
}
|
||||
|
||||
bool TestUrlUtil::Init() {
|
||||
util_ = pp::UrlUtil_Dev::Get();
|
||||
bool TestURLUtil::Init() {
|
||||
util_ = pp::URLUtil_Dev::Get();
|
||||
return !!util_;
|
||||
}
|
||||
|
||||
void TestUrlUtil::RunTest() {
|
||||
void TestURLUtil::RunTest() {
|
||||
RUN_TEST(Canonicalize);
|
||||
RUN_TEST(ResolveRelative);
|
||||
RUN_TEST(IsSameSecurityOrigin);
|
||||
RUN_TEST(DocumentCanRequest);
|
||||
RUN_TEST(DocumentCanAccessDocument);
|
||||
RUN_TEST(GetDocumentURL);
|
||||
}
|
||||
|
||||
std::string TestUrlUtil::TestCanonicalize() {
|
||||
std::string TestURLUtil::TestCanonicalize() {
|
||||
// Test no canonicalize output.
|
||||
pp::Var result = util_->Canonicalize("http://Google.com");
|
||||
ASSERT_TRUE(result.AsString() == "http://google.com/");
|
||||
|
||||
// Test all the components
|
||||
PP_UrlComponents_Dev c;
|
||||
PP_URLComponents_Dev c;
|
||||
result = util_->Canonicalize(
|
||||
"http://me:pw@Google.com:1234/path?query#ref ",
|
||||
&c);
|
||||
@ -68,7 +69,7 @@ std::string TestUrlUtil::TestCanonicalize() {
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestUrlUtil::TestResolveRelative() {
|
||||
std::string TestURLUtil::TestResolveRelative() {
|
||||
const int kTestCount = 6;
|
||||
struct TestCase {
|
||||
const char* base;
|
||||
@ -84,7 +85,7 @@ std::string TestUrlUtil::TestResolveRelative() {
|
||||
};
|
||||
|
||||
for (int i = 0; i < kTestCount; i++) {
|
||||
pp::Var result = util_->ResolveRelativeToUrl(test_cases[i].base,
|
||||
pp::Var result = util_->ResolveRelativeToURL(test_cases[i].base,
|
||||
test_cases[i].relative);
|
||||
if (test_cases[i].expected == NULL) {
|
||||
ASSERT_TRUE(result.is_null());
|
||||
@ -95,7 +96,7 @@ std::string TestUrlUtil::TestResolveRelative() {
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestUrlUtil::TestIsSameSecurityOrigin() {
|
||||
std::string TestURLUtil::TestIsSameSecurityOrigin() {
|
||||
ASSERT_FALSE(util_->IsSameSecurityOrigin("http://google.com/",
|
||||
"http://example.com/"));
|
||||
ASSERT_TRUE(util_->IsSameSecurityOrigin("http://google.com/foo",
|
||||
@ -103,15 +104,26 @@ std::string TestUrlUtil::TestIsSameSecurityOrigin() {
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestUrlUtil::TestDocumentCanRequest() {
|
||||
std::string TestURLUtil::TestDocumentCanRequest() {
|
||||
// This is hard to test, but we can at least verify we can't request
|
||||
// some random domain.
|
||||
ASSERT_FALSE(util_->DocumentCanRequest(*instance_, "http://evil.com/"));
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestUrlUtil::TestDocumentCanAccessDocument() {
|
||||
std::string TestURLUtil::TestDocumentCanAccessDocument() {
|
||||
// This is hard to test, but we can at least verify we can access ourselves.
|
||||
ASSERT_TRUE(util_->DocumentCanAccessDocument(*instance_, *instance_));
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestURLUtil::TestGetDocumentURL() {
|
||||
pp::Var url = util_->GetDocumentURL(*instance_);
|
||||
ASSERT_TRUE(url.is_string());
|
||||
pp::Var window = instance_->GetWindowObject();
|
||||
pp::Var href = window.GetProperty("location").GetProperty("href");
|
||||
ASSERT_TRUE(href.is_string());
|
||||
// In the test framework, they should be the same.
|
||||
ASSERT_EQ(url.AsString(), href.AsString());
|
||||
PASS();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
#include "ppapi/cpp/dev/url_util_dev.h"
|
||||
#include "ppapi/tests/test_case.h"
|
||||
|
||||
class TestUrlUtil : public TestCase {
|
||||
class TestURLUtil : public TestCase {
|
||||
public:
|
||||
TestUrlUtil(TestingInstance* instance) : TestCase(instance), util_(NULL) {}
|
||||
TestURLUtil(TestingInstance* instance) : TestCase(instance), util_(NULL) {}
|
||||
|
||||
// TestCase implementation.
|
||||
virtual bool Init();
|
||||
@ -22,8 +22,9 @@ class TestUrlUtil : public TestCase {
|
||||
std::string TestIsSameSecurityOrigin();
|
||||
std::string TestDocumentCanRequest();
|
||||
std::string TestDocumentCanAccessDocument();
|
||||
std::string TestGetDocumentURL();
|
||||
|
||||
const pp::UrlUtil_Dev* util_;
|
||||
const pp::URLUtil_Dev* util_;
|
||||
};
|
||||
|
||||
#endif // PPAPI_TESTS_TEST_URL_UTIL_H_
|
||||
|
@ -285,7 +285,7 @@ const void* GetInterface(const char* name) {
|
||||
if (strcmp(name, PPB_URLRESPONSEINFO_INTERFACE) == 0)
|
||||
return PPB_URLResponseInfo_Impl::GetInterface();
|
||||
if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0)
|
||||
return PPB_UrlUtil_Impl::GetInterface();
|
||||
return PPB_URLUtil_Impl::GetInterface();
|
||||
if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0)
|
||||
return Var::GetDeprecatedInterface();
|
||||
if (strcmp(name, PPB_VAR_INTERFACE) == 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
@ -25,7 +25,7 @@ namespace ppapi {
|
||||
namespace {
|
||||
|
||||
void ConvertComponent(const url_parse::Component& input,
|
||||
PP_UrlComponent_Dev* output) {
|
||||
PP_URLComponent_Dev* output) {
|
||||
output->begin = input.begin;
|
||||
output->len = input.len;
|
||||
}
|
||||
@ -33,7 +33,7 @@ void ConvertComponent(const url_parse::Component& input,
|
||||
// Output can be NULL to specify "do nothing." This rule is followed by all the
|
||||
// url util functions, so we implement it once here.
|
||||
void ConvertComponents(const url_parse::Parsed& input,
|
||||
PP_UrlComponents_Dev* output) {
|
||||
PP_URLComponents_Dev* output) {
|
||||
if (!output)
|
||||
return;
|
||||
|
||||
@ -49,8 +49,8 @@ void ConvertComponents(const url_parse::Parsed& input,
|
||||
|
||||
// Used for returning the given GURL from a PPAPI function, with an optional
|
||||
// out param indicating the components.
|
||||
PP_Var GenerateUrlReturn(PluginModule* module, const GURL& url,
|
||||
PP_UrlComponents_Dev* components) {
|
||||
PP_Var GenerateURLReturn(PluginModule* module, const GURL& url,
|
||||
PP_URLComponents_Dev* components) {
|
||||
if (!url.is_valid())
|
||||
return PP_MakeNull();
|
||||
ConvertComponents(url.parsed_for_possibly_invalid_spec(), components);
|
||||
@ -76,17 +76,17 @@ bool SecurityOriginForInstance(PP_Instance instance_id,
|
||||
return true;
|
||||
}
|
||||
|
||||
PP_Var Canonicalize(PP_Var url, PP_UrlComponents_Dev* components) {
|
||||
PP_Var Canonicalize(PP_Var url, PP_URLComponents_Dev* components) {
|
||||
scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url));
|
||||
if (!url_string)
|
||||
return PP_MakeNull();
|
||||
return GenerateUrlReturn(url_string->module(),
|
||||
return GenerateURLReturn(url_string->module(),
|
||||
GURL(url_string->value()), components);
|
||||
}
|
||||
|
||||
PP_Var ResolveRelativeToUrl(PP_Var base_url,
|
||||
PP_Var ResolveRelativeToURL(PP_Var base_url,
|
||||
PP_Var relative,
|
||||
PP_UrlComponents_Dev* components) {
|
||||
PP_URLComponents_Dev* components) {
|
||||
scoped_refptr<StringVar> base_url_string(StringVar::FromPPVar(base_url));
|
||||
scoped_refptr<StringVar> relative_string(StringVar::FromPPVar(relative));
|
||||
if (!base_url_string || !relative_string)
|
||||
@ -95,14 +95,14 @@ PP_Var ResolveRelativeToUrl(PP_Var base_url,
|
||||
GURL base_gurl(base_url_string->value());
|
||||
if (!base_gurl.is_valid())
|
||||
return PP_MakeNull();
|
||||
return GenerateUrlReturn(base_url_string->module(),
|
||||
return GenerateURLReturn(base_url_string->module(),
|
||||
base_gurl.Resolve(relative_string->value()),
|
||||
components);
|
||||
}
|
||||
|
||||
PP_Var ResolveRelativeToDocument(PP_Instance instance_id,
|
||||
PP_Var relative,
|
||||
PP_UrlComponents_Dev* components) {
|
||||
PP_URLComponents_Dev* components) {
|
||||
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
|
||||
if (!instance)
|
||||
return PP_MakeNull();
|
||||
@ -113,7 +113,7 @@ PP_Var ResolveRelativeToDocument(PP_Instance instance_id,
|
||||
|
||||
WebKit::WebElement plugin_element = instance->container()->element();
|
||||
GURL document_url = plugin_element.document().baseURL();
|
||||
return GenerateUrlReturn(instance->module(),
|
||||
return GenerateURLReturn(instance->module(),
|
||||
document_url.Resolve(relative_string->value()),
|
||||
components);
|
||||
}
|
||||
@ -160,19 +160,33 @@ PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) {
|
||||
return BoolToPPBool(active_origin.canAccess(target_origin));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
PP_Var GetDocumentURL(PP_Instance instance_id,
|
||||
PP_URLComponents_Dev* components) {
|
||||
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
|
||||
if (!instance)
|
||||
return PP_MakeNull();
|
||||
|
||||
const PPB_UrlUtil_Dev ppb_url_util = {
|
||||
WebKit::WebFrame* frame = instance->container()->element().document().frame();
|
||||
if (!frame)
|
||||
return PP_MakeNull();
|
||||
|
||||
return GenerateURLReturn(instance->module(), frame->url(), components);
|
||||
}
|
||||
|
||||
const PPB_URLUtil_Dev ppb_url_util = {
|
||||
&Canonicalize,
|
||||
&ResolveRelativeToUrl,
|
||||
&ResolveRelativeToURL,
|
||||
&ResolveRelativeToDocument,
|
||||
&IsSameSecurityOrigin,
|
||||
&DocumentCanRequest,
|
||||
&DocumentCanAccessDocument
|
||||
&DocumentCanAccessDocument,
|
||||
&GetDocumentURL
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
const PPB_UrlUtil_Dev* PPB_UrlUtil_Impl::GetInterface() {
|
||||
const PPB_URLUtil_Dev* PPB_URLUtil_Impl::GetInterface() {
|
||||
return &ppb_url_util;
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_UTIL_IMPL_H_
|
||||
#define WEBKIT_PLUGINS_PPAPI_PPB_URL_UTIL_IMPL_H_
|
||||
|
||||
struct PPB_UrlUtil_Dev;
|
||||
struct PPB_URLUtil_Dev;
|
||||
|
||||
namespace webkit {
|
||||
namespace ppapi {
|
||||
|
||||
class PPB_UrlUtil_Impl {
|
||||
class PPB_URLUtil_Impl {
|
||||
public:
|
||||
static const PPB_UrlUtil_Dev* GetInterface();
|
||||
static const PPB_URLUtil_Dev* GetInterface();
|
||||
};
|
||||
|
||||
} // namespace ppapi
|
||||
|
Reference in New Issue
Block a user