OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ | 5 #ifndef CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
6 #define CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ | 6 #define CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_handle.h" | 11 #include "base/memory/scoped_handle.h" |
(...skipping 17 matching lines...) Expand all Loading... |
29 int renderer_id, base::MessageLoopProxy* ipc_message_loop); | 29 int renderer_id, base::MessageLoopProxy* ipc_message_loop); |
30 | 30 |
31 // Send a message to all renderers that the process is going to shutdown. | 31 // Send a message to all renderers that the process is going to shutdown. |
32 static void NotifyRenderersOfPendingShutdown(); | 32 static void NotifyRenderersOfPendingShutdown(); |
33 | 33 |
34 virtual ~PluginChannel(); | 34 virtual ~PluginChannel(); |
35 | 35 |
36 virtual bool Send(IPC::Message* msg) OVERRIDE; | 36 virtual bool Send(IPC::Message* msg) OVERRIDE; |
37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
38 | 38 |
| 39 base::ProcessHandle renderer_handle() const { return renderer_handle_; } |
39 int renderer_id() { return renderer_id_; } | 40 int renderer_id() { return renderer_id_; } |
40 | 41 |
41 virtual int GenerateRouteID() OVERRIDE; | 42 virtual int GenerateRouteID() OVERRIDE; |
42 | 43 |
43 // Returns the event that's set when a call to the renderer causes a modal | 44 // Returns the event that's set when a call to the renderer causes a modal |
44 // dialog to come up. | 45 // dialog to come up. |
45 virtual base::WaitableEvent* GetModalDialogEvent( | 46 virtual base::WaitableEvent* GetModalDialogEvent( |
46 gfx::NativeViewId containing_window) OVERRIDE; | 47 gfx::NativeViewId containing_window) OVERRIDE; |
47 | 48 |
48 bool in_send() { return in_send_ != 0; } | 49 bool in_send() { return in_send_ != 0; } |
49 | 50 |
50 bool incognito() { return incognito_; } | 51 bool incognito() { return incognito_; } |
51 void set_incognito(bool value) { incognito_ = value; } | 52 void set_incognito(bool value) { incognito_ = value; } |
52 | 53 |
53 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
54 int TakeRendererFileDescriptor() { | 55 int TakeRendererFileDescriptor() { |
55 return channel_->TakeClientFileDescriptor(); | 56 return channel_->TakeClientFileDescriptor(); |
56 } | 57 } |
57 #endif | 58 #endif |
58 | 59 |
59 protected: | 60 protected: |
60 // IPC::Channel::Listener implementation: | 61 // IPC::Channel::Listener implementation: |
| 62 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
61 virtual void OnChannelError() OVERRIDE; | 63 virtual void OnChannelError() OVERRIDE; |
62 | 64 |
63 virtual void CleanUp() OVERRIDE; | 65 virtual void CleanUp() OVERRIDE; |
64 | 66 |
65 // Overrides NPChannelBase::Init. | 67 // Overrides NPChannelBase::Init. |
66 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, | 68 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, |
67 bool create_pipe_now, | 69 bool create_pipe_now, |
68 base::WaitableEvent* shutdown_event) OVERRIDE; | 70 base::WaitableEvent* shutdown_event) OVERRIDE; |
69 | 71 |
70 private: | 72 private: |
71 class MessageFilter; | 73 class MessageFilter; |
72 | 74 |
73 // Called on the plugin thread | 75 // Called on the plugin thread |
74 PluginChannel(); | 76 PluginChannel(); |
75 | 77 |
76 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; | 78 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE; |
77 | 79 |
78 static NPChannelBase* ClassFactory() { return new PluginChannel(); } | 80 static NPChannelBase* ClassFactory() { return new PluginChannel(); } |
79 | 81 |
80 void OnCreateInstance(const std::string& mime_type, int* instance_id); | 82 void OnCreateInstance(const std::string& mime_type, int* instance_id); |
81 void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); | 83 void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); |
82 void OnGenerateRouteID(int* route_id); | 84 void OnGenerateRouteID(int* route_id); |
83 void OnClearSiteData(const std::string& site, | 85 void OnClearSiteData(const std::string& site, |
84 uint64 flags, | 86 uint64 flags, |
85 base::Time begin_time); | 87 base::Time begin_time); |
86 | 88 |
87 std::vector<scoped_refptr<WebPluginDelegateStub> > plugin_stubs_; | 89 std::vector<scoped_refptr<WebPluginDelegateStub> > plugin_stubs_; |
88 | 90 |
| 91 // Handle to the renderer process who is on the other side of the channel. |
| 92 base::ProcessHandle renderer_handle_; |
| 93 |
89 // The id of the renderer who is on the other side of the channel. | 94 // The id of the renderer who is on the other side of the channel. |
90 int renderer_id_; | 95 int renderer_id_; |
91 | 96 |
92 int in_send_; // Tracks if we're in a Send call. | 97 int in_send_; // Tracks if we're in a Send call. |
93 bool log_messages_; // True if we should log sent and received messages. | 98 bool log_messages_; // True if we should log sent and received messages. |
94 bool incognito_; // True if the renderer is in incognito mode. | 99 bool incognito_; // True if the renderer is in incognito mode. |
95 scoped_refptr<MessageFilter> filter_; // Handles the modal dialog events. | 100 scoped_refptr<MessageFilter> filter_; // Handles the modal dialog events. |
96 | 101 |
97 DISALLOW_COPY_AND_ASSIGN(PluginChannel); | 102 DISALLOW_COPY_AND_ASSIGN(PluginChannel); |
98 }; | 103 }; |
99 | 104 |
100 #endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ | 105 #endif // CONTENT_PLUGIN_PLUGIN_CHANNEL_H_ |
OLD | NEW |