OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | 5 #include <windows.h> |
6 #include <objbase.h> | 6 #include <objbase.h> |
7 | 7 |
8 #include "chrome/plugin/plugin_thread.h" | 8 #include "chrome/plugin/plugin_thread.h" |
9 | 9 |
10 #include "chrome/common/chrome_plugin_lib.h" | 10 #include "chrome/common/chrome_plugin_lib.h" |
11 #include "chrome/common/ipc_logging.h" | 11 #include "chrome/common/ipc_logging.h" |
12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
13 #include "chrome/common/plugin_messages.h" | 13 #include "chrome/common/plugin_messages.h" |
14 #include "chrome/plugin/chrome_plugin_host.h" | 14 #include "chrome/plugin/chrome_plugin_host.h" |
15 #include "chrome/plugin/npobject_util.h" | 15 #include "chrome/plugin/npobject_util.h" |
16 #include "chrome/plugin/plugin_process.h" | 16 #include "chrome/plugin/plugin_process.h" |
| 17 #include "net/base/net_errors.h" |
17 #include "webkit/glue/plugins/plugin_lib.h" | 18 #include "webkit/glue/plugins/plugin_lib.h" |
18 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
19 | 20 |
20 PluginThread* PluginThread::plugin_thread_; | 21 PluginThread* PluginThread::plugin_thread_; |
21 | 22 |
22 PluginThread::PluginThread(PluginProcess* process, | 23 PluginThread::PluginThread(PluginProcess* process, |
23 const std::wstring& channel_name) | 24 const std::wstring& channel_name) |
24 : plugin_process_(process), | 25 : plugin_process_(process), |
25 channel_name_(channel_name), | 26 channel_name_(channel_name), |
26 owner_loop_(MessageLoop::current()), | 27 owner_loop_(MessageLoop::current()), |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 plugin_thread->Send( | 183 plugin_thread->Send( |
183 new PluginProcessHostMsg_GetPluginFinderUrl(plugin_finder_url)); | 184 new PluginProcessHostMsg_GetPluginFinderUrl(plugin_finder_url)); |
184 DCHECK(!plugin_finder_url->empty()); | 185 DCHECK(!plugin_finder_url->empty()); |
185 return true; | 186 return true; |
186 } | 187 } |
187 | 188 |
188 bool IsDefaultPluginEnabled() { | 189 bool IsDefaultPluginEnabled() { |
189 return true; | 190 return true; |
190 } | 191 } |
191 | 192 |
| 193 static int ResolveProxyFromPluginThread(const GURL& url, |
| 194 std::string* proxy_result) { |
| 195 int net_error; |
| 196 bool ipc_ok = PluginThread::GetPluginThread()->Send( |
| 197 new PluginProcessHostMsg_ResolveProxy(url, &net_error, proxy_result)); |
| 198 return ipc_ok ? net_error : net::ERR_UNEXPECTED; |
| 199 } |
| 200 |
| 201 extern int ResolveProxyFromRenderThread(const GURL&, std::string*); |
| 202 // Dispatch the resolve proxy resquest to the right code, depending on which |
| 203 // process the plugin is running in {renderer, browser, plugin}. |
| 204 // |
| 205 // TODO(eroman): Find a better place to put this; plugin_thread.cc isn't really |
| 206 // correct since this depends on the renderer thread. One solution is to save |
| 207 // the function pointers into a table during initialization. |
| 208 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) { |
| 209 int net_error; |
| 210 std::string proxy_result; |
| 211 |
| 212 if (PluginThread::GetPluginThread()) |
| 213 net_error = ResolveProxyFromPluginThread(url, &proxy_result); |
| 214 else |
| 215 net_error = ResolveProxyFromRenderThread(url, &proxy_result); |
| 216 |
| 217 if (net_error == net::OK) { |
| 218 *proxy_list = proxy_result; |
| 219 return true; // Success. |
| 220 } |
| 221 return false; // Fail. |
| 222 } |
| 223 |
192 } // namespace webkit_glue | 224 } // namespace webkit_glue |
193 | 225 |
OLD | NEW |