| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/message_channel.h" | 5 #include "content/renderer/pepper/message_channel.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "content/public/common/content_client.h" |
| 14 #include "content/public/renderer/content_renderer_client.h" |
| 13 #include "content/renderer/pepper/host_array_buffer_var.h" | 15 #include "content/renderer/pepper/host_array_buffer_var.h" |
| 14 #include "content/renderer/pepper/npapi_glue.h" | 16 #include "content/renderer/pepper/npapi_glue.h" |
| 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 17 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 16 #include "content/renderer/pepper/plugin_module.h" | 18 #include "content/renderer/pepper/plugin_module.h" |
| 17 #include "content/renderer/pepper/v8_var_converter.h" | 19 #include "content/renderer/pepper/v8_var_converter.h" |
| 18 #include "ppapi/shared_impl/ppapi_globals.h" | 20 #include "ppapi/shared_impl/ppapi_globals.h" |
| 19 #include "ppapi/shared_impl/scoped_pp_var.h" | 21 #include "ppapi/shared_impl/scoped_pp_var.h" |
| 20 #include "ppapi/shared_impl/var.h" | 22 #include "ppapi/shared_impl/var.h" |
| 21 #include "ppapi/shared_impl/var_tracker.h" | 23 #include "ppapi/shared_impl/var_tracker.h" |
| 22 #include "third_party/WebKit/public/web/WebBindings.h" | 24 #include "third_party/WebKit/public/web/WebBindings.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 71 |
| 70 // Return true iff |identifier| is equal to |string|. | 72 // Return true iff |identifier| is equal to |string|. |
| 71 bool IdentifierIs(NPIdentifier identifier, const char string[]) { | 73 bool IdentifierIs(NPIdentifier identifier, const char string[]) { |
| 72 return WebBindings::getStringIdentifier(string) == identifier; | 74 return WebBindings::getStringIdentifier(string) == identifier; |
| 73 } | 75 } |
| 74 | 76 |
| 75 bool HasDevChannelPermission(NPObject* channel_object) { | 77 bool HasDevChannelPermission(NPObject* channel_object) { |
| 76 MessageChannel* channel = ToMessageChannel(channel_object); | 78 MessageChannel* channel = ToMessageChannel(channel_object); |
| 77 if (!channel) | 79 if (!channel) |
| 78 return false; | 80 return false; |
| 79 return channel->instance()->module()->permissions().HasPermission( | 81 return GetContentClient()->renderer()->IsPluginAllowedToUseDevChannelAPIs(); |
| 80 ppapi::PERMISSION_DEV_CHANNEL); | |
| 81 } | 82 } |
| 82 | 83 |
| 83 //------------------------------------------------------------------------------ | 84 //------------------------------------------------------------------------------ |
| 84 // Implementations of NPClass functions. These are here to: | 85 // Implementations of NPClass functions. These are here to: |
| 85 // - Implement postMessage behavior. | 86 // - Implement postMessage behavior. |
| 86 // - Forward calls to the 'passthrough' object to allow backwards-compatibility | 87 // - Forward calls to the 'passthrough' object to allow backwards-compatibility |
| 87 // with GetInstanceObject() objects. | 88 // with GetInstanceObject() objects. |
| 88 //------------------------------------------------------------------------------ | 89 //------------------------------------------------------------------------------ |
| 89 NPObject* MessageChannelAllocate(NPP npp, NPClass* the_class) { | 90 NPObject* MessageChannelAllocate(NPP npp, NPClass* the_class) { |
| 90 return new MessageChannel::MessageChannelNPObject; | 91 return new MessageChannel::MessageChannelNPObject; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 return true; | 577 return true; |
| 577 } | 578 } |
| 578 return false; | 579 return false; |
| 579 } | 580 } |
| 580 | 581 |
| 581 void MessageChannel::SetReadOnlyProperty(PP_Var key, PP_Var value) { | 582 void MessageChannel::SetReadOnlyProperty(PP_Var key, PP_Var value) { |
| 582 internal_properties_[PPVarToNPIdentifier(key)] = ScopedPPVar(value); | 583 internal_properties_[PPVarToNPIdentifier(key)] = ScopedPPVar(value); |
| 583 } | 584 } |
| 584 | 585 |
| 585 } // namespace content | 586 } // namespace content |
| OLD | NEW |