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_response_info_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
9 #include "ppapi/shared_impl/var.h" | 9 #include "ppapi/shared_impl/var.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeade
rVisitor.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeade
rVisitor.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
14 #include "webkit/plugins/ppapi/common.h" | 14 #include "webkit/plugins/ppapi/common.h" |
15 #include "webkit/plugins/ppapi/plugin_module.h" | |
16 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
17 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 16 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
18 #include "webkit/plugins/ppapi/resource_helper.h" | 17 #include "webkit/plugins/ppapi/resource_helper.h" |
19 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" |
20 | 19 |
21 using ppapi::StringVar; | 20 using ppapi::StringVar; |
22 using ppapi::thunk::PPB_URLResponseInfo_API; | 21 using ppapi::thunk::PPB_URLResponseInfo_API; |
23 using WebKit::WebHTTPHeaderVisitor; | 22 using WebKit::WebHTTPHeaderVisitor; |
24 using WebKit::WebString; | 23 using WebKit::WebString; |
25 using WebKit::WebURLResponse; | 24 using WebKit::WebURLResponse; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 pp_instance(), webkit_glue::WebStringToFilePath(file_path)); | 77 pp_instance(), webkit_glue::WebStringToFilePath(file_path)); |
79 } | 78 } |
80 return true; | 79 return true; |
81 } | 80 } |
82 | 81 |
83 PPB_URLResponseInfo_API* PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_API() { | 82 PPB_URLResponseInfo_API* PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_API() { |
84 return this; | 83 return this; |
85 } | 84 } |
86 | 85 |
87 PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) { | 86 PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) { |
88 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); | |
89 if (!plugin_module) | |
90 return PP_MakeUndefined(); | |
91 PP_Module pp_module = plugin_module->pp_module(); | |
92 switch (property) { | 87 switch (property) { |
93 case PP_URLRESPONSEPROPERTY_URL: | 88 case PP_URLRESPONSEPROPERTY_URL: |
94 return StringVar::StringToPPVar(pp_module, url_); | 89 return StringVar::StringToPPVar(url_); |
95 case PP_URLRESPONSEPROPERTY_REDIRECTURL: | 90 case PP_URLRESPONSEPROPERTY_REDIRECTURL: |
96 if (IsRedirect(status_code_)) | 91 if (IsRedirect(status_code_)) |
97 return StringVar::StringToPPVar(pp_module, redirect_url_); | 92 return StringVar::StringToPPVar(redirect_url_); |
98 break; | 93 break; |
99 case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD: | 94 case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD: |
100 if (IsRedirect(status_code_)) | 95 if (IsRedirect(status_code_)) |
101 return StringVar::StringToPPVar(pp_module, status_text_); | 96 return StringVar::StringToPPVar(status_text_); |
102 break; | 97 break; |
103 case PP_URLRESPONSEPROPERTY_STATUSCODE: | 98 case PP_URLRESPONSEPROPERTY_STATUSCODE: |
104 return PP_MakeInt32(status_code_); | 99 return PP_MakeInt32(status_code_); |
105 case PP_URLRESPONSEPROPERTY_STATUSLINE: | 100 case PP_URLRESPONSEPROPERTY_STATUSLINE: |
106 return StringVar::StringToPPVar(pp_module, status_text_); | 101 return StringVar::StringToPPVar(status_text_); |
107 case PP_URLRESPONSEPROPERTY_HEADERS: | 102 case PP_URLRESPONSEPROPERTY_HEADERS: |
108 return StringVar::StringToPPVar(pp_module, headers_); | 103 return StringVar::StringToPPVar(headers_); |
109 } | 104 } |
110 // The default is to return an undefined PP_Var. | 105 // The default is to return an undefined PP_Var. |
111 return PP_MakeUndefined(); | 106 return PP_MakeUndefined(); |
112 } | 107 } |
113 | 108 |
114 PP_Resource PPB_URLResponseInfo_Impl::GetBodyAsFileRef() { | 109 PP_Resource PPB_URLResponseInfo_Impl::GetBodyAsFileRef() { |
115 if (!body_.get()) | 110 if (!body_.get()) |
116 return 0; | 111 return 0; |
117 return body_->GetReference(); | 112 return body_->GetReference(); |
118 } | 113 } |
119 | 114 |
120 } // namespace ppapi | 115 } // namespace ppapi |
121 } // namespace webkit | 116 } // namespace webkit |
122 | 117 |
OLD | NEW |