| Index: content/renderer/pepper/content_instance_glue_impl.cc
|
| diff --git a/content/renderer/pepper/content_instance_glue_impl.cc b/content/renderer/pepper/content_instance_glue_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9680b3ab8e55883053d3fba72b63015761f2685a
|
| --- /dev/null
|
| +++ b/content/renderer/pepper/content_instance_glue_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/content_instance_glue_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 {
|
| +
|
| +ContentInstanceGlueImpl::ContentInstanceGlueImpl(
|
| + webkit::ppapi::PluginModule* module)
|
| + : module_(module) {
|
| +}
|
| +
|
| +ContentInstanceGlueImpl::~ContentInstanceGlueImpl() {
|
| +}
|
| +
|
| +bool ContentInstanceGlueImpl::IsValidInstance(PP_Instance instance) {
|
| + return !!GetAndValidateInstance(instance);
|
| +}
|
| +
|
| +bool ContentInstanceGlueImpl::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* ContentInstanceGlueImpl::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
|
|
|