| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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 // A class that receives IPC messages from an NPObjectProxy and calls the real | |
| 6 // NPObject. | |
| 7 | |
| 8 #ifndef CHROME_PLUGIN_NPOBJECT_STUB_H_ | |
| 9 #define CHROME_PLUGIN_NPOBJECT_STUB_H_ | |
| 10 #pragma once | |
| 11 | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/ref_counted.h" | |
| 15 #include "base/weak_ptr.h" | |
| 16 #include "chrome/plugin/npobject_base.h" | |
| 17 #include "googleurl/src/gurl.h" | |
| 18 #include "ipc/ipc_channel.h" | |
| 19 #include "ui/gfx/native_widget_types.h" | |
| 20 | |
| 21 class PluginChannelBase; | |
| 22 struct NPIdentifier_Param; | |
| 23 struct NPObject; | |
| 24 struct NPVariant_Param; | |
| 25 | |
| 26 // This wraps an NPObject and converts IPC messages from NPObjectProxy to calls | |
| 27 // to the object. The results are marshalled back. See npobject_proxy.h for | |
| 28 // more information. | |
| 29 class NPObjectStub : public IPC::Channel::Listener, | |
| 30 public IPC::Message::Sender, | |
| 31 public base::SupportsWeakPtr<NPObjectStub>, | |
| 32 public NPObjectBase { | |
| 33 public: | |
| 34 NPObjectStub(NPObject* npobject, | |
| 35 PluginChannelBase* channel, | |
| 36 int route_id, | |
| 37 gfx::NativeViewId containing_window, | |
| 38 const GURL& page_url); | |
| 39 ~NPObjectStub(); | |
| 40 | |
| 41 // IPC::Message::Sender implementation: | |
| 42 virtual bool Send(IPC::Message* msg); | |
| 43 | |
| 44 // Called when the plugin widget that this NPObject came from is destroyed. | |
| 45 // This is needed because the renderer calls NPN_DeallocateObject on the | |
| 46 // window script object on destruction to avoid leaks. | |
| 47 void OnPluginDestroyed(); | |
| 48 | |
| 49 // NPObjectBase implementation. | |
| 50 virtual NPObject* GetUnderlyingNPObject(); | |
| 51 | |
| 52 virtual IPC::Channel::Listener* GetChannelListener(); | |
| 53 | |
| 54 private: | |
| 55 // IPC::Channel::Listener implementation: | |
| 56 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 57 virtual void OnChannelError(); | |
| 58 | |
| 59 // message handlers | |
| 60 void OnRelease(IPC::Message* reply_msg); | |
| 61 void OnHasMethod(const NPIdentifier_Param& name, | |
| 62 bool* result); | |
| 63 void OnInvoke(bool is_default, | |
| 64 const NPIdentifier_Param& method, | |
| 65 const std::vector<NPVariant_Param>& args, | |
| 66 IPC::Message* reply_msg); | |
| 67 void OnHasProperty(const NPIdentifier_Param& name, | |
| 68 bool* result); | |
| 69 void OnGetProperty(const NPIdentifier_Param& name, | |
| 70 NPVariant_Param* property, | |
| 71 bool* result); | |
| 72 void OnSetProperty(const NPIdentifier_Param& name, | |
| 73 const NPVariant_Param& property, | |
| 74 IPC::Message* reply_msg); | |
| 75 void OnRemoveProperty(const NPIdentifier_Param& name, | |
| 76 bool* result); | |
| 77 void OnInvalidate(); | |
| 78 void OnEnumeration(std::vector<NPIdentifier_Param>* value, | |
| 79 bool* result); | |
| 80 void OnConstruct(const std::vector<NPVariant_Param>& args, | |
| 81 IPC::Message* reply_msg); | |
| 82 void OnEvaluate(const std::string& script, bool popups_allowed, | |
| 83 IPC::Message* reply_msg); | |
| 84 | |
| 85 private: | |
| 86 NPObject* npobject_; | |
| 87 scoped_refptr<PluginChannelBase> channel_; | |
| 88 int route_id_; | |
| 89 gfx::NativeViewId containing_window_; | |
| 90 | |
| 91 // The url of the main frame hosting the plugin. | |
| 92 GURL page_url_; | |
| 93 }; | |
| 94 | |
| 95 #endif // CHROME_PLUGIN_NPOBJECT_STUB_H_ | |
| OLD | NEW |