| 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 "content/renderer/pepper/pepper_file_chooser_host.h" | 5 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" | 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" | 10 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 PPAPI_END_MESSAGE_MAP() | 87 PPAPI_END_MESSAGE_MAP() |
| 88 return PP_ERROR_FAILED; | 88 return PP_ERROR_FAILED; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void PepperFileChooserHost::StoreChosenFiles( | 91 void PepperFileChooserHost::StoreChosenFiles( |
| 92 const std::vector<ChosenFileInfo>& files) { | 92 const std::vector<ChosenFileInfo>& files) { |
| 93 std::vector<IPC::Message> create_msgs; | 93 std::vector<IPC::Message> create_msgs; |
| 94 std::vector<base::FilePath> file_paths; | 94 std::vector<base::FilePath> file_paths; |
| 95 std::vector<std::string> display_names; | 95 std::vector<std::string> display_names; |
| 96 for (size_t i = 0; i < files.size(); i++) { | 96 for (size_t i = 0; i < files.size(); i++) { |
| 97 #if defined(OS_WIN) | 97 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(files[i].path); |
| 98 base::FilePath file_path(base::UTF8ToWide(files[i].path)); | |
| 99 #else | |
| 100 base::FilePath file_path(files[i].path); | |
| 101 #endif | |
| 102 file_paths.push_back(file_path); | 98 file_paths.push_back(file_path); |
| 103 create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(file_path)); | 99 create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(file_path)); |
| 104 display_names.push_back(files[i].display_name); | 100 display_names.push_back(files[i].display_name); |
| 105 } | 101 } |
| 106 | 102 |
| 107 if (!files.empty()) { | 103 if (!files.empty()) { |
| 108 renderer_ppapi_host_->CreateBrowserResourceHosts( | 104 renderer_ppapi_host_->CreateBrowserResourceHosts( |
| 109 pp_instance(), | 105 pp_instance(), |
| 110 create_msgs, | 106 create_msgs, |
| 111 base::Bind(&PepperFileChooserHost::DidCreateResourceHosts, | 107 base::Bind(&PepperFileChooserHost::DidCreateResourceHosts, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 182 } |
| 187 | 183 |
| 188 reply_context_.params.set_result(PP_OK); | 184 reply_context_.params.set_result(PP_OK); |
| 189 host()->SendReply(reply_context_, | 185 host()->SendReply(reply_context_, |
| 190 PpapiPluginMsg_FileChooser_ShowReply(chosen_files)); | 186 PpapiPluginMsg_FileChooser_ShowReply(chosen_files)); |
| 191 reply_context_ = ppapi::host::ReplyMessageContext(); | 187 reply_context_ = ppapi::host::ReplyMessageContext(); |
| 192 handler_ = NULL; // Handler deletes itself. | 188 handler_ = NULL; // Handler deletes itself. |
| 193 } | 189 } |
| 194 | 190 |
| 195 } // namespace content | 191 } // namespace content |
| OLD | NEW |