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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/pepper_file_chooser.cc
===================================================================
--- webkit/glue/plugins/pepper_file_chooser.cc (revision 0)
+++ webkit/glue/plugins/pepper_file_chooser.cc (revision 0)
@@ -0,0 +1,90 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/glue/plugins/pepper_file_chooser.h"
+
+#include "base/logging.h"
+#include "third_party/ppapi/c/pp_completion_callback.h"
+#include "third_party/ppapi/c/pp_errors.h"
+#include "webkit/glue/plugins/pepper_file_ref.h"
+#include "webkit/glue/plugins/pepper_plugin_instance.h"
+#include "webkit/glue/plugins/pepper_resource_tracker.h"
+
+namespace pepper {
+
+namespace {
+
+PP_Resource Create(PP_Instance instance_id,
+ const PP_FileChooserOptions* options) {
+ PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
+ if (!instance)
+ return 0;
+
+ FileChooser* chooser = new FileChooser(instance, options);
+ chooser->AddRef(); // AddRef for the caller.
+ return chooser->GetResource();
+}
+
+bool IsFileChooser(PP_Resource resource) {
+ return !!ResourceTracker::Get()->GetAsFileChooser(resource).get();
+}
+
+int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) {
+ scoped_refptr<FileChooser> chooser(
+ ResourceTracker::Get()->GetAsFileChooser(chooser_id).get());
+ if (!chooser.get())
+ return PP_Error_BadResource;
+
+ return chooser->Show(callback);
+}
+
+PP_Resource GetNextChosenFile(PP_Resource chooser_id) {
+ scoped_refptr<FileChooser> chooser(
+ ResourceTracker::Get()->GetAsFileChooser(chooser_id).get());
+ if (!chooser.get())
+ return 0;
+
+ scoped_refptr<FileRef> file_ref(chooser->GetNextChosenFile());
+ if (!file_ref.get())
+ return 0;
+ file_ref->AddRef(); // AddRef for the caller.
+
+ return file_ref->GetResource();
+}
+
+const PPB_FileChooser ppb_filechooser = {
+ &Create,
+ &IsFileChooser,
+ &Show,
+ &GetNextChosenFile
+};
+
+} // namespace
+
+FileChooser::FileChooser(PluginInstance* instance,
+ const PP_FileChooserOptions* options)
+ : Resource(instance->module()),
+ mode_(options->mode),
+ accept_mime_types_(options->accept_mime_types) {
+}
+
+FileChooser::~FileChooser() {
+}
+
+// static
+const PPB_FileChooser* FileChooser::GetInterface() {
+ return &ppb_filechooser;
+}
+
+int32_t FileChooser::Show(PP_CompletionCallback callback) {
+ NOTIMPLEMENTED(); // TODO(darin): Implement me!
+ return PP_Error_Failed;
+}
+
+scoped_refptr<FileRef> FileChooser::GetNextChosenFile() {
+ NOTIMPLEMENTED(); // TODO(darin): Implement me!
+ return NULL;
+}
+
+} // namespace pepper
Property changes on: webkit\glue\plugins\pepper_file_chooser.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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
This is Rietveld 408576698