OLD | NEW |
1 // Copyright (c) 2011 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 #include "content/browser/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "content/browser/plugin_service.h" | 11 #include "content/browser/plugin_service.h" |
12 #include "content/browser/renderer_host/render_message_filter.h" | 12 #include "content/browser/renderer_host/render_message_filter.h" |
13 #include "content/common/content_switches.h" | 13 #include "content/common/content_switches.h" |
14 #include "content/common/pepper_plugin_registry.h" | 14 #include "content/common/pepper_plugin_registry.h" |
15 #include "ipc/ipc_switches.h" | 15 #include "ipc/ipc_switches.h" |
16 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
17 | 17 |
18 PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver) | 18 PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver) |
19 : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS), | 19 : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS), |
20 filter_(new PepperMessageFilter(host_resolver)) { | 20 filter_(new PepperMessageFilter(host_resolver)) { |
21 AddFilter(filter_.get()); | 21 AddFilter(filter_.get()); |
| 22 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
22 net::NetworkChangeNotifier::AddOnlineStateObserver(this); | 23 net::NetworkChangeNotifier::AddOnlineStateObserver(this); |
23 } | 24 } |
24 | 25 |
25 PpapiPluginProcessHost::~PpapiPluginProcessHost() { | 26 PpapiPluginProcessHost::~PpapiPluginProcessHost() { |
26 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); | 27 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); |
| 28 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
27 CancelRequests(); | 29 CancelRequests(); |
28 } | 30 } |
29 | 31 |
30 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { | 32 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { |
31 plugin_path_ = info.path; | 33 plugin_path_ = info.path; |
32 set_name(UTF8ToWide(info.name)); | 34 set_name(UTF8ToWide(info.name)); |
33 set_version(UTF8ToWide(info.version)); | 35 set_version(UTF8ToWide(info.version)); |
34 | 36 |
35 if (!CreateChannel()) | 37 if (!CreateChannel()) |
36 return false; | 38 return false; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 153 } |
152 pending_requests_.clear(); | 154 pending_requests_.clear(); |
153 | 155 |
154 while (!sent_requests_.empty()) { | 156 while (!sent_requests_.empty()) { |
155 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle, | 157 sent_requests_.front()->OnChannelOpened(base::kNullProcessHandle, |
156 IPC::ChannelHandle()); | 158 IPC::ChannelHandle()); |
157 sent_requests_.pop(); | 159 sent_requests_.pop(); |
158 } | 160 } |
159 } | 161 } |
160 | 162 |
| 163 void PpapiPluginProcessHost::OnIPAddressChanged() { |
| 164 // TODO(brettw) bug 90246: This doesn't seem correct. The online/offline |
| 165 // notification seems like it should be sufficient, but I don't see that when |
| 166 // I unplug and replug my network cable. Sending this notification when |
| 167 // "something" changes seems to make Flash reasonably happy, but seems wrong. |
| 168 // We should really be able to provide the real online state in |
| 169 // OnOnlineStateChanged(). |
| 170 Send(new PpapiMsg_SetNetworkState(true)); |
| 171 } |
| 172 |
161 void PpapiPluginProcessHost::OnOnlineStateChanged(bool online) { | 173 void PpapiPluginProcessHost::OnOnlineStateChanged(bool online) { |
162 Send(new PpapiMsg_SetNetworkState(online)); | 174 Send(new PpapiMsg_SetNetworkState(online)); |
163 } | 175 } |
164 | 176 |
165 // Called when a new plugin <--> renderer channel has been created. | 177 // Called when a new plugin <--> renderer channel has been created. |
166 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( | 178 void PpapiPluginProcessHost::OnRendererPluginChannelCreated( |
167 const IPC::ChannelHandle& channel_handle) { | 179 const IPC::ChannelHandle& channel_handle) { |
168 if (sent_requests_.empty()) | 180 if (sent_requests_.empty()) |
169 return; | 181 return; |
170 | 182 |
(...skipping 13 matching lines...) Expand all Loading... |
184 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, | 196 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, |
185 renderer_process, &renderers_plugin_handle, | 197 renderer_process, &renderers_plugin_handle, |
186 0, FALSE, DUPLICATE_SAME_ACCESS); | 198 0, FALSE, DUPLICATE_SAME_ACCESS); |
187 #elif defined(OS_POSIX) | 199 #elif defined(OS_POSIX) |
188 // Don't need to duplicate anything on POSIX since it's just a PID. | 200 // Don't need to duplicate anything on POSIX since it's just a PID. |
189 base::ProcessHandle renderers_plugin_handle = plugin_process; | 201 base::ProcessHandle renderers_plugin_handle = plugin_process; |
190 #endif | 202 #endif |
191 | 203 |
192 client->OnChannelOpened(renderers_plugin_handle, channel_handle); | 204 client->OnChannelOpened(renderers_plugin_handle, channel_handle); |
193 } | 205 } |
OLD | NEW |