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

Side by Side Diff: chrome/plugin/npobject_stub.h

Issue 258026: Fix scripting during NPP_Destroy. Note that if the plugin is making a call t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/plugin/npobject_stub.cc » ('j') | chrome/plugin/npobject_stub.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 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 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 // A class that receives IPC messages from an NPObjectProxy and calls the real 5 // A class that receives IPC messages from an NPObjectProxy and calls the real
6 // NPObject. 6 // NPObject.
7 7
8 #ifndef CHROME_PLUGIN_NPOBJECT_STUB_H_ 8 #ifndef CHROME_PLUGIN_NPOBJECT_STUB_H_
9 #define CHROME_PLUGIN_NPOBJECT_STUB_H_ 9 #define CHROME_PLUGIN_NPOBJECT_STUB_H_
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/gfx/native_widget_types.h" 13 #include "base/gfx/native_widget_types.h"
14 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
15 #include "base/weak_ptr.h"
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
16 #include "ipc/ipc_channel.h" 17 #include "ipc/ipc_channel.h"
17 18
18 class PluginChannelBase; 19 class PluginChannelBase;
19 class WebPluginDelegateProxy;
20 struct NPIdentifier_Param; 20 struct NPIdentifier_Param;
21 struct NPObject; 21 struct NPObject;
22 struct NPVariant_Param; 22 struct NPVariant_Param;
23 23
24 // This wraps an NPObject and converts IPC messages from NPObjectProxy to calls 24 // This wraps an NPObject and converts IPC messages from NPObjectProxy to calls
25 // to the object. The results are marshalled back. See npobject_proxy.h for 25 // to the object. The results are marshalled back. See npobject_proxy.h for
26 // more information. 26 // more information.
27 class NPObjectStub : public IPC::Channel::Listener, 27 class NPObjectStub : public IPC::Channel::Listener,
28 public IPC::Message::Sender { 28 public IPC::Message::Sender,
29 public base::SupportsWeakPtr<NPObjectStub> {
29 public: 30 public:
30 NPObjectStub(NPObject* npobject, 31 NPObjectStub(NPObject* npobject,
31 PluginChannelBase* channel, 32 PluginChannelBase* channel,
32 int route_id, 33 int route_id,
33 gfx::NativeViewId containing_window, 34 gfx::NativeViewId containing_window,
34 const GURL& page_url); 35 const GURL& page_url);
35 ~NPObjectStub(); 36 ~NPObjectStub();
36 37
37 // IPC::Message::Sender implementation: 38 // IPC::Message::Sender implementation:
38 bool Send(IPC::Message* msg); 39 bool Send(IPC::Message* msg);
39 40
40 // Called when the plugin widget that this NPObject came from is destroyed. 41 // Called when the plugin widget that this NPObject came from is destroyed.
41 // This is needed because the renderer calls NPN_DeallocateObject on the 42 // This is needed because the renderer calls NPN_DeallocateObject on the
42 // window script object on destruction to avoid leaks. 43 // window script object on destruction to avoid leaks.
43 void set_invalid() { valid_ = false; } 44 void OnPluginDestroyed();
44 void set_proxy(WebPluginDelegateProxy* proxy) {
45 web_plugin_delegate_proxy_ = proxy;
46 }
47 45
48 private: 46 private:
49 // IPC::Channel::Listener implementation: 47 // IPC::Channel::Listener implementation:
50 void OnMessageReceived(const IPC::Message& message); 48 void OnMessageReceived(const IPC::Message& message);
51 void OnChannelError(); 49 void OnChannelError();
52 50
53 // message handlers 51 // message handlers
54 void OnRelease(IPC::Message* reply_msg); 52 void OnRelease(IPC::Message* reply_msg);
55 void OnHasMethod(const NPIdentifier_Param& name, 53 void OnHasMethod(const NPIdentifier_Param& name,
56 bool* result); 54 bool* result);
(...skipping 17 matching lines...) Expand all
74 void OnConstruct(const std::vector<NPVariant_Param>& args, 72 void OnConstruct(const std::vector<NPVariant_Param>& args,
75 IPC::Message* reply_msg); 73 IPC::Message* reply_msg);
76 void OnEvaluate(const std::string& script, bool popups_allowed, 74 void OnEvaluate(const std::string& script, bool popups_allowed,
77 IPC::Message* reply_msg); 75 IPC::Message* reply_msg);
78 void OnSetException(const std::string& message); 76 void OnSetException(const std::string& message);
79 77
80 private: 78 private:
81 NPObject* npobject_; 79 NPObject* npobject_;
82 scoped_refptr<PluginChannelBase> channel_; 80 scoped_refptr<PluginChannelBase> channel_;
83 int route_id_; 81 int route_id_;
84
85 // These variables are used to ensure that the window script object is not
86 // called after the plugin widget has gone away, as the frame manually
87 // deallocates it and ignores the refcount to avoid leaks.
88 bool valid_;
89 WebPluginDelegateProxy* web_plugin_delegate_proxy_;
90
91 gfx::NativeViewId containing_window_; 82 gfx::NativeViewId containing_window_;
92 83
93 // The url of the main frame hosting the plugin. 84 // The url of the main frame hosting the plugin.
94 GURL page_url_; 85 GURL page_url_;
95 }; 86 };
96 87
97 #endif // CHROME_PLUGIN_NPOBJECT_STUB_H_ 88 #endif // CHROME_PLUGIN_NPOBJECT_STUB_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/plugin/npobject_stub.cc » ('j') | chrome/plugin/npobject_stub.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698