Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: ppapi/examples/file_chooser/file_chooser.cc

Issue 9728001: Make the file chooser use PP_ArrayOutput (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/trusted/file_chooser_trusted.cc ('k') | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ppapi/cpp/trusted/file_chooser_trusted.cc ('k') | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698