Chromium Code Reviews

Side by Side Diff: webkit/glue/plugins/pepper_file_chooser.cc

Issue 2822031: File API boilerplate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/pepper_file_chooser.h ('k') | webkit/glue/plugins/pepper_file_io.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/glue/plugins/pepper_file_chooser.h"
6
7 #include "base/logging.h"
8 #include "third_party/ppapi/c/pp_completion_callback.h"
9 #include "third_party/ppapi/c/pp_errors.h"
10 #include "webkit/glue/plugins/pepper_file_ref.h"
11 #include "webkit/glue/plugins/pepper_plugin_instance.h"
12 #include "webkit/glue/plugins/pepper_resource_tracker.h"
13
14 namespace pepper {
15
16 namespace {
17
18 PP_Resource Create(PP_Instance instance_id,
19 const PP_FileChooserOptions* options) {
20 PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
21 if (!instance)
22 return 0;
23
24 FileChooser* chooser = new FileChooser(instance, options);
25 chooser->AddRef(); // AddRef for the caller.
26 return chooser->GetResource();
27 }
28
29 bool IsFileChooser(PP_Resource resource) {
30 return !!ResourceTracker::Get()->GetAsFileChooser(resource).get();
31 }
32
33 int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) {
34 scoped_refptr<FileChooser> chooser(
35 ResourceTracker::Get()->GetAsFileChooser(chooser_id).get());
36 if (!chooser.get())
37 return PP_Error_BadResource;
38
39 return chooser->Show(callback);
40 }
41
42 PP_Resource GetNextChosenFile(PP_Resource chooser_id) {
43 scoped_refptr<FileChooser> chooser(
44 ResourceTracker::Get()->GetAsFileChooser(chooser_id).get());
45 if (!chooser.get())
46 return 0;
47
48 scoped_refptr<FileRef> file_ref(chooser->GetNextChosenFile());
49 if (!file_ref.get())
50 return 0;
51 file_ref->AddRef(); // AddRef for the caller.
52
53 return file_ref->GetResource();
54 }
55
56 const PPB_FileChooser ppb_filechooser = {
57 &Create,
58 &IsFileChooser,
59 &Show,
60 &GetNextChosenFile
61 };
62
63 } // namespace
64
65 FileChooser::FileChooser(PluginInstance* instance,
66 const PP_FileChooserOptions* options)
67 : Resource(instance->module()),
68 mode_(options->mode),
69 accept_mime_types_(options->accept_mime_types) {
70 }
71
72 FileChooser::~FileChooser() {
73 }
74
75 // static
76 const PPB_FileChooser* FileChooser::GetInterface() {
77 return &ppb_filechooser;
78 }
79
80 int32_t FileChooser::Show(PP_CompletionCallback callback) {
81 NOTIMPLEMENTED(); // TODO(darin): Implement me!
82 return PP_Error_Failed;
83 }
84
85 scoped_refptr<FileRef> FileChooser::GetNextChosenFile() {
86 NOTIMPLEMENTED(); // TODO(darin): Implement me!
87 return NULL;
88 }
89
90 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_file_chooser.h ('k') | webkit/glue/plugins/pepper_file_io.h » ('j') | no next file with comments »

Powered by Google App Engine