| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/shared_impl/ppb_url_util_shared.h" | 6 #include "ppapi/shared_impl/ppb_url_util_shared.h" |
| 7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_instance_api.h" | 8 #include "ppapi/thunk/ppb_instance_api.h" |
| 9 #include "ppapi/thunk/thunk.h" | 9 #include "ppapi/thunk/thunk.h" |
| 10 | 10 |
| 11 namespace ppapi { | 11 namespace ppapi { |
| 12 namespace thunk { | 12 namespace thunk { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 PP_Var ResolveRelativeToDocument(PP_Instance instance, | 16 PP_Var ResolveRelativeToDocument(PP_Instance instance, |
| 17 PP_Var relative, | 17 PP_Var relative, |
| 18 PP_URLComponents_Dev* components) { | 18 PP_URLComponents_Dev* components) { |
| 19 EnterInstance enter(instance); | 19 EnterInstance enter(instance); |
| 20 if (enter.failed()) | 20 if (enter.failed()) |
| 21 return PP_MakeUndefined(); | 21 return PP_MakeUndefined(); |
| 22 return enter.functions()->ResolveRelativeToDocument(instance, relative, | 22 return enter.functions()->ResolveRelativeToDocument( |
| 23 components); | 23 instance, relative, components); |
| 24 } | 24 } |
| 25 | 25 |
| 26 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { | 26 PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { |
| 27 EnterInstance enter(instance); | 27 EnterInstance enter(instance); |
| 28 if (enter.failed()) | 28 if (enter.failed()) |
| 29 return PP_FALSE; | 29 return PP_FALSE; |
| 30 return enter.functions()->DocumentCanRequest(instance, url); | 30 return enter.functions()->DocumentCanRequest(instance, url); |
| 31 } | 31 } |
| 32 | 32 |
| 33 PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { | 33 PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { |
| 34 EnterInstance enter(active); | 34 EnterInstance enter(active); |
| 35 if (enter.failed()) | 35 if (enter.failed()) |
| 36 return PP_FALSE; | 36 return PP_FALSE; |
| 37 return enter.functions()->DocumentCanAccessDocument(active, target); | 37 return enter.functions()->DocumentCanAccessDocument(active, target); |
| 38 } | 38 } |
| 39 | 39 |
| 40 PP_Var GetDocumentURL(PP_Instance instance, | 40 PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { |
| 41 PP_URLComponents_Dev* components) { | |
| 42 EnterInstance enter(instance); | 41 EnterInstance enter(instance); |
| 43 if (enter.failed()) | 42 if (enter.failed()) |
| 44 return PP_MakeUndefined(); | 43 return PP_MakeUndefined(); |
| 45 return enter.functions()->GetDocumentURL(instance, components); | 44 return enter.functions()->GetDocumentURL(instance, components); |
| 46 } | 45 } |
| 47 | 46 |
| 48 PP_Var GetPluginInstanceURL(PP_Instance instance, | 47 PP_Var GetPluginInstanceURL(PP_Instance instance, |
| 49 PP_URLComponents_Dev* components) { | 48 PP_URLComponents_Dev* components) { |
| 50 EnterInstance enter(instance); | 49 EnterInstance enter(instance); |
| 51 if (enter.failed()) | 50 if (enter.failed()) |
| 52 return PP_MakeUndefined(); | 51 return PP_MakeUndefined(); |
| 53 return enter.functions()->GetPluginInstanceURL(instance, components); | 52 return enter.functions()->GetPluginInstanceURL(instance, components); |
| 54 } | 53 } |
| 55 | 54 |
| 56 PP_Var GetPluginReferrerURL(PP_Instance instance, | 55 PP_Var GetPluginReferrerURL(PP_Instance instance, |
| 57 PP_URLComponents_Dev* components) { | 56 PP_URLComponents_Dev* components) { |
| 58 EnterInstance enter(instance); | 57 EnterInstance enter(instance); |
| 59 if (enter.failed()) | 58 if (enter.failed()) |
| 60 return PP_MakeUndefined(); | 59 return PP_MakeUndefined(); |
| 61 return enter.functions()->GetPluginReferrerURL(instance, components); | 60 return enter.functions()->GetPluginReferrerURL(instance, components); |
| 62 } | 61 } |
| 63 | 62 |
| 64 const PPB_URLUtil_Dev_0_6 g_ppb_url_util_0_6 = { | 63 const PPB_URLUtil_Dev_0_6 g_ppb_url_util_0_6 = { |
| 65 &PPB_URLUtil_Shared::Canonicalize, | 64 &PPB_URLUtil_Shared::Canonicalize, |
| 66 &PPB_URLUtil_Shared::ResolveRelativeToURL, | 65 &PPB_URLUtil_Shared::ResolveRelativeToURL, |
| 67 &ResolveRelativeToDocument, | 66 &ResolveRelativeToDocument, |
| 68 &PPB_URLUtil_Shared::IsSameSecurityOrigin, | 67 &PPB_URLUtil_Shared::IsSameSecurityOrigin, |
| 69 &DocumentCanRequest, | 68 &DocumentCanRequest, |
| 70 &DocumentCanAccessDocument, | 69 &DocumentCanAccessDocument, |
| 71 &GetDocumentURL, | 70 &GetDocumentURL, |
| 72 &GetPluginInstanceURL | 71 &GetPluginInstanceURL}; |
| 73 }; | |
| 74 | 72 |
| 75 const PPB_URLUtil_Dev_0_7 g_ppb_url_util_0_7 = { | 73 const PPB_URLUtil_Dev_0_7 g_ppb_url_util_0_7 = { |
| 76 &PPB_URLUtil_Shared::Canonicalize, | 74 &PPB_URLUtil_Shared::Canonicalize, |
| 77 &PPB_URLUtil_Shared::ResolveRelativeToURL, | 75 &PPB_URLUtil_Shared::ResolveRelativeToURL, |
| 78 &ResolveRelativeToDocument, | 76 &ResolveRelativeToDocument, |
| 79 &PPB_URLUtil_Shared::IsSameSecurityOrigin, | 77 &PPB_URLUtil_Shared::IsSameSecurityOrigin, |
| 80 &DocumentCanRequest, | 78 &DocumentCanRequest, |
| 81 &DocumentCanAccessDocument, | 79 &DocumentCanAccessDocument, |
| 82 &GetDocumentURL, | 80 &GetDocumentURL, |
| 83 &GetPluginInstanceURL, | 81 &GetPluginInstanceURL, |
| 84 &GetPluginReferrerURL | 82 &GetPluginReferrerURL}; |
| 85 }; | |
| 86 | 83 |
| 87 } // namespace | 84 } // namespace |
| 88 | 85 |
| 89 const PPB_URLUtil_Dev_0_6* GetPPB_URLUtil_Dev_0_6_Thunk() { | 86 const PPB_URLUtil_Dev_0_6* GetPPB_URLUtil_Dev_0_6_Thunk() { |
| 90 return &g_ppb_url_util_0_6; | 87 return &g_ppb_url_util_0_6; |
| 91 } | 88 } |
| 92 | 89 |
| 93 const PPB_URLUtil_Dev_0_7* GetPPB_URLUtil_Dev_0_7_Thunk() { | 90 const PPB_URLUtil_Dev_0_7* GetPPB_URLUtil_Dev_0_7_Thunk() { |
| 94 return &g_ppb_url_util_0_7; | 91 return &g_ppb_url_util_0_7; |
| 95 } | 92 } |
| 96 | 93 |
| 97 } // namespace thunk | 94 } // namespace thunk |
| 98 } // namespace ppapi | 95 } // namespace ppapi |
| OLD | NEW |