| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_PLUGIN_PLUGIN_CHANNEL_H_ | |
| 6 #define CHROME_PLUGIN_PLUGIN_CHANNEL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <vector> | |
| 10 #include "base/ref_counted.h" | |
| 11 #include "base/scoped_handle.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "chrome/plugin/plugin_channel_base.h" | |
| 14 #include "chrome/plugin/webplugin_delegate_stub.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class WaitableEvent; | |
| 18 } | |
| 19 | |
| 20 // Encapsulates an IPC channel between the plugin process and one renderer | |
| 21 // process. On the renderer side there's a corresponding PluginChannelHost. | |
| 22 class PluginChannel : public PluginChannelBase { | |
| 23 public: | |
| 24 // Get a new PluginChannel object for the current process to talk to the | |
| 25 // given renderer process. The renderer ID is an opaque unique ID generated | |
| 26 // by the browser. | |
| 27 static PluginChannel* GetPluginChannel(int renderer_id, | |
| 28 MessageLoop* ipc_message_loop); | |
| 29 | |
| 30 // Send a message to all renderers that the process is going to shutdown. | |
| 31 static void NotifyRenderersOfPendingShutdown(); | |
| 32 | |
| 33 virtual ~PluginChannel(); | |
| 34 | |
| 35 virtual bool Send(IPC::Message* msg); | |
| 36 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 37 | |
| 38 base::ProcessHandle renderer_handle() const { return renderer_handle_; } | |
| 39 int renderer_id() { return renderer_id_; } | |
| 40 | |
| 41 virtual int GenerateRouteID(); | |
| 42 | |
| 43 // Returns the event that's set when a call to the renderer causes a modal | |
| 44 // dialog to come up. | |
| 45 base::WaitableEvent* GetModalDialogEvent(gfx::NativeViewId containing_window); | |
| 46 | |
| 47 bool in_send() { return in_send_ != 0; } | |
| 48 | |
| 49 bool incognito() { return incognito_; } | |
| 50 void set_incognito(bool value) { incognito_ = value; } | |
| 51 | |
| 52 #if defined(OS_POSIX) | |
| 53 int renderer_fd() const { return channel_->GetClientFileDescriptor(); } | |
| 54 #endif | |
| 55 | |
| 56 protected: | |
| 57 // IPC::Channel::Listener implementation: | |
| 58 virtual void OnChannelConnected(int32 peer_pid); | |
| 59 virtual void OnChannelError(); | |
| 60 | |
| 61 virtual void CleanUp(); | |
| 62 | |
| 63 // Overrides PluginChannelBase::Init. | |
| 64 virtual bool Init(MessageLoop* ipc_message_loop, bool create_pipe_now); | |
| 65 | |
| 66 private: | |
| 67 class MessageFilter; | |
| 68 | |
| 69 // Called on the plugin thread | |
| 70 PluginChannel(); | |
| 71 | |
| 72 virtual bool OnControlMessageReceived(const IPC::Message& msg); | |
| 73 | |
| 74 static PluginChannelBase* ClassFactory() { return new PluginChannel(); } | |
| 75 | |
| 76 void OnCreateInstance(const std::string& mime_type, int* instance_id); | |
| 77 void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); | |
| 78 void OnGenerateRouteID(int* route_id); | |
| 79 void OnClearSiteData(const std::string& site, | |
| 80 uint64 flags, | |
| 81 base::Time begin_time); | |
| 82 | |
| 83 std::vector<scoped_refptr<WebPluginDelegateStub> > plugin_stubs_; | |
| 84 | |
| 85 // Handle to the renderer process who is on the other side of the channel. | |
| 86 base::ProcessHandle renderer_handle_; | |
| 87 | |
| 88 // The id of the renderer who is on the other side of the channel. | |
| 89 int renderer_id_; | |
| 90 | |
| 91 int in_send_; // Tracks if we're in a Send call. | |
| 92 bool log_messages_; // True if we should log sent and received messages. | |
| 93 bool incognito_; // True if the renderer is in incognito mode. | |
| 94 scoped_refptr<MessageFilter> filter_; // Handles the modal dialog events. | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(PluginChannel); | |
| 97 }; | |
| 98 | |
| 99 #endif // CHROME_PLUGIN_PLUGIN_CHANNEL_H_ | |
| OLD | NEW |