blob: 75359449ff12e2b1c34e07396565c4c78adb859b [file] [log] [blame]
[email protected]cd0bd792012-04-14 00:52:161// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]3c5c6d82011-03-16 17:23:585#ifndef CONTENT_PLUGIN_PLUGIN_CHANNEL_H_
6#define CONTENT_PLUGIN_PLUGIN_CHANNEL_H_
initial.commit09911bf2008-07-26 23:55:297
8#include <vector>
[email protected]3b63f8f42011-03-28 01:54:159#include "base/memory/ref_counted.h"
10#include "base/memory/scoped_handle.h"
[email protected]54724e22013-07-25 13:02:1511#include "base/process/process.h"
[email protected]157e5d22009-04-23 18:43:3512#include "build/build_config.h"
[email protected]defa597a2013-07-19 02:22:1313#include "content/child/npapi/np_channel_base.h"
[email protected]1673caf2013-11-12 20:15:5414#include "content/child/scoped_child_process_reference.h"
[email protected]3c5c6d82011-03-16 17:23:5815#include "content/plugin/webplugin_delegate_stub.h"
initial.commit09911bf2008-07-26 23:55:2916
[email protected]8beff0762009-09-29 02:18:3017namespace base {
18class WaitableEvent;
19}
20
[email protected]91355a82012-10-21 19:52:4721namespace content {
22
initial.commit09911bf2008-07-26 23:55:2923// Encapsulates an IPC channel between the plugin process and one renderer
24// process. On the renderer side there's a corresponding PluginChannelHost.
[email protected]099587b72011-09-20 00:40:5025class PluginChannel : public NPChannelBase {
initial.commit09911bf2008-07-26 23:55:2926 public:
[email protected]76543b92009-08-31 17:27:4527 // Get a new PluginChannel object for the current process to talk to the
[email protected]c84a7852009-09-16 21:36:4428 // given renderer process. The renderer ID is an opaque unique ID generated
29 // by the browser.
[email protected]92bf9062011-05-02 18:00:4930 static PluginChannel* GetPluginChannel(
31 int renderer_id, base::MessageLoopProxy* ipc_message_loop);
initial.commit09911bf2008-07-26 23:55:2932
[email protected]4e59e812010-04-06 20:51:1633 // Send a message to all renderers that the process is going to shutdown.
34 static void NotifyRenderersOfPendingShutdown();
35
[email protected]d84effeb2012-06-25 17:03:1036 // IPC::Listener:
[email protected]edc64de2011-11-17 20:07:3837 virtual bool Send(IPC::Message* msg) OVERRIDE;
38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
[email protected]871da302012-05-11 19:30:5539 virtual void OnChannelError() OVERRIDE;
initial.commit09911bf2008-07-26 23:55:2940
[email protected]c84a7852009-09-16 21:36:4441 int renderer_id() { return renderer_id_; }
42
[email protected]edc64de2011-11-17 20:07:3843 virtual int GenerateRouteID() OVERRIDE;
initial.commit09911bf2008-07-26 23:55:2944
[email protected]8beff0762009-09-29 02:18:3045 // Returns the event that's set when a call to the renderer causes a modal
46 // dialog to come up.
[email protected]c48de1a2012-11-02 19:06:5647 virtual base::WaitableEvent* GetModalDialogEvent(int render_view_id) OVERRIDE;
[email protected]8beff0762009-09-29 02:18:3048
initial.commit09911bf2008-07-26 23:55:2949 bool in_send() { return in_send_ != 0; }
50
[email protected]d5e44452011-03-10 18:12:1051 bool incognito() { return incognito_; }
52 void set_incognito(bool value) { incognito_ = value; }
[email protected]3c8bd9f2009-03-26 19:40:2953
[email protected]4a8278472010-03-18 16:14:4954#if defined(OS_POSIX)
[email protected]2ce26c432011-09-19 17:08:1255 int TakeRendererFileDescriptor() {
56 return channel_->TakeClientFileDescriptor();
57 }
[email protected]4a8278472010-03-18 16:14:4958#endif
59
initial.commit09911bf2008-07-26 23:55:2960 protected:
[email protected]871da302012-05-11 19:30:5561 virtual ~PluginChannel();
initial.commit09911bf2008-07-26 23:55:2962
[email protected]871da302012-05-11 19:30:5563 // NPChannelBase::
[email protected]edc64de2011-11-17 20:07:3864 virtual void CleanUp() OVERRIDE;
[email protected]92bf9062011-05-02 18:00:4965 virtual bool Init(base::MessageLoopProxy* ipc_message_loop,
[email protected]4a9e852a2011-09-20 11:57:3666 bool create_pipe_now,
[email protected]edc64de2011-11-17 20:07:3867 base::WaitableEvent* shutdown_event) OVERRIDE;
[email protected]3dfc7a42009-06-27 01:43:5168
initial.commit09911bf2008-07-26 23:55:2969 private:
[email protected]8beff0762009-09-29 02:18:3070 class MessageFilter;
71
initial.commit09911bf2008-07-26 23:55:2972 // Called on the plugin thread
73 PluginChannel();
74
[email protected]edc64de2011-11-17 20:07:3875 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
initial.commit09911bf2008-07-26 23:55:2976
[email protected]099587b72011-09-20 00:40:5077 static NPChannelBase* ClassFactory() { return new PluginChannel(); }
initial.commit09911bf2008-07-26 23:55:2978
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]a4b146f2011-01-11 12:43:3682 void OnClearSiteData(const std::string& site,
83 uint64 flags,
[email protected]1bf0fb22012-04-12 21:44:1684 uint64 max_age);
[email protected]93cabae2013-10-01 16:11:3685 void OnDidAbortLoading(int render_view_id);
initial.commit09911bf2008-07-26 23:55:2986
[email protected]157e5d22009-04-23 18:43:3587 std::vector<scoped_refptr<WebPluginDelegateStub> > plugin_stubs_;
initial.commit09911bf2008-07-26 23:55:2988
[email protected]1673caf2013-11-12 20:15:5489 ScopedChildProcessReference process_ref_;
90
[email protected]c84a7852009-09-16 21:36:4491 // The id of the renderer who is on the other side of the channel.
92 int renderer_id_;
93
initial.commit09911bf2008-07-26 23:55:2994 int in_send_; // Tracks if we're in a Send call.
[email protected]2fe8d1912014-05-05 20:48:3395 bool log_messages_; // True if we should log sent and received messages.
[email protected]d5e44452011-03-10 18:12:1096 bool incognito_; // True if the renderer is in incognito mode.
[email protected]8beff0762009-09-29 02:18:3097 scoped_refptr<MessageFilter> filter_; // Handles the modal dialog events.
initial.commit09911bf2008-07-26 23:55:2998
[email protected]a84bb1462013-06-21 15:59:5099 // 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]4d818fee2010-06-06 13:32:27103 DISALLOW_COPY_AND_ASSIGN(PluginChannel);
initial.commit09911bf2008-07-26 23:55:29104};
105
[email protected]91355a82012-10-21 19:52:47106} // namespace content
107
[email protected]3c5c6d82011-03-16 17:23:58108#endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_H_