| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/plugin/plugin_thread.h" | 5 #include "chrome/plugin/plugin_thread.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(USE_X11) | 9 #if defined(USE_X11) |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| 11 #elif defined(OS_MACOSX) | 11 #elif defined(OS_MACOSX) |
| 12 #include <CoreFoundation/CoreFoundation.h> | 12 #include <CoreFoundation/CoreFoundation.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
| 19 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
| 21 #include "base/threading/thread_local.h" | 21 #include "base/threading/thread_local.h" |
| 22 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/plugin/npobject_util.h" | 22 #include "chrome/plugin/npobject_util.h" |
| 24 #include "chrome/renderer/render_thread.h" | 23 #include "chrome/renderer/render_thread.h" |
| 25 #include "content/common/child_process.h" | 24 #include "content/common/child_process.h" |
| 25 #include "content/common/content_client.h" |
| 26 #include "content/common/content_switches.h" |
| 26 #include "content/common/child_process_messages.h" | 27 #include "content/common/child_process_messages.h" |
| 27 #include "content/common/plugin_messages.h" | 28 #include "content/common/plugin_messages.h" |
| 28 #include "ipc/ipc_channel_handle.h" | 29 #include "ipc/ipc_channel_handle.h" |
| 29 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 30 #include "webkit/glue/webkit_glue.h" | 31 #include "webkit/glue/webkit_glue.h" |
| 31 #include "webkit/plugins/npapi/plugin_lib.h" | 32 #include "webkit/plugins/npapi/plugin_lib.h" |
| 32 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 33 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 33 | 34 |
| 34 #if defined(TOOLKIT_USES_GTK) | 35 #if defined(TOOLKIT_USES_GTK) |
| 35 #include "ui/gfx/gtk_util.h" | 36 #include "ui/gfx/gtk_util.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 #if defined(USE_X11) | 39 #if defined(USE_X11) |
| 39 #include "ui/base/x/x11_util.h" | 40 #include "ui/base/x/x11_util.h" |
| 40 #elif defined(OS_MACOSX) | |
| 41 #include "base/mac/mac_util.h" | |
| 42 #include "base/mac/scoped_cftyperef.h" | |
| 43 #include "base/sys_string_conversions.h" | |
| 44 #include "grit/chromium_strings.h" | |
| 45 #include "ui/base/l10n/l10n_util.h" | |
| 46 #endif | 41 #endif |
| 47 | 42 |
| 48 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( | 43 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( |
| 49 base::LINKER_INITIALIZED); | 44 base::LINKER_INITIALIZED); |
| 50 | 45 |
| 51 PluginThread::PluginThread() | 46 PluginThread::PluginThread() |
| 52 : preloaded_plugin_module_(NULL) { | 47 : preloaded_plugin_module_(NULL) { |
| 53 plugin_path_ = | 48 plugin_path_ = |
| 54 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 49 CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 55 switches::kPluginPath); | 50 switches::kPluginPath); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 77 ui::SetDefaultX11ErrorHandlers(); | 72 ui::SetDefaultX11ErrorHandlers(); |
| 78 #endif | 73 #endif |
| 79 | 74 |
| 80 PatchNPNFunctions(); | 75 PatchNPNFunctions(); |
| 81 | 76 |
| 82 // Preload the library to avoid loading, unloading then reloading | 77 // Preload the library to avoid loading, unloading then reloading |
| 83 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); | 78 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); |
| 84 | 79 |
| 85 scoped_refptr<webkit::npapi::PluginLib> plugin( | 80 scoped_refptr<webkit::npapi::PluginLib> plugin( |
| 86 webkit::npapi::PluginLib::CreatePluginLib(plugin_path_)); | 81 webkit::npapi::PluginLib::CreatePluginLib(plugin_path_)); |
| 87 if (plugin.get()) { | 82 if (plugin.get()) |
| 88 plugin->NP_Initialize(); | 83 plugin->NP_Initialize(); |
| 89 | 84 |
| 90 #if defined(OS_MACOSX) | 85 content::GetContentClient()->PluginProcessStarted( |
| 91 base::mac::ScopedCFTypeRef<CFStringRef> plugin_name( | 86 plugin.get() ? plugin->plugin_info().name : string16()); |
| 92 base::SysUTF16ToCFStringRef(plugin->plugin_info().name)); | |
| 93 base::mac::ScopedCFTypeRef<CFStringRef> app_name( | |
| 94 base::SysUTF16ToCFStringRef( | |
| 95 l10n_util::GetStringUTF16(IDS_SHORT_PLUGIN_APP_NAME))); | |
| 96 base::mac::ScopedCFTypeRef<CFStringRef> process_name( | |
| 97 CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ (%@)"), | |
| 98 plugin_name.get(), app_name.get())); | |
| 99 base::mac::SetProcessName(process_name); | |
| 100 #endif | |
| 101 } | |
| 102 | 87 |
| 103 // Certain plugins, such as flash, steal the unhandled exception filter | 88 // Certain plugins, such as flash, steal the unhandled exception filter |
| 104 // thus we never get crash reports when they fault. This call fixes it. | 89 // thus we never get crash reports when they fault. This call fixes it. |
| 105 message_loop()->set_exception_restoration(true); | 90 message_loop()->set_exception_restoration(true); |
| 106 } | 91 } |
| 107 | 92 |
| 108 PluginThread::~PluginThread() { | 93 PluginThread::~PluginThread() { |
| 109 if (preloaded_plugin_module_) { | 94 if (preloaded_plugin_module_) { |
| 110 base::UnloadNativeLibrary(preloaded_plugin_module_); | 95 base::UnloadNativeLibrary(preloaded_plugin_module_); |
| 111 preloaded_plugin_module_ = NULL; | 96 preloaded_plugin_module_ = NULL; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 bool result = ChildThread::current()->Send( | 185 bool result = ChildThread::current()->Send( |
| 201 new ChildProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result)); | 186 new ChildProcessHostMsg_ResolveProxy(url, &net_error, &proxy_result)); |
| 202 if (!result || net_error != net::OK) | 187 if (!result || net_error != net::OK) |
| 203 return false; | 188 return false; |
| 204 | 189 |
| 205 *proxy_list = proxy_result; | 190 *proxy_list = proxy_result; |
| 206 return true; | 191 return true; |
| 207 } | 192 } |
| 208 | 193 |
| 209 } // namespace webkit_glue | 194 } // namespace webkit_glue |
| OLD | NEW |