summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/chrome_main.cc17
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc3
-rw-r--r--chrome/renderer/chrome_ppapi_interfaces.cc82
-rw-r--r--chrome/renderer/chrome_ppapi_interfaces.h18
-rw-r--r--chrome/renderer/chrome_renderer_glue.cc30
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rw-r--r--webkit/plugins/ppapi/ppapi_interface_factory.cc8
-rw-r--r--webkit/plugins/ppapi/ppapi_interface_factory.h4
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_nacl_private_impl.cc48
-rw-r--r--webkit/plugins/ppapi/ppb_nacl_private_impl.h21
-rw-r--r--webkit/tools/test_shell/test_shell.cc5
14 files changed, 125 insertions, 121 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index 20de46a..9614e56 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/i18n/icu_util.h"
+#include "base/lazy_instance.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/message_loop.h"
#include "base/metrics/stats_counters.h"
@@ -90,6 +91,14 @@
#include "chrome/app/breakpad_linux.h"
#endif
+#if !defined(NACL_WIN64) // We don't build the renderer code on win nacl64.
+base::LazyInstance<chrome::ChromeContentRendererClient>
+ g_chrome_content_renderer_client(base::LINKER_INITIALIZED);
+#endif // NACL_WIN64
+
+base::LazyInstance<chrome::ChromeContentPluginClient>
+ g_chrome_content_plugin_client(base::LINKER_INITIALIZED);
+
extern int BrowserMain(const MainFunctionParams&);
extern int RendererMain(const MainFunctionParams&);
extern int GpuMain(const MainFunctionParams&);
@@ -220,15 +229,15 @@ void EnableHeapProfiler(const CommandLine& command_line) {
void InitializeChromeContentRendererClient() {
#if !defined(NACL_WIN64) // We don't build the renderer code on win nacl64.
- static chrome::ChromeContentRendererClient chrome_content_renderer_client;
- content::GetContentClient()->set_renderer(&chrome_content_renderer_client);
+ content::GetContentClient()->set_renderer(
+ &g_chrome_content_renderer_client.Get());
#endif
}
void InitializeChromeContentClient(const std::string& process_type) {
if (process_type == switches::kPluginProcess) {
- static chrome::ChromeContentPluginClient chrome_content_plugin_client;
- content::GetContentClient()->set_plugin(&chrome_content_plugin_client);
+ content::GetContentClient()->set_plugin(
+ &g_chrome_content_plugin_client.Get());
} else if (process_type == switches::kRendererProcess ||
process_type == switches::kExtensionProcess) {
InitializeChromeContentRendererClient();
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index abc994f..17d8ae4 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -97,6 +97,8 @@
'renderer/blocked_plugin.h',
'renderer/chrome_content_renderer_client.cc',
'renderer/chrome_content_renderer_client.h',
+ 'renderer/chrome_ppapi_interfaces.cc',
+ 'renderer/chrome_ppapi_interfaces.h',
'renderer/chrome_render_process_observer.cc',
'renderer/chrome_render_process_observer.h',
'renderer/chrome_render_view_observer.cc',
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 9e6a913..70f45b0 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -28,6 +28,7 @@
#include "chrome/renderer/automation/automation_renderer_helper.h"
#include "chrome/renderer/automation/dom_automation_v8_extension.h"
#include "chrome/renderer/blocked_plugin.h"
+#include "chrome/renderer/chrome_ppapi_interfaces.h"
#include "chrome/renderer/chrome_render_process_observer.h"
#include "chrome/renderer/chrome_render_view_observer.h"
#include "chrome/renderer/content_settings_observer.h"
@@ -128,9 +129,11 @@ static void AppendParams(const std::vector<string16>& additional_names,
namespace chrome {
ChromeContentRendererClient::ChromeContentRendererClient() {
+ chrome::InitializePPAPI();
}
ChromeContentRendererClient::~ChromeContentRendererClient() {
+ chrome::UninitializePPAPI();
}
void ChromeContentRendererClient::RenderThreadStarted() {
diff --git a/chrome/renderer/chrome_ppapi_interfaces.cc b/chrome/renderer/chrome_ppapi_interfaces.cc
new file mode 100644
index 0000000..e57794c
--- /dev/null
+++ b/chrome/renderer/chrome_ppapi_interfaces.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/chrome_ppapi_interfaces.h"
+
+#include "base/logging.h"
+#include "base/rand_util_c.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/common/render_messages.h"
+#include "content/renderer/render_thread.h"
+#include "ppapi/c/private/ppb_nacl_private.h"
+#include "webkit/plugins/ppapi/ppapi_interface_factory.h"
+
+#if !defined(DISABLE_NACL)
+#include "native_client/src/shared/imc/nacl_imc.h"
+#include "native_client/src/trusted/plugin/nacl_entry_points.h"
+#endif
+
+namespace chrome {
+
+// Launch NaCl's sel_ldr process.
+bool LaunchSelLdr(const char* alleged_url, int socket_count,
+ void* imc_handles, void* nacl_process_handle,
+ int* nacl_process_id) {
+#if !defined(DISABLE_NACL)
+ std::vector<nacl::FileDescriptor> sockets;
+ base::ProcessHandle nacl_process;
+ if (!RenderThread::current()->Send(
+ new ViewHostMsg_LaunchNaCl(
+ ASCIIToWide(alleged_url),
+ socket_count,
+ &sockets,
+ &nacl_process,
+ reinterpret_cast<base::ProcessId*>(nacl_process_id)))) {
+ return false;
+ }
+ CHECK(static_cast<int>(sockets.size()) == socket_count);
+ for (int i = 0; i < socket_count; i++) {
+ static_cast<nacl::Handle*>(imc_handles)[i] =
+ nacl::ToNativeHandle(sockets[i]);
+ }
+ *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process;
+ return true;
+#else
+ return false;
+#endif
+}
+
+int UrandomFD(void) {
+#if defined(OS_POSIX)
+ return GetUrandomFD();
+#else
+ return 0;
+#endif
+}
+
+const PPB_NaCl_Private ppb_nacl = {
+ &LaunchSelLdr,
+ &UrandomFD,
+};
+
+const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) {
+ if (interface_name == PPB_NACL_PRIVATE_INTERFACE)
+ return &ppb_nacl;
+ return NULL;
+}
+
+void InitializePPAPI() {
+ webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager =
+ webkit::ppapi::PpapiInterfaceFactoryManager::GetInstance();
+ factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory);
+}
+
+void UninitializePPAPI() {
+ webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager =
+ webkit::ppapi::PpapiInterfaceFactoryManager::GetInstance();
+ factory_manager->UnregisterFactory(ChromePPAPIInterfaceFactory);
+}
+
+} // namespace chrome
+
diff --git a/chrome/renderer/chrome_ppapi_interfaces.h b/chrome/renderer/chrome_ppapi_interfaces.h
new file mode 100644
index 0000000..16b4c0c
--- /dev/null
+++ b/chrome/renderer/chrome_ppapi_interfaces.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_CHROME_PPAPI_INTERFACES_H_
+#define CHROME_RENDERER_CHROME_PPAPI_INTERFACES_H_
+#pragma once
+
+namespace chrome {
+
+// The following 2 functions perform Chrome specific initialzation/
+// uninitialization for PPAPI.
+void InitializePPAPI();
+void UninitializePPAPI();
+} // chrome
+
+#endif // CHROME_RENDERER_CHROME_PPAPI_INTERFACES_H_
+
diff --git a/chrome/renderer/chrome_renderer_glue.cc b/chrome/renderer/chrome_renderer_glue.cc
index 3533096b..da25659 100644
--- a/chrome/renderer/chrome_renderer_glue.cc
+++ b/chrome/renderer/chrome_renderer_glue.cc
@@ -7,16 +7,10 @@
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/render_messages.h"
#include "content/common/view_messages.h"
#include "content/renderer/render_thread.h"
#include "webkit/glue/webkit_glue.h"
-#if !defined(DISABLE_NACL)
-#include "native_client/src/shared/imc/nacl_imc.h"
-#include "native_client/src/trusted/plugin/nacl_entry_points.h"
-#endif
-
namespace webkit_glue {
void UserMetricsRecordAction(const std::string& action) {
@@ -32,28 +26,4 @@ std::string GetProductVersion() {
return product;
}
-#if !defined(DISABLE_NACL)
-bool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles,
- void* nacl_process_handle, int* nacl_process_id) {
- std::vector<nacl::FileDescriptor> sockets;
- base::ProcessHandle nacl_process;
- if (!RenderThread::current()->Send(
- new ViewHostMsg_LaunchNaCl(
- ASCIIToWide(alleged_url),
- socket_count,
- &sockets,
- &nacl_process,
- reinterpret_cast<base::ProcessId*>(nacl_process_id)))) {
- return false;
- }
- CHECK(static_cast<int>(sockets.size()) == socket_count);
- for (int i = 0; i < socket_count; i++) {
- static_cast<nacl::Handle*>(imc_handles)[i] =
- nacl::ToNativeHandle(sockets[i]);
- }
- *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process;
- return true;
-}
-#endif
-
} // namespace webkit_glue
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 0ee2ac0..92c071f 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -283,8 +283,6 @@
'../plugins/ppapi/ppb_image_data_impl.h',
'../plugins/ppapi/ppb_layer_compositor_impl.cc',
'../plugins/ppapi/ppb_layer_compositor_impl.h',
- '../plugins/ppapi/ppb_nacl_private_impl.cc',
- '../plugins/ppapi/ppb_nacl_private_impl.h',
'../plugins/ppapi/ppb_opengles_impl.cc',
'../plugins/ppapi/ppb_opengles_impl.h',
'../plugins/ppapi/ppb_pdf_impl.cc',
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 0f16cc1..23b127b 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -63,7 +63,6 @@
#include "ppapi/c/private/ppb_instance_private.h"
#include "ppapi/c/private/ppb_pdf.h"
#include "ppapi/c/private/ppb_proxy_private.h"
-#include "ppapi/c/private/ppb_nacl_private.h"
#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
@@ -90,7 +89,6 @@
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h"
-#include "webkit/plugins/ppapi/ppb_nacl_private_impl.h"
#include "webkit/plugins/ppapi/ppb_pdf_impl.h"
#include "webkit/plugins/ppapi/ppb_proxy_impl.h"
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
@@ -275,8 +273,6 @@ const void* GetInterface(const char* name) {
return ::ppapi::thunk::GetPPB_FileChooser_Thunk();
if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_FileIO_Thunk();
- if (strcmp(name, PPB_NACL_PRIVATE_INTERFACE) == 0)
- return PPB_NaCl_Private_Impl::GetInterface();
if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_FileIOTrusted_Thunk();
if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppapi_interface_factory.cc b/webkit/plugins/ppapi/ppapi_interface_factory.cc
index 587469a..629dca9 100644
--- a/webkit/plugins/ppapi/ppapi_interface_factory.cc
+++ b/webkit/plugins/ppapi/ppapi_interface_factory.cc
@@ -32,15 +32,15 @@ void PpapiInterfaceFactoryManager::UnregisterFactory(
FactoryList::iterator index =
std::find(interface_factory_list_.begin(), interface_factory_list_.end(),
factory);
- DCHECK(index != interface_factory_list_.end());
- interface_factory_list_.erase(index);
+ if (index != interface_factory_list_.end())
+ interface_factory_list_.erase(index);
}
-void* PpapiInterfaceFactoryManager::GetInterface(
+const void* PpapiInterfaceFactoryManager::GetInterface(
const std::string& interface_name) {
FactoryList::iterator index;
- void* ppapi_interface = NULL;
+ const void* ppapi_interface = NULL;
for (index = interface_factory_list_.begin();
index != interface_factory_list_.end();
diff --git a/webkit/plugins/ppapi/ppapi_interface_factory.h b/webkit/plugins/ppapi/ppapi_interface_factory.h
index 2950d92..d625f1e 100644
--- a/webkit/plugins/ppapi/ppapi_interface_factory.h
+++ b/webkit/plugins/ppapi/ppapi_interface_factory.h
@@ -18,7 +18,7 @@ namespace ppapi {
// factories.
class PpapiInterfaceFactoryManager {
public:
- typedef void* (InterfaceFactory)(const std::string& interface_name);
+ typedef const void* (InterfaceFactory)(const std::string& interface_name);
// Registers a custom PPAPI interface factory.
void RegisterFactory(InterfaceFactory* factory);
@@ -28,7 +28,7 @@ class PpapiInterfaceFactoryManager {
// Returns a pointer to the interface identified by the name passed in.
// Returns NULL if no factory handles this interface.
- void* GetInterface(const std::string& interface_name);
+ const void* GetInterface(const std::string& interface_name);
// Returns a pointer to the global instance of the
// PpapiInterfaceFactoryManager class.
diff --git a/webkit/plugins/ppapi/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc
index 025cb56..3a276cc 100644
--- a/webkit/plugins/ppapi/ppapi_unittest.cc
+++ b/webkit/plugins/ppapi/ppapi_unittest.cc
@@ -134,7 +134,7 @@ class PpapiCustomInterfaceFactoryTest
result_ = false;
}
- static void* InterfaceFactory(const std::string& interface_name) {
+ static const void* InterfaceFactory(const std::string& interface_name) {
result_ = true;
return NULL;
}
diff --git a/webkit/plugins/ppapi/ppb_nacl_private_impl.cc b/webkit/plugins/ppapi/ppb_nacl_private_impl.cc
deleted file mode 100644
index d14737e..0000000
--- a/webkit/plugins/ppapi/ppb_nacl_private_impl.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/plugins/ppapi/ppb_nacl_private_impl.h"
-
-#include "base/rand_util_c.h"
-#include "ppapi/c/private/ppb_nacl_private.h"
-#include "webkit/glue/webkit_glue.h"
-
-namespace webkit {
-namespace ppapi {
-
-namespace {
-
-bool LaunchSelLdr(const char* alleged_url, int socket_count,
- void* imc_handles, void* nacl_process_handle,
- int* nacl_process_id) {
-#if !defined(DISABLE_NACL)
- return webkit_glue::LaunchSelLdr(alleged_url, socket_count, imc_handles,
- nacl_process_handle, nacl_process_id);
-#else
- return false;
-#endif
-}
-
-int UrandomFD(void) {
-#if defined(OS_POSIX)
- return GetUrandomFD();
-#else
- return 0;
-#endif
-}
-
-} // namespace
-
-const PPB_NaCl_Private ppb_nacl = {
- &LaunchSelLdr,
- &UrandomFD,
-};
-
-// static
-const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() {
- return &ppb_nacl;
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_nacl_private_impl.h b/webkit/plugins/ppapi/ppb_nacl_private_impl.h
deleted file mode 100644
index 1c01e98..0000000
--- a/webkit/plugins/ppapi/ppb_nacl_private_impl.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_PLUGINS_PPAPI_PPB_NACL_PRIVATE_IMPL_H_
-#define WEBKIT_PLUGINS_PPAPI_PPB_NACL_PRIVATE_IMPL_H_
-
-struct PPB_NaCl_Private;
-
-namespace webkit {
-namespace ppapi {
-
-class PPB_NaCl_Private_Impl {
- public:
- static const PPB_NaCl_Private* GetInterface();
-};
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_PPB_NACL_PRIVATE_IMPL_H_
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 77a4523..5d31a4f 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -673,11 +673,6 @@ bool IsSingleProcess() {
return true;
}
-bool LaunchSelLdr(const char* alleged_url, int socket_count, void* imc_handles,
- void* nacl_process_handle, int* nacl_process_id) {
- return false;
-}
-
#if defined(OS_LINUX)
int MatchFontWithFallback(const std::string& face, bool bold,
bool italic, int charset) {