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

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

Issue 6519057: Implement proxying for FileRef and FileChooser.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 10 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
OLDNEW
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 "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/dev/file_ref_dev.h" 9 #include "ppapi/cpp/dev/file_ref_dev.h"
10 #include "ppapi/cpp/instance.h" 10 #include "ppapi/cpp/instance.h"
11 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/var.h" 12 #include "ppapi/cpp/var.h"
13 13
14 class MyInstance : public pp::Instance { 14 class MyInstance : public pp::Instance {
15 public: 15 public:
16 MyInstance(PP_Instance instance) 16 MyInstance(PP_Instance instance)
17 : pp::Instance(instance) { 17 : pp::Instance(instance) {
18 callback_factory_.Initialize(this); 18 callback_factory_.Initialize(this);
19 } 19 }
20 20
21 virtual bool HandleEvent(const PP_InputEvent& event) { 21 virtual bool HandleInputEvent(const PP_InputEvent& event) {
22 switch (event.type) { 22 switch (event.type) {
23 case PP_INPUTEVENT_TYPE_MOUSEDOWN: { 23 case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
24 const PP_InputEvent_Mouse& mouse_event = event.u.mouse; 24 const PP_InputEvent_Mouse& mouse_event = event.u.mouse;
25 if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_LEFT) 25 if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_LEFT)
26 ShowFileChooser(false); 26 ShowFileChooser(false);
27 else if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) 27 else if (mouse_event.button == PP_INPUTEVENT_MOUSEBUTTON_RIGHT)
28 ShowFileChooser(true); 28 ShowFileChooser(true);
29 else 29 else
30 return false; 30 return false;
31 31
(...skipping 19 matching lines...) Expand all
51 file_chooser->Show(callback_factory_.NewCallback( 51 file_chooser->Show(callback_factory_.NewCallback(
52 &MyInstance::ShowSelectedFileNames, file_chooser)); 52 &MyInstance::ShowSelectedFileNames, file_chooser));
53 } 53 }
54 54
55 void ShowSelectedFileNames(int32_t, pp::FileChooser_Dev* file_chooser) { 55 void ShowSelectedFileNames(int32_t, pp::FileChooser_Dev* file_chooser) {
56 if (!file_chooser) 56 if (!file_chooser)
57 return; 57 return;
58 58
59 pp::FileRef_Dev file_ref = file_chooser->GetNextChosenFile(); 59 pp::FileRef_Dev file_ref = file_chooser->GetNextChosenFile();
60 while (!file_ref.is_null()) { 60 while (!file_ref.is_null()) {
61 Log(file_ref.GetPath()); 61 Log(file_ref.GetName());
62 file_ref = file_chooser->GetNextChosenFile(); 62 file_ref = file_chooser->GetNextChosenFile();
63 } 63 }
64 64
65 delete file_chooser; 65 delete file_chooser;
66 } 66 }
67 67
68 void RecreateConsole() { 68 void RecreateConsole() {
69 pp::Var doc = GetWindowObject().GetProperty("document"); 69 pp::Var doc = GetWindowObject().GetProperty("document");
70 pp::Var body = doc.GetProperty("body"); 70 pp::Var body = doc.GetProperty("body");
71 if (!console_.is_undefined()) 71 if (!console_.is_undefined())
(...skipping 26 matching lines...) Expand all
98 }; 98 };
99 99
100 namespace pp { 100 namespace pp {
101 101
102 // Factory function for your specialization of the Module object. 102 // Factory function for your specialization of the Module object.
103 Module* CreateModule() { 103 Module* CreateModule() {
104 return new MyModule(); 104 return new MyModule();
105 } 105 }
106 106
107 } // namespace pp 107 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698