| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/glue/plugins/pepper_file_chooser.h" | 5 #include "webkit/glue/plugins/pepper_file_chooser.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // static | 112 // static |
| 113 const PPB_FileChooser_Dev* FileChooser::GetInterface() { | 113 const PPB_FileChooser_Dev* FileChooser::GetInterface() { |
| 114 return &ppb_filechooser; | 114 return &ppb_filechooser; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void FileChooser::StoreChosenFiles(const std::vector<std::string>& files) { | 117 void FileChooser::StoreChosenFiles(const std::vector<std::string>& files) { |
| 118 next_chosen_file_index_ = 0; | 118 next_chosen_file_index_ = 0; |
| 119 std::vector<std::string>::const_iterator end_it = files.end(); | 119 std::vector<std::string>::const_iterator end_it = files.end(); |
| 120 for (std::vector<std::string>::const_iterator it = files.begin(); | 120 for (std::vector<std::string>::const_iterator it = files.begin(); |
| 121 it != end_it; it++) | 121 it != end_it; it++) { |
| 122 chosen_files_.push_back(new FileRef(module(), FilePath().AppendASCII(*it))); | 122 chosen_files_.push_back(make_scoped_refptr( |
| 123 new FileRef(module(), FilePath().AppendASCII(*it)))); |
| 124 } |
| 123 | 125 |
| 124 if (!completion_callback_.func) | 126 if (!completion_callback_.func) |
| 125 return; | 127 return; |
| 126 | 128 |
| 127 PP_CompletionCallback callback = {0}; | 129 PP_CompletionCallback callback = {0}; |
| 128 std::swap(callback, completion_callback_); | 130 std::swap(callback, completion_callback_); |
| 129 PP_RunCompletionCallback(&callback, 0); | 131 PP_RunCompletionCallback(&callback, 0); |
| 130 } | 132 } |
| 131 | 133 |
| 132 int32_t FileChooser::Show(PP_CompletionCallback callback) { | 134 int32_t FileChooser::Show(PP_CompletionCallback callback) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 145 } | 147 } |
| 146 | 148 |
| 147 scoped_refptr<FileRef> FileChooser::GetNextChosenFile() { | 149 scoped_refptr<FileRef> FileChooser::GetNextChosenFile() { |
| 148 if (next_chosen_file_index_ >= chosen_files_.size()) | 150 if (next_chosen_file_index_ >= chosen_files_.size()) |
| 149 return NULL; | 151 return NULL; |
| 150 | 152 |
| 151 return chosen_files_[next_chosen_file_index_++]; | 153 return chosen_files_[next_chosen_file_index_++]; |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace pepper | 156 } // namespace pepper |
| OLD | NEW |