| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/plugins/ppapi/ppb_url_util_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_url_util_impl.h" |
| 6 | 6 |
| 7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
| 8 #include "ppapi/c/dev/ppb_url_util_dev.h" | 8 #include "ppapi/c/dev/ppb_url_util_dev.h" |
| 9 #include "ppapi/c/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
| 10 #include "ppapi/shared_impl/url_util_impl.h" | 10 #include "ppapi/shared_impl/url_util_impl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 using ppapi::StringVar; | 26 using ppapi::StringVar; |
| 27 using ppapi::URLUtilImpl; | 27 using ppapi::URLUtilImpl; |
| 28 | 28 |
| 29 namespace webkit { | 29 namespace webkit { |
| 30 namespace ppapi { | 30 namespace ppapi { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // Returns the PP_Module associated with the given string, or 0 on failure. | 34 // Returns the PP_Module associated with the given string, or 0 on failure. |
| 35 PP_Module GetModuleFromVar(PP_Var string_var) { | 35 PP_Module GetModuleFromVar(PP_Var string_var) { |
| 36 scoped_refptr<StringVar> str(StringVar::FromPPVar(string_var)); | 36 StringVar* str = StringVar::FromPPVar(string_var); |
| 37 if (!str) | 37 if (!str) |
| 38 return 0; | 38 return 0; |
| 39 return str->pp_module(); | 39 return str->pp_module(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Sets |*security_origin| to be the WebKit security origin associated with the | 42 // Sets |*security_origin| to be the WebKit security origin associated with the |
| 43 // document containing the given plugin instance. On success, returns true. If | 43 // document containing the given plugin instance. On success, returns true. If |
| 44 // the instance is invalid, returns false and |*security_origin| will be | 44 // the instance is invalid, returns false and |*security_origin| will be |
| 45 // unchanged. | 45 // unchanged. |
| 46 bool SecurityOriginForInstance(PP_Instance instance_id, | 46 bool SecurityOriginForInstance(PP_Instance instance_id, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 base_url, relative, components); | 65 base_url, relative, components); |
| 66 } | 66 } |
| 67 | 67 |
| 68 PP_Var ResolveRelativeToDocument(PP_Instance instance_id, | 68 PP_Var ResolveRelativeToDocument(PP_Instance instance_id, |
| 69 PP_Var relative, | 69 PP_Var relative, |
| 70 PP_URLComponents_Dev* components) { | 70 PP_URLComponents_Dev* components) { |
| 71 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 71 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 72 if (!instance) | 72 if (!instance) |
| 73 return PP_MakeNull(); | 73 return PP_MakeNull(); |
| 74 | 74 |
| 75 scoped_refptr<StringVar> relative_string(StringVar::FromPPVar(relative)); | 75 StringVar* relative_string = StringVar::FromPPVar(relative); |
| 76 if (!relative_string) | 76 if (!relative_string) |
| 77 return PP_MakeNull(); | 77 return PP_MakeNull(); |
| 78 | 78 |
| 79 WebKit::WebElement plugin_element = instance->container()->element(); | 79 WebKit::WebElement plugin_element = instance->container()->element(); |
| 80 GURL document_url = plugin_element.document().baseURL(); | 80 GURL document_url = plugin_element.document().baseURL(); |
| 81 return URLUtilImpl::GenerateURLReturn( | 81 return URLUtilImpl::GenerateURLReturn( |
| 82 instance->module()->pp_module(), | 82 instance->module()->pp_module(), |
| 83 document_url.Resolve(relative_string->value()), | 83 document_url.Resolve(relative_string->value()), |
| 84 components); | 84 components); |
| 85 } | 85 } |
| 86 | 86 |
| 87 PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { | 87 PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { |
| 88 return URLUtilImpl::IsSameSecurityOrigin(url_a, url_b); | 88 return URLUtilImpl::IsSameSecurityOrigin(url_a, url_b); |
| 89 } | 89 } |
| 90 | 90 |
| 91 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { | 91 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { |
| 92 scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url)); | 92 StringVar* url_string = StringVar::FromPPVar(url); |
| 93 if (!url_string) | 93 if (!url_string) |
| 94 return PP_FALSE; | 94 return PP_FALSE; |
| 95 | 95 |
| 96 WebKit::WebSecurityOrigin security_origin; | 96 WebKit::WebSecurityOrigin security_origin; |
| 97 if (!SecurityOriginForInstance(instance, &security_origin)) | 97 if (!SecurityOriginForInstance(instance, &security_origin)) |
| 98 return PP_FALSE; | 98 return PP_FALSE; |
| 99 | 99 |
| 100 GURL gurl(url_string->value()); | 100 GURL gurl(url_string->value()); |
| 101 if (!gurl.is_valid()) | 101 if (!gurl.is_valid()) |
| 102 return PP_FALSE; | 102 return PP_FALSE; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 // static | 154 // static |
| 155 const PPB_URLUtil_Dev* PPB_URLUtil_Impl::GetInterface() { | 155 const PPB_URLUtil_Dev* PPB_URLUtil_Impl::GetInterface() { |
| 156 return &ppb_url_util; | 156 return &ppb_url_util; |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace ppapi | 159 } // namespace ppapi |
| 160 } // namespace webkit | 160 } // namespace webkit |
| 161 | 161 |
| OLD | NEW |