| 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 "ppapi/c/dev/ppb_file_chooser_dev.h" | 5 #include "ppapi/c/dev/ppb_file_chooser_dev.h" |
| 6 #include "ppapi/c/pp_input_event.h" | 6 #include "ppapi/c/pp_input_event.h" |
| 7 #include "ppapi/cpp/completion_callback.h" | 7 #include "ppapi/cpp/completion_callback.h" |
| 8 #include "ppapi/cpp/dev/file_chooser_dev.h" | 8 #include "ppapi/cpp/dev/file_chooser_dev.h" |
| 9 #include "ppapi/cpp/file_ref.h" | 9 #include "ppapi/cpp/file_ref.h" |
| 10 #include "ppapi/cpp/input_event.h" | 10 #include "ppapi/cpp/input_event.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 private: | 42 private: |
| 43 void ShowFileChooser(bool multi_select) { | 43 void ShowFileChooser(bool multi_select) { |
| 44 RecreateConsole(); | 44 RecreateConsole(); |
| 45 | 45 |
| 46 PP_FileChooserMode_Dev mode = | 46 PP_FileChooserMode_Dev mode = |
| 47 (multi_select ? PP_FILECHOOSERMODE_OPENMULTIPLE | 47 (multi_select ? PP_FILECHOOSERMODE_OPENMULTIPLE |
| 48 : PP_FILECHOOSERMODE_OPEN); | 48 : PP_FILECHOOSERMODE_OPEN); |
| 49 std::string accept_mime_types = (multi_select ? "" : "plain/text"); | 49 std::string accept_mime_types = (multi_select ? "" : "plain/text"); |
| 50 | 50 |
| 51 chooser_ = pp::FileChooser_Dev(this, mode, accept_mime_types); | 51 chooser_ = pp::FileChooser_Dev(this, mode, accept_mime_types); |
| 52 chooser_.Show(callback_factory_.NewCallback( | 52 chooser_.Show(callback_factory_.NewCallbackWithOutput( |
| 53 &MyInstance::ShowSelectedFileNames)); | 53 &MyInstance::ShowSelectedFileNames)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ShowSelectedFileNames(int32_t result) { | 56 void ShowSelectedFileNames(int32_t result, |
| 57 if (!result != PP_OK) | 57 const std::vector<pp::FileRef>& files) { |
| 58 if (result != PP_OK) |
| 58 return; | 59 return; |
| 59 | 60 for (size_t i = 0; i < files.size(); i++) |
| 60 pp::FileRef file_ref = chooser_.GetNextChosenFile(); | 61 Log(files[i].GetName()); |
| 61 while (!file_ref.is_null()) { | |
| 62 Log(file_ref.GetName()); | |
| 63 file_ref = chooser_.GetNextChosenFile(); | |
| 64 } | |
| 65 } | 62 } |
| 66 | 63 |
| 67 void RecreateConsole() { | 64 void RecreateConsole() { |
| 68 pp::VarPrivate doc = GetWindowObject().GetProperty("document"); | 65 pp::VarPrivate doc = GetWindowObject().GetProperty("document"); |
| 69 pp::VarPrivate body = doc.GetProperty("body"); | 66 pp::VarPrivate body = doc.GetProperty("body"); |
| 70 if (!console_.is_undefined()) | 67 if (!console_.is_undefined()) |
| 71 body.Call("removeChild", console_); | 68 body.Call("removeChild", console_); |
| 72 | 69 |
| 73 console_ = doc.Call("createElement", "pre"); | 70 console_ = doc.Call("createElement", "pre"); |
| 74 console_.SetProperty("id", "console"); | 71 console_.SetProperty("id", "console"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 }; | 96 }; |
| 100 | 97 |
| 101 namespace pp { | 98 namespace pp { |
| 102 | 99 |
| 103 // Factory function for your specialization of the Module object. | 100 // Factory function for your specialization of the Module object. |
| 104 Module* CreateModule() { | 101 Module* CreateModule() { |
| 105 return new MyModule(); | 102 return new MyModule(); |
| 106 } | 103 } |
| 107 | 104 |
| 108 } // namespace pp | 105 } // namespace pp |
| OLD | NEW |