[email protected] | cd0bd79 | 2012-04-14 00:52:16 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 3c5c6d8 | 2011-03-16 17:23:58 | [diff] [blame] | 5 | #ifndef CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
6 | #define CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
8 | #include <vector> | ||||
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
10 | #include "base/memory/scoped_handle.h" | ||||
[email protected] | 54724e2 | 2013-07-25 13:02:15 | [diff] [blame] | 11 | #include "base/process/process.h" |
[email protected] | 157e5d2 | 2009-04-23 18:43:35 | [diff] [blame] | 12 | #include "build/build_config.h" |
[email protected] | defa597a | 2013-07-19 02:22:13 | [diff] [blame] | 13 | #include "content/child/npapi/np_channel_base.h" |
[email protected] | 1673caf | 2013-11-12 20:15:54 | [diff] [blame] | 14 | #include "content/child/scoped_child_process_reference.h" |
[email protected] | 3c5c6d8 | 2011-03-16 17:23:58 | [diff] [blame] | 15 | #include "content/plugin/webplugin_delegate_stub.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | |
[email protected] | 8beff076 | 2009-09-29 02:18:30 | [diff] [blame] | 17 | namespace base { |
18 | class WaitableEvent; | ||||
19 | } | ||||
20 | |||||
[email protected] | 91355a8 | 2012-10-21 19:52:47 | [diff] [blame] | 21 | namespace content { |
22 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 23 | // Encapsulates an IPC channel between the plugin process and one renderer |
24 | // process. On the renderer side there's a corresponding PluginChannelHost. | ||||
[email protected] | 099587b7 | 2011-09-20 00:40:50 | [diff] [blame] | 25 | class PluginChannel : public NPChannelBase { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 26 | public: |
[email protected] | 76543b9 | 2009-08-31 17:27:45 | [diff] [blame] | 27 | // Get a new PluginChannel object for the current process to talk to the |
[email protected] | c84a785 | 2009-09-16 21:36:44 | [diff] [blame] | 28 | // given renderer process. The renderer ID is an opaque unique ID generated |
29 | // by the browser. | ||||
[email protected] | 92bf906 | 2011-05-02 18:00:49 | [diff] [blame] | 30 | static PluginChannel* GetPluginChannel( |
31 | int renderer_id, base::MessageLoopProxy* ipc_message_loop); | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 32 | |
[email protected] | 4e59e81 | 2010-04-06 20:51:16 | [diff] [blame] | 33 | // Send a message to all renderers that the process is going to shutdown. |
34 | static void NotifyRenderersOfPendingShutdown(); | ||||
35 | |||||
[email protected] | d84effeb | 2012-06-25 17:03:10 | [diff] [blame] | 36 | // IPC::Listener: |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 37 | virtual bool Send(IPC::Message* msg) OVERRIDE; |
38 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | ||||
[email protected] | 871da30 | 2012-05-11 19:30:55 | [diff] [blame] | 39 | virtual void OnChannelError() OVERRIDE; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 40 | |
[email protected] | c84a785 | 2009-09-16 21:36:44 | [diff] [blame] | 41 | int renderer_id() { return renderer_id_; } |
42 | |||||
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 43 | virtual int GenerateRouteID() OVERRIDE; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 44 | |
[email protected] | 8beff076 | 2009-09-29 02:18:30 | [diff] [blame] | 45 | // Returns the event that's set when a call to the renderer causes a modal |
46 | // dialog to come up. | ||||
[email protected] | c48de1a | 2012-11-02 19:06:56 | [diff] [blame] | 47 | virtual base::WaitableEvent* GetModalDialogEvent(int render_view_id) OVERRIDE; |
[email protected] | 8beff076 | 2009-09-29 02:18:30 | [diff] [blame] | 48 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 49 | bool in_send() { return in_send_ != 0; } |
50 | |||||
[email protected] | d5e4445 | 2011-03-10 18:12:10 | [diff] [blame] | 51 | bool incognito() { return incognito_; } |
52 | void set_incognito(bool value) { incognito_ = value; } | ||||
[email protected] | 3c8bd9f | 2009-03-26 19:40:29 | [diff] [blame] | 53 | |
[email protected] | 4a827847 | 2010-03-18 16:14:49 | [diff] [blame] | 54 | #if defined(OS_POSIX) |
[email protected] | 2ce26c43 | 2011-09-19 17:08:12 | [diff] [blame] | 55 | int TakeRendererFileDescriptor() { |
56 | return channel_->TakeClientFileDescriptor(); | ||||
57 | } | ||||
[email protected] | 4a827847 | 2010-03-18 16:14:49 | [diff] [blame] | 58 | #endif |
59 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 60 | protected: |
[email protected] | 871da30 | 2012-05-11 19:30:55 | [diff] [blame] | 61 | virtual ~PluginChannel(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | |
[email protected] | 871da30 | 2012-05-11 19:30:55 | [diff] [blame] | 63 | // NPChannelBase:: |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 64 | virtual void CleanUp() OVERRIDE; |
[email protected] | 92bf906 | 2011-05-02 18:00:49 | [diff] [blame] | 65 | virtual bool Init(base::MessageLoopProxy* ipc_message_loop, |
[email protected] | 4a9e852a | 2011-09-20 11:57:36 | [diff] [blame] | 66 | bool create_pipe_now, |
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 67 | base::WaitableEvent* shutdown_event) OVERRIDE; |
[email protected] | 3dfc7a4 | 2009-06-27 01:43:51 | [diff] [blame] | 68 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 69 | private: |
[email protected] | 8beff076 | 2009-09-29 02:18:30 | [diff] [blame] | 70 | class MessageFilter; |
71 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 72 | // Called on the plugin thread |
73 | PluginChannel(); | ||||
74 | |||||
[email protected] | edc64de | 2011-11-17 20:07:38 | [diff] [blame] | 75 | virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 76 | |
[email protected] | 099587b7 | 2011-09-20 00:40:50 | [diff] [blame] | 77 | static NPChannelBase* ClassFactory() { return new PluginChannel(); } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 78 | |
79 | void OnCreateInstance(const std::string& mime_type, int* instance_id); | ||||
80 | void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); | ||||
81 | void OnGenerateRouteID(int* route_id); | ||||
[email protected] | a4b146f | 2011-01-11 12:43:36 | [diff] [blame] | 82 | void OnClearSiteData(const std::string& site, |
83 | uint64 flags, | ||||
[email protected] | 1bf0fb2 | 2012-04-12 21:44:16 | [diff] [blame] | 84 | uint64 max_age); |
[email protected] | 93cabae | 2013-10-01 16:11:36 | [diff] [blame] | 85 | void OnDidAbortLoading(int render_view_id); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 86 | |
[email protected] | 157e5d2 | 2009-04-23 18:43:35 | [diff] [blame] | 87 | std::vector<scoped_refptr<WebPluginDelegateStub> > plugin_stubs_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 88 | |
[email protected] | 1673caf | 2013-11-12 20:15:54 | [diff] [blame] | 89 | ScopedChildProcessReference process_ref_; |
90 | |||||
[email protected] | c84a785 | 2009-09-16 21:36:44 | [diff] [blame] | 91 | // The id of the renderer who is on the other side of the channel. |
92 | int renderer_id_; | ||||
93 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 94 | int in_send_; // Tracks if we're in a Send call. |
[email protected] | 2fe8d191 | 2014-05-05 20:48:33 | [diff] [blame] | 95 | bool log_messages_; // True if we should log sent and received messages. |
[email protected] | d5e4445 | 2011-03-10 18:12:10 | [diff] [blame] | 96 | bool incognito_; // True if the renderer is in incognito mode. |
[email protected] | 8beff076 | 2009-09-29 02:18:30 | [diff] [blame] | 97 | scoped_refptr<MessageFilter> filter_; // Handles the modal dialog events. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 98 | |
[email protected] | a84bb146 | 2013-06-21 15:59:50 | [diff] [blame] | 99 | // Dummy NPP value used in the plugin process to represent entities other |
100 | // that other plugin instances for the purpose of object ownership tracking. | ||||
101 | scoped_ptr<struct _NPP> npp_; | ||||
102 | |||||
[email protected] | 4d818fee | 2010-06-06 13:32:27 | [diff] [blame] | 103 | DISALLOW_COPY_AND_ASSIGN(PluginChannel); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 104 | }; |
105 | |||||
[email protected] | 91355a8 | 2012-10-21 19:52:47 | [diff] [blame] | 106 | } // namespace content |
107 | |||||
[email protected] | 3c5c6d8 | 2011-03-16 17:23:58 | [diff] [blame] | 108 | #endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |