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/plugin_host.h" | 5 #include "webkit/plugins/npapi/plugin_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 475 |
476 base::PlatformFileInfo post_file_info; | 476 base::PlatformFileInfo post_file_info; |
477 if (!file_util::GetFileInfo(file_path, &post_file_info) || | 477 if (!file_util::GetFileInfo(file_path, &post_file_info) || |
478 post_file_info.is_directory) | 478 post_file_info.is_directory) |
479 return NPERR_FILE_NOT_FOUND; | 479 return NPERR_FILE_NOT_FOUND; |
480 | 480 |
481 if (!file_util::ReadFileToString(file_path, &post_file_contents)) | 481 if (!file_util::ReadFileToString(file_path, &post_file_contents)) |
482 return NPERR_FILE_NOT_FOUND; | 482 return NPERR_FILE_NOT_FOUND; |
483 | 483 |
484 buf = post_file_contents.c_str(); | 484 buf = post_file_contents.c_str(); |
485 len = static_cast<uint32_t>(post_file_contents.size()); | 485 len = post_file_contents.size(); |
486 } | 486 } |
487 | 487 |
488 // The post data sent by a plugin contains both headers | 488 // The post data sent by a plugin contains both headers |
489 // and post data. Example: | 489 // and post data. Example: |
490 // Content-type: text/html | 490 // Content-type: text/html |
491 // Content-length: 200 | 491 // Content-length: 200 |
492 // | 492 // |
493 // <200 bytes of content here> | 493 // <200 bytes of content here> |
494 // | 494 // |
495 // Unfortunately, our stream needs these broken apart, | 495 // Unfortunately, our stream needs these broken apart, |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 GURL cookies_url((std::string(url))); | 981 GURL cookies_url((std::string(url))); |
982 result = webplugin->GetCookies(cookies_url, cookies_url); | 982 result = webplugin->GetCookies(cookies_url, cookies_url); |
983 break; | 983 break; |
984 } | 984 } |
985 default: | 985 default: |
986 return NPERR_GENERIC_ERROR; | 986 return NPERR_GENERIC_ERROR; |
987 } | 987 } |
988 | 988 |
989 // Allocate this using the NPAPI allocator. The plugin will call | 989 // Allocate this using the NPAPI allocator. The plugin will call |
990 // NPN_Free to free this. | 990 // NPN_Free to free this. |
991 *value = static_cast<char*>( | 991 *value = static_cast<char*>(NPN_MemAlloc(result.length() + 1)); |
992 NPN_MemAlloc(static_cast<uint32_t>(result.length()) + 1)); | |
993 base::strlcpy(*value, result.c_str(), result.length() + 1); | 992 base::strlcpy(*value, result.c_str(), result.length() + 1); |
994 *len = static_cast<uint32_t>(result.length()); | 993 *len = result.length(); |
995 | 994 |
996 return NPERR_NO_ERROR; | 995 return NPERR_NO_ERROR; |
997 } | 996 } |
998 | 997 |
999 NPError NPN_SetValueForURL(NPP id, | 998 NPError NPN_SetValueForURL(NPP id, |
1000 NPNURLVariable variable, | 999 NPNURLVariable variable, |
1001 const char* url, | 1000 const char* url, |
1002 const char* value, | 1001 const char* value, |
1003 uint32_t len) { | 1002 uint32_t len) { |
1004 if (!id) | 1003 if (!id) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 } | 1105 } |
1107 | 1106 |
1108 void NPN_URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) { | 1107 void NPN_URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) { |
1109 scoped_refptr<PluginInstance> plugin(FindInstance(instance)); | 1108 scoped_refptr<PluginInstance> plugin(FindInstance(instance)); |
1110 if (plugin) { | 1109 if (plugin) { |
1111 plugin->URLRedirectResponse(!!allow, notify_data); | 1110 plugin->URLRedirectResponse(!!allow, notify_data); |
1112 } | 1111 } |
1113 } | 1112 } |
1114 | 1113 |
1115 } // extern "C" | 1114 } // extern "C" |
OLD | NEW |