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