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 "webkit/plugins/npapi/webplugin_impl.h" | 5 #include "webkit/plugins/npapi/webplugin_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 namespace webkit { | 79 namespace webkit { |
80 namespace npapi { | 80 namespace npapi { |
81 | 81 |
82 namespace { | 82 namespace { |
83 | 83 |
84 const char kFlashMimeType[] = "application/x-shockwave-flash"; | 84 const char kFlashMimeType[] = "application/x-shockwave-flash"; |
85 const char kOctetStreamMimeType[] = "application/octet-stream"; | 85 const char kOctetStreamMimeType[] = "application/octet-stream"; |
86 const char kHTMLMimeType[] = "text/html"; | 86 const char kHTMLMimeType[] = "text/html"; |
87 const char kPlainTextMimeType[] = "text/plain"; | 87 const char kPlainTextMimeType[] = "text/plain"; |
88 const char kPluginFlashMimeType[] = "Plugin.FlashMIMEType"; | 88 const char kPluginFlashMimeType[] = "Plugin.FlashMIMEType"; |
89 const char kPluginFlashVersion[] = "Plugin.FlashVersion"; | |
89 | 90 |
90 enum { | 91 enum { |
91 MIME_TYPE_OK = 0, | 92 MIME_TYPE_OK = 0, |
92 MIME_TYPE_EMPTY, | 93 MIME_TYPE_EMPTY, |
93 MIME_TYPE_OCTETSTREAM, | 94 MIME_TYPE_OCTETSTREAM, |
94 MIME_TYPE_HTML, | 95 MIME_TYPE_HTML, |
95 MIME_TYPE_PLAINTEXT, | 96 MIME_TYPE_PLAINTEXT, |
96 MIME_TYPE_OTHER, | 97 MIME_TYPE_OTHER, |
97 MIME_TYPE_NUM_EVENTS | 98 MIME_TYPE_NUM_EVENTS |
98 }; | 99 }; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 // WebKit::WebPlugin ---------------------------------------------------------- | 238 // WebKit::WebPlugin ---------------------------------------------------------- |
238 | 239 |
239 struct WebPluginImpl::ClientInfo { | 240 struct WebPluginImpl::ClientInfo { |
240 unsigned long id; | 241 unsigned long id; |
241 WebPluginResourceClient* client; | 242 WebPluginResourceClient* client; |
242 WebKit::WebURLRequest request; | 243 WebKit::WebURLRequest request; |
243 bool pending_failure_notification; | 244 bool pending_failure_notification; |
244 linked_ptr<WebKit::WebURLLoader> loader; | 245 linked_ptr<WebKit::WebURLLoader> loader; |
245 bool notify_redirects; | 246 bool notify_redirects; |
246 bool is_plugin_src_load; | 247 bool is_plugin_src_load; |
248 bool check_flash_version; | |
247 }; | 249 }; |
248 | 250 |
249 bool WebPluginImpl::initialize(WebPluginContainer* container) { | 251 bool WebPluginImpl::initialize(WebPluginContainer* container) { |
250 if (!page_delegate_) { | 252 if (!page_delegate_) { |
251 LOG(ERROR) << "No page delegate"; | 253 LOG(ERROR) << "No page delegate"; |
252 return false; | 254 return false; |
253 } | 255 } |
254 | 256 |
255 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( | 257 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( |
256 file_path_, mime_type_); | 258 file_path_, mime_type_); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 ResponseInfo response_info; | 886 ResponseInfo response_info; |
885 GetResponseInfo(response, &response_info); | 887 GetResponseInfo(response, &response_info); |
886 | 888 |
887 ClientInfo* client_info = GetClientInfoFromLoader(loader); | 889 ClientInfo* client_info = GetClientInfoFromLoader(loader); |
888 if (!client_info) | 890 if (!client_info) |
889 return; | 891 return; |
890 | 892 |
891 // Defend against content confusion by the Flash plug-in. | 893 // Defend against content confusion by the Flash plug-in. |
892 if (client_info->is_plugin_src_load && | 894 if (client_info->is_plugin_src_load && |
893 mime_type_ == kFlashMimeType) { | 895 mime_type_ == kFlashMimeType) { |
896 client_info->check_flash_version = true; | |
894 std::string sniff = | 897 std::string sniff = |
895 response.httpHeaderField("X-Content-Type-Options").utf8(); | 898 response.httpHeaderField("X-Content-Type-Options").utf8(); |
896 std::string content_type = | 899 std::string content_type = |
897 response.httpHeaderField("Content-Type").utf8(); | 900 response.httpHeaderField("Content-Type").utf8(); |
898 StringToLowerASCII(&sniff); | 901 StringToLowerASCII(&sniff); |
899 StringToLowerASCII(&content_type); | 902 StringToLowerASCII(&content_type); |
900 if (content_type.find(kFlashMimeType) != std::string::npos) { | 903 if (content_type.find(kFlashMimeType) != std::string::npos) { |
901 UMA_HISTOGRAM_ENUMERATION(kPluginFlashMimeType, | 904 UMA_HISTOGRAM_ENUMERATION(kPluginFlashMimeType, |
902 MIME_TYPE_OK, | 905 MIME_TYPE_OK, |
903 MIME_TYPE_NUM_EVENTS); | 906 MIME_TYPE_NUM_EVENTS); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 } | 1009 } |
1007 | 1010 |
1008 void WebPluginImpl::didReceiveData(WebURLLoader* loader, | 1011 void WebPluginImpl::didReceiveData(WebURLLoader* loader, |
1009 const char *buffer, | 1012 const char *buffer, |
1010 int data_length, | 1013 int data_length, |
1011 int encoded_data_length) { | 1014 int encoded_data_length) { |
1012 WebPluginResourceClient* client = GetClientFromLoader(loader); | 1015 WebPluginResourceClient* client = GetClientFromLoader(loader); |
1013 if (!client) | 1016 if (!client) |
1014 return; | 1017 return; |
1015 | 1018 |
1019 ClientInfo* client_info = GetClientInfoFromLoader(loader); | |
Bernhard Bauer
2012/03/28 13:19:29
Can you put this (and possibly the |check_flash_ve
| |
1020 if (client_info && client_info->check_flash_version) { | |
1021 client_info->check_flash_version = false; | |
1022 if (data_length >= 4 && | |
1023 (buffer[0] == 'C' || buffer[1] == 'F') && | |
1024 buffer[1] == 'W' && | |
1025 buffer[2] == 'S') { | |
1026 unsigned char version = static_cast<unsigned char>(buffer[3]); | |
1027 UMA_HISTOGRAM_ENUMERATION(kPluginFlashVersion, | |
1028 version, | |
1029 256); | |
1030 } | |
1031 } | |
1032 | |
1016 MultiPartResponseHandlerMap::iterator index = | 1033 MultiPartResponseHandlerMap::iterator index = |
1017 multi_part_response_map_.find(client); | 1034 multi_part_response_map_.find(client); |
1018 if (index != multi_part_response_map_.end()) { | 1035 if (index != multi_part_response_map_.end()) { |
1019 MultipartResponseDelegate* multi_part_handler = (*index).second; | 1036 MultipartResponseDelegate* multi_part_handler = (*index).second; |
1020 DCHECK(multi_part_handler != NULL); | 1037 DCHECK(multi_part_handler != NULL); |
1021 multi_part_handler->OnReceivedData(buffer, | 1038 multi_part_handler->OnReceivedData(buffer, |
1022 data_length, | 1039 data_length, |
1023 encoded_data_length); | 1040 encoded_data_length); |
1024 } else { | 1041 } else { |
1025 loader->setDefersLoading(true); | 1042 loader->setDefersLoading(true); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 info.request.initialize(); | 1213 info.request.initialize(); |
1197 info.request.setURL(url); | 1214 info.request.setURL(url); |
1198 info.request.setFirstPartyForCookies( | 1215 info.request.setFirstPartyForCookies( |
1199 webframe_->document().firstPartyForCookies()); | 1216 webframe_->document().firstPartyForCookies()); |
1200 info.request.setRequestorProcessID(delegate_->GetProcessId()); | 1217 info.request.setRequestorProcessID(delegate_->GetProcessId()); |
1201 info.request.setTargetType(WebURLRequest::TargetIsObject); | 1218 info.request.setTargetType(WebURLRequest::TargetIsObject); |
1202 info.request.setHTTPMethod(WebString::fromUTF8(method)); | 1219 info.request.setHTTPMethod(WebString::fromUTF8(method)); |
1203 info.pending_failure_notification = false; | 1220 info.pending_failure_notification = false; |
1204 info.notify_redirects = notify_redirects; | 1221 info.notify_redirects = notify_redirects; |
1205 info.is_plugin_src_load = is_plugin_src_load; | 1222 info.is_plugin_src_load = is_plugin_src_load; |
1223 info.check_flash_version = false; | |
1206 | 1224 |
1207 if (range_info) { | 1225 if (range_info) { |
1208 info.request.addHTTPHeaderField(WebString::fromUTF8("Range"), | 1226 info.request.addHTTPHeaderField(WebString::fromUTF8("Range"), |
1209 WebString::fromUTF8(range_info)); | 1227 WebString::fromUTF8(range_info)); |
1210 } | 1228 } |
1211 | 1229 |
1212 if (strcmp(method, "POST") == 0) { | 1230 if (strcmp(method, "POST") == 0) { |
1213 // Adds headers or form data to a request. This must be called before | 1231 // Adds headers or form data to a request. This must be called before |
1214 // we initiate the actual request. | 1232 // we initiate the actual request. |
1215 SetPostData(&info.request, buf, buf_len); | 1233 SetPostData(&info.request, buf, buf_len); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1402 webframe_->setReferrerForRequest(*request, plugin_url_); | 1420 webframe_->setReferrerForRequest(*request, plugin_url_); |
1403 break; | 1421 break; |
1404 | 1422 |
1405 default: | 1423 default: |
1406 break; | 1424 break; |
1407 } | 1425 } |
1408 } | 1426 } |
1409 | 1427 |
1410 } // namespace npapi | 1428 } // namespace npapi |
1411 } // namespace webkit | 1429 } // namespace webkit |
OLD | NEW |