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

Unified Diff: content/renderer/pepper/pepper_instance_state_accessor_impl.cc

Issue 10544089: Implement the file chooser as a new resource "host" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
Index: content/renderer/pepper/pepper_instance_state_accessor_impl.cc
diff --git a/content/renderer/pepper/pepper_instance_state_accessor_impl.cc b/content/renderer/pepper/pepper_instance_state_accessor_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..376d3aa89af5c54d8d7683db19ce591769e082fc
--- /dev/null
+++ b/content/renderer/pepper/pepper_instance_state_accessor_impl.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 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 "content/renderer/pepper/pepper_instance_state_accessor_impl.h"
+
+#include "ppapi/shared_impl/ppapi_permissions.h"
+#include "webkit/plugins/ppapi/host_globals.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+
+using webkit::ppapi::HostGlobals;
+using webkit::ppapi::PluginInstance;
+
+namespace content {
+
+PepperInstanceStateAccessorImpl::PepperInstanceStateAccessorImpl(
+ webkit::ppapi::PluginModule* module)
+ : module_(module) {
+}
+
+PepperInstanceStateAccessorImpl::~PepperInstanceStateAccessorImpl() {
+}
+
+bool PepperInstanceStateAccessorImpl::IsValidInstance(PP_Instance instance) {
+ return !!GetAndValidateInstance(instance);
+}
+
+bool PepperInstanceStateAccessorImpl::HasUserGesture(PP_Instance pp_instance) {
+ PluginInstance* instance = GetAndValidateInstance(pp_instance);
+ if (!instance)
+ return false;
+
+ if (instance->module()->permissions().HasPermission(
+ ppapi::PERMISSION_BYPASS_USER_GESTURE))
+ return true;
+ return instance->IsProcessingUserGesture();
+}
+
+PluginInstance* PepperInstanceStateAccessorImpl::GetAndValidateInstance(
+ PP_Instance pp_instance) {
+ PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
+ if (!instance)
+ return NULL;
+ if (instance->module() != module_)
+ return NULL;
+ return instance;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698