summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 15:19:37 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-24 15:19:37 +0000
commitbbf076f18dbb27fba74de06f4994aa1480690ea3 (patch)
tree6dcabc6d408c997b18f8762fee0fac8470770fb4 /webkit/plugins/ppapi/ppb_file_chooser_impl.cc
parent081c03452bb7d97b138bed3ccc7cbe0903eae05c (diff)
downloadchromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.zip
chromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.tar.gz
chromium_src-bbf076f18dbb27fba74de06f4994aa1480690ea3.tar.bz2
Remove webkit::ppapi::Resource.
This makes all resource _impl's derive directly from ppapi::Resource so we can share code better. This means removing PluginInstances and converting them to PP_Instances. This adds a new ResourceHelper static class to help in the conversion of resources to PluginInstances for the _impl classes. Overall the new code is in general slightly worse than the old because using the ResourceHelper is more annoying than just calling instance() on the old webkit::ppapi::Resource object. However, I'm hoping that, because this will allow us to move more code into shared_impl and reduce duplicate logic, it will eventually have a net positive effect. This also adds a ScopedPPResource class that works just like a scoped_refptr. We need this in a few places. Most of the places that used the old ScopedResourceId class could be removed now since resources have PP_Resource IDs generated even when there's no plugin reference (this didn't use to be the case) so we can pass resources as input params to the plugin even when there's no plugin ref, as long as there's a scoped_refptr to the Resource. Review URL: http://codereview.chromium.org/7669055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_file_chooser_impl.cc')
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index 14f4784..c9c3e08 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -17,14 +17,14 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
+#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/resource_tracker.h"
-#include "webkit/glue/webkit_glue.h"
+#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::StringVar;
using ppapi::thunk::PPB_FileChooser_API;
@@ -63,7 +63,7 @@ class FileChooserCompletionImpl : public WebFileChooserCompletion {
} // namespace
PPB_FileChooser_Impl::PPB_FileChooser_Impl(
- PluginInstance* instance,
+ PP_Instance instance,
PP_FileChooserMode_Dev mode,
const PP_Var& accept_mime_types)
: Resource(instance),
@@ -79,7 +79,7 @@ PPB_FileChooser_Impl::~PPB_FileChooser_Impl() {
// static
PP_Resource PPB_FileChooser_Impl::Create(
- PluginInstance* instance,
+ PP_Instance instance,
PP_FileChooserMode_Dev mode,
const PP_Var& accept_mime_types) {
if (mode != PP_FILECHOOSERMODE_OPEN &&
@@ -110,7 +110,7 @@ void PPB_FileChooser_Impl::StoreChosenFiles(
#endif
chosen_files_.push_back(make_scoped_refptr(
- new PPB_FileRef_Impl(instance(), file_path)));
+ new PPB_FileRef_Impl(pp_instance(), file_path)));
}
RunCallback((chosen_files_.size() > 0) ? PP_OK : PP_ERROR_USERCANCEL);
@@ -133,8 +133,12 @@ void PPB_FileChooser_Impl::RegisterCallback(
DCHECK(callback.func);
DCHECK(!callback_.get() || callback_->completed());
- callback_ = new TrackedCompletionCallback(
- instance()->module()->GetCallbackTracker(), pp_resource(), callback);
+ PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
+ if (!plugin_module)
+ return;
+
+ callback_ = new TrackedCompletionCallback(plugin_module->GetCallbackTracker(),
+ pp_resource(), callback);
}
void PPB_FileChooser_Impl::RunCallback(int32_t result) {
@@ -156,8 +160,12 @@ int32_t PPB_FileChooser_Impl::Show(const PP_CompletionCallback& callback) {
params.acceptTypes = WebString::fromUTF8(accept_mime_types_);
params.directory = false;
- if (!instance()->delegate()->RunFileChooser(params,
- new FileChooserCompletionImpl(this)))
+ PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
+ if (!plugin_delegate)
+ return PP_ERROR_FAILED;
+
+ if (!plugin_delegate->RunFileChooser(params,
+ new FileChooserCompletionImpl(this)))
return PP_ERROR_FAILED;
RegisterCallback(callback);