| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_instance_state_accessor_impl.h" | |
| 6 | |
| 7 #include "ppapi/shared_impl/ppapi_permissions.h" | |
| 8 #include "webkit/plugins/ppapi/host_globals.h" | |
| 9 #include "webkit/plugins/ppapi/plugin_module.h" | |
| 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | |
| 11 | |
| 12 using webkit::ppapi::HostGlobals; | |
| 13 using webkit::ppapi::PluginInstance; | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 PepperInstanceStateAccessorImpl::PepperInstanceStateAccessorImpl( | |
| 18 webkit::ppapi::PluginModule* module) | |
| 19 : module_(module) { | |
| 20 } | |
| 21 | |
| 22 PepperInstanceStateAccessorImpl::~PepperInstanceStateAccessorImpl() { | |
| 23 } | |
| 24 | |
| 25 bool PepperInstanceStateAccessorImpl::IsValidInstance(PP_Instance instance) { | |
| 26 return !!GetAndValidateInstance(instance); | |
| 27 } | |
| 28 | |
| 29 bool PepperInstanceStateAccessorImpl::HasUserGesture(PP_Instance pp_instance) { | |
| 30 PluginInstance* instance = GetAndValidateInstance(pp_instance); | |
| 31 if (!instance) | |
| 32 return false; | |
| 33 | |
| 34 if (instance->module()->permissions().HasPermission( | |
| 35 ppapi::PERMISSION_BYPASS_USER_GESTURE)) | |
| 36 return true; | |
| 37 return instance->IsProcessingUserGesture(); | |
| 38 } | |
| 39 | |
| 40 PluginInstance* PepperInstanceStateAccessorImpl::GetAndValidateInstance( | |
| 41 PP_Instance pp_instance) { | |
| 42 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); | |
| 43 if (!instance) | |
| 44 return NULL; | |
| 45 if (instance->module() != module_) | |
| 46 return NULL; | |
| 47 return instance; | |
| 48 } | |
| 49 | |
| 50 } // namespace content | |
| OLD | NEW |