Separate NaCl messages from the rest of chrome messages and create a new message filter. This is part of an effort to componentize NaCl code.
BUG=244791
Review URL: https://chromiumcodereview.appspot.com/15906013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206855 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index b1802c1a..6aba761 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -46,6 +46,7 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
+#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
@@ -746,6 +747,10 @@
#if defined(ENABLE_WEBRTC)
host->GetChannel()->AddFilter(new WebRtcLoggingHandlerHost());
#endif
+#if !defined(DISABLE_NACL)
+ host->GetChannel()->AddFilter(new NaClHostMessageFilter(id, profile,
+ context));
+#endif
host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
profile->IsOffTheRecord()));
diff --git a/chrome/browser/nacl_host/nacl_file_host.cc b/chrome/browser/nacl_host/nacl_file_host.cc
index 67d1a397..788876e3 100644
--- a/chrome/browser/nacl_host/nacl_file_host.cc
+++ b/chrome/browser/nacl_host/nacl_file_host.cc
@@ -13,10 +13,10 @@
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
-#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
+#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
-#include "chrome/common/render_messages.h"
+#include "chrome/common/nacl_host_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
@@ -35,10 +35,10 @@
const size_t kMaxFileLength = 40;
void NotifyRendererOfError(
- ChromeRenderMessageFilter* chrome_render_message_filter,
+ NaClHostMessageFilter* nacl_host_message_filter,
IPC::Message* reply_msg) {
reply_msg->set_reply_error();
- chrome_render_message_filter->Send(reply_msg);
+ nacl_host_message_filter->Send(reply_msg);
}
bool PnaclDoOpenFile(const base::FilePath& file_to_open,
@@ -56,7 +56,7 @@
}
void DoOpenPnaclFile(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
const std::string& filename,
IPC::Message* reply_msg) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
@@ -64,13 +64,13 @@
// Do some validation.
if (!nacl_file_host::PnaclCanOpenFile(filename, &full_filepath)) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
base::PlatformFile file_to_open;
if (!PnaclDoOpenFile(full_filepath, &file_to_open)) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
@@ -78,25 +78,25 @@
// Do any DuplicateHandle magic that is necessary first.
IPC::PlatformFileForTransit target_desc =
IPC::GetFileHandleForProcess(file_to_open,
- chrome_render_message_filter->peer_handle(),
+ nacl_host_message_filter->peer_handle(),
true /* Close source */);
if (target_desc == IPC::InvalidPlatformFileForTransit()) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
- ChromeViewHostMsg_GetReadonlyPnaclFD::WriteReplyParams(
+ NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams(
reply_msg, target_desc);
- chrome_render_message_filter->Send(reply_msg);
+ nacl_host_message_filter->Send(reply_msg);
}
void DoCreateTemporaryFile(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
IPC::Message* reply_msg) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
base::FilePath file_path;
if (!file_util::CreateTemporaryFile(&file_path)) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
@@ -109,7 +109,7 @@
NULL, &error);
if (error != base::PLATFORM_FILE_OK) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
@@ -117,20 +117,20 @@
// Do any DuplicateHandle magic that is necessary first.
IPC::PlatformFileForTransit target_desc =
IPC::GetFileHandleForProcess(file_handle,
- chrome_render_message_filter->peer_handle(),
+ nacl_host_message_filter->peer_handle(),
true);
if (target_desc == IPC::InvalidPlatformFileForTransit()) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
- ChromeViewHostMsg_NaClCreateTemporaryFile::WriteReplyParams(
+ NaClHostMsg_NaClCreateTemporaryFile::WriteReplyParams(
reply_msg, target_desc);
- chrome_render_message_filter->Send(reply_msg);
+ nacl_host_message_filter->Send(reply_msg);
}
void DoRegisterOpenedNaClExecutableFile(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
base::PlatformFile file,
base::FilePath file_path,
IPC::Message* reply_msg) {
@@ -138,18 +138,18 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
- uint64_t file_token_lo = 0;
- uint64_t file_token_hi = 0;
+ uint64 file_token_lo = 0;
+ uint64 file_token_hi = 0;
nacl_browser->PutFilePath(file_path, &file_token_lo, &file_token_hi);
IPC::PlatformFileForTransit file_desc = IPC::GetFileHandleForProcess(
file,
- chrome_render_message_filter->peer_handle(),
+ nacl_host_message_filter->peer_handle(),
true /* close_source */);
- ChromeViewHostMsg_OpenNaClExecutable::WriteReplyParams(
+ NaClHostMsg_OpenNaClExecutable::WriteReplyParams(
reply_msg, file_desc, file_token_lo, file_token_hi);
- chrome_render_message_filter->Send(reply_msg);
+ nacl_host_message_filter->Send(reply_msg);
}
// Convert the file URL into a file path in the extension directory.
@@ -206,7 +206,7 @@
// This function is security sensitive. Be sure to check with a security
// person before you modify it.
void DoOpenNaClExecutableOnThreadPool(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
scoped_refptr<ExtensionInfoMap> extension_info_map,
const GURL& file_url,
IPC::Message* reply_msg) {
@@ -214,7 +214,7 @@
base::FilePath file_path;
if (!GetExtensionFilePath(extension_info_map, file_url, &file_path)) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
@@ -227,10 +227,10 @@
BrowserThread::IO, FROM_HERE,
base::Bind(
&DoRegisterOpenedNaClExecutableFile,
- chrome_render_message_filter,
+ nacl_host_message_filter,
file, file_path, reply_msg));
} else {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
}
@@ -240,16 +240,16 @@
namespace nacl_file_host {
void GetReadonlyPnaclFd(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
const std::string& filename,
IPC::Message* reply_msg) {
if (!BrowserThread::PostBlockingPoolTask(
FROM_HERE,
base::Bind(&DoOpenPnaclFile,
- chrome_render_message_filter,
+ nacl_host_message_filter,
filename,
reply_msg))) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
}
}
@@ -287,19 +287,19 @@
}
void CreateTemporaryFile(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
IPC::Message* reply_msg) {
if (!BrowserThread::PostBlockingPoolTask(
FROM_HERE,
base::Bind(&DoCreateTemporaryFile,
- chrome_render_message_filter,
+ nacl_host_message_filter,
reply_msg))) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
}
}
void OpenNaClExecutable(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
scoped_refptr<ExtensionInfoMap> extension_info_map,
int render_view_id,
const GURL& file_url,
@@ -309,7 +309,7 @@
BrowserThread::UI, FROM_HERE,
base::Bind(
&OpenNaClExecutable,
- chrome_render_message_filter,
+ nacl_host_message_filter,
extension_info_map,
render_view_id, file_url, reply_msg));
return;
@@ -319,16 +319,16 @@
// render view's site. Without these checks, apps could probe the extension
// directory or run NaCl code from other extensions.
content::RenderViewHost* rvh = content::RenderViewHost::FromID(
- chrome_render_message_filter->render_process_id(), render_view_id);
+ nacl_host_message_filter->render_process_id(), render_view_id);
if (!rvh) {
- chrome_render_message_filter->BadMessageReceived(); // Kill the renderer.
+ nacl_host_message_filter->BadMessageReceived(); // Kill the renderer.
return;
}
content::SiteInstance* site_instance = rvh->GetSiteInstance();
if (!content::SiteInstance::IsSameWebSite(site_instance->GetBrowserContext(),
site_instance->GetSiteURL(),
file_url)) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
return;
}
@@ -339,10 +339,10 @@
FROM_HERE,
base::Bind(
&DoOpenNaClExecutableOnThreadPool,
- chrome_render_message_filter,
+ nacl_host_message_filter,
extension_info_map,
file_url, reply_msg))) {
- NotifyRendererOfError(chrome_render_message_filter.get(), reply_msg);
+ NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg);
}
}
diff --git a/chrome/browser/nacl_host/nacl_file_host.h b/chrome/browser/nacl_host/nacl_file_host.h
index 2dba7934..3491688ba 100644
--- a/chrome/browser/nacl_host/nacl_file_host.h
+++ b/chrome/browser/nacl_host/nacl_file_host.h
@@ -9,9 +9,9 @@
#include "base/memory/ref_counted.h"
-class ChromeRenderMessageFilter;
class ExtensionInfoMap;
class GURL;
+class NaClHostMessageFilter;
namespace base {
class FilePath;
@@ -27,7 +27,7 @@
// Open a Pnacl file (readonly) on behalf of the NaCl plugin.
void GetReadonlyPnaclFd(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
const std::string& filename,
IPC::Message* reply_msg);
@@ -39,12 +39,12 @@
// Creates a temporary file that will be deleted when the last handle
// is closed, or earlier.
void CreateTemporaryFile(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
IPC::Message* reply_msg);
// Opens a NaCl executable file for reading and executing.
void OpenNaClExecutable(
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter,
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter,
scoped_refptr<ExtensionInfoMap> extension_info_map,
int render_view_id,
const GURL& file_url,
diff --git a/chrome/browser/nacl_host/nacl_host_message_filter.cc b/chrome/browser/nacl_host/nacl_host_message_filter.cc
new file mode 100644
index 0000000..20ad21f
--- /dev/null
+++ b/chrome/browser/nacl_host/nacl_host_message_filter.cc
@@ -0,0 +1,104 @@
+// Copyright 2013 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/browser/nacl_host/nacl_host_message_filter.h"
+
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/metrics/histogram.h"
+#include "chrome/browser/extensions/extension_info_map.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/nacl_host/nacl_file_host.h"
+#include "chrome/browser/nacl_host/nacl_infobar.h"
+#include "chrome/browser/nacl_host/nacl_process_host.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/nacl_host_messages.h"
+#include "googleurl/src/gurl.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_context_getter.h"
+
+NaClHostMessageFilter::NaClHostMessageFilter(
+ int render_process_id,
+ Profile* profile,
+ net::URLRequestContextGetter* request_context)
+ : render_process_id_(render_process_id),
+ profile_(profile),
+ off_the_record_(profile_->IsOffTheRecord()),
+ request_context_(request_context),
+ extension_info_map_(
+ extensions::ExtensionSystem::Get(profile)->info_map()),
+ weak_ptr_factory_(this) {
+}
+
+NaClHostMessageFilter::~NaClHostMessageFilter() {
+}
+
+bool NaClHostMessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(NaClHostMessageFilter, message, *message_was_ok)
+#if !defined(DISABLE_NACL)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_LaunchNaCl, OnLaunchNaCl)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_GetReadonlyPnaclFD,
+ OnGetReadonlyPnaclFd)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_NaClCreateTemporaryFile,
+ OnNaClCreateTemporaryFile)
+ IPC_MESSAGE_HANDLER(NaClHostMsg_NaClErrorStatus, OnNaClErrorStatus)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_OpenNaClExecutable,
+ OnOpenNaClExecutable)
+#endif
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+net::HostResolver* NaClHostMessageFilter::GetHostResolver() {
+ return request_context_->GetURLRequestContext()->host_resolver();
+}
+
+#if !defined(DISABLE_NACL)
+void NaClHostMessageFilter::OnLaunchNaCl(
+ const nacl::NaClLaunchParams& launch_params,
+ IPC::Message* reply_msg) {
+ NaClProcessHost* host = new NaClProcessHost(
+ GURL(launch_params.manifest_url),
+ launch_params.render_view_id,
+ launch_params.permission_bits,
+ launch_params.uses_irt,
+ launch_params.enable_dyncode_syscalls,
+ launch_params.enable_exception_handling,
+ off_the_record_,
+ profile_->GetPath());
+ host->Launch(this, reply_msg, extension_info_map_);
+}
+
+void NaClHostMessageFilter::OnGetReadonlyPnaclFd(
+ const std::string& filename, IPC::Message* reply_msg) {
+ // This posts a task to another thread, but the renderer will
+ // block until the reply is sent.
+ nacl_file_host::GetReadonlyPnaclFd(this, filename, reply_msg);
+}
+
+void NaClHostMessageFilter::OnNaClCreateTemporaryFile(
+ IPC::Message* reply_msg) {
+ nacl_file_host::CreateTemporaryFile(this, reply_msg);
+}
+
+void NaClHostMessageFilter::OnNaClErrorStatus(int render_view_id,
+ int error_id) {
+ // Currently there is only one kind of error status, for which
+ // we want to show the user an infobar.
+ ShowNaClInfobar(render_process_id_, render_view_id, error_id);
+}
+
+void NaClHostMessageFilter::OnOpenNaClExecutable(int render_view_id,
+ const GURL& file_url,
+ IPC::Message* reply_msg) {
+ nacl_file_host::OpenNaClExecutable(this, extension_info_map_,
+ render_view_id, file_url, reply_msg);
+}
+#endif
diff --git a/chrome/browser/nacl_host/nacl_host_message_filter.h b/chrome/browser/nacl_host/nacl_host_message_filter.h
new file mode 100644
index 0000000..61ffc74c
--- /dev/null
+++ b/chrome/browser/nacl_host/nacl_host_message_filter.h
@@ -0,0 +1,72 @@
+// Copyright 2013 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_BROWSER_NACL_HOST_NACL_HOST_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_NACL_HOST_NACL_HOST_MESSAGE_FILTER_H_
+
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/browser_message_filter.h"
+
+class ExtensionInfoMap;
+class GURL;
+class Profile;
+
+namespace nacl {
+struct NaClLaunchParams;
+}
+
+namespace net {
+class HostResolver;
+class URLRequestContextGetter;
+}
+
+// This class filters out incoming Chrome-specific IPC messages for the renderer
+// process on the IPC thread.
+class NaClHostMessageFilter : public content::BrowserMessageFilter {
+ public:
+ NaClHostMessageFilter(int render_process_id,
+ Profile* profile,
+ net::URLRequestContextGetter* request_context);
+
+ // content::BrowserMessageFilter methods:
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) OVERRIDE;
+
+ int render_process_id() { return render_process_id_; }
+ bool off_the_record() { return off_the_record_; }
+ net::HostResolver* GetHostResolver();
+
+ private:
+ friend class content::BrowserThread;
+ friend class base::DeleteHelper<NaClHostMessageFilter>;
+
+ virtual ~NaClHostMessageFilter();
+
+#if !defined(DISABLE_NACL)
+ void OnLaunchNaCl(const nacl::NaClLaunchParams& launch_params,
+ IPC::Message* reply_msg);
+ void OnGetReadonlyPnaclFd(const std::string& filename,
+ IPC::Message* reply_msg);
+ void OnNaClCreateTemporaryFile(IPC::Message* reply_msg);
+ void OnNaClErrorStatus(int render_view_id, int error_id);
+ void OnOpenNaClExecutable(int render_view_id,
+ const GURL& file_url,
+ IPC::Message* reply_msg);
+#endif
+ int render_process_id_;
+
+ // The Profile associated with our renderer process. This should only be
+ // accessed on the UI thread!
+ Profile* profile_;
+ // Copied from the profile so that it can be read on the IO thread.
+ bool off_the_record_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_;
+ scoped_refptr<ExtensionInfoMap> extension_info_map_;
+
+ base::WeakPtrFactory<NaClHostMessageFilter> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(NaClHostMessageFilter);
+};
+
+#endif // CHROME_BROWSER_NACL_HOST_NACL_HOST_MESSAGE_FILTER_H_
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index 7b2a8f2..6f7f50c 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -25,7 +25,7 @@
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/nacl_host/nacl_browser.h"
-#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
+#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
@@ -34,6 +34,7 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/nacl_cmd_line.h"
+#include "chrome/common/nacl_host_messages.h"
#include "chrome/common/nacl_messages.h"
#include "chrome/common/render_messages.h"
#include "content/public/browser/browser_child_process_host.h"
@@ -247,7 +248,7 @@
// The process failed to launch for some reason.
// Don't keep the renderer hanging.
reply_msg_->set_reply_error();
- chrome_render_message_filter_->Send(reply_msg_);
+ nacl_host_message_filter_->Send(reply_msg_);
}
#if defined(OS_WIN)
if (process_launched_by_broker_) {
@@ -279,10 +280,10 @@
}
void NaClProcessHost::Launch(
- ChromeRenderMessageFilter* chrome_render_message_filter,
+ NaClHostMessageFilter* nacl_host_message_filter,
IPC::Message* reply_msg,
scoped_refptr<ExtensionInfoMap> extension_info_map) {
- chrome_render_message_filter_ = chrome_render_message_filter;
+ nacl_host_message_filter_ = nacl_host_message_filter;
reply_msg_ = reply_msg;
extension_info_map_ = extension_info_map;
@@ -531,7 +532,7 @@
if (!DuplicateHandle(base::GetCurrentProcessHandle(),
reinterpret_cast<HANDLE>(
internal_->socket_for_renderer),
- chrome_render_message_filter_->peer_handle(),
+ nacl_host_message_filter_->peer_handle(),
&handle_in_renderer,
0, // Unused given DUPLICATE_SAME_ACCESS.
FALSE,
@@ -565,11 +566,11 @@
#endif
const ChildProcessData& data = process_->GetData();
- ChromeViewHostMsg_LaunchNaCl::WriteReplyParams(
+ NaClHostMsg_LaunchNaCl::WriteReplyParams(
reply_msg_, handle_for_renderer,
channel_handle, base::GetProcId(data.handle), data.id);
- chrome_render_message_filter_->Send(reply_msg_);
- chrome_render_message_filter_ = NULL;
+ nacl_host_message_filter_->Send(reply_msg_);
+ nacl_host_message_filter_ = NULL;
reply_msg_ = NULL;
internal_->socket_for_renderer = NACL_INVALID_HANDLE;
return true;
@@ -708,13 +709,13 @@
permissions_,
process_->GetData().handle,
ipc_proxy_channel_.get(),
- chrome_render_message_filter_->GetHostResolver(),
- chrome_render_message_filter_->render_process_id(),
+ nacl_host_message_filter_->GetHostResolver(),
+ nacl_host_message_filter_->render_process_id(),
render_view_id_,
profile_directory_));
ppapi::PpapiNaClChannelArgs args;
- args.off_the_record = chrome_render_message_filter_->off_the_record();
+ args.off_the_record = nacl_host_message_filter_->off_the_record();
args.permissions = permissions_;
CommandLine* cmdline = CommandLine::ForCurrentProcess();
DCHECK(cmdline);
@@ -735,7 +736,7 @@
// a place holder.
ipc_proxy_channel_->Send(
new PpapiMsg_CreateNaClChannel(
- chrome_render_message_filter_->render_process_id(),
+ nacl_host_message_filter_->render_process_id(),
args,
SerializedHandle(SerializedHandle::CHANNEL_HANDLE,
IPC::InvalidPlatformFileForTransit())));
diff --git a/chrome/browser/nacl_host/nacl_process_host.h b/chrome/browser/nacl_host/nacl_process_host.h
index 3df8c27..4f15e8a 100644
--- a/chrome/browser/nacl_host/nacl_process_host.h
+++ b/chrome/browser/nacl_host/nacl_process_host.h
@@ -21,7 +21,7 @@
#include "net/socket/tcp_listen_socket.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
-class ChromeRenderMessageFilter;
+class NaClHostMessageFilter;
class CommandLine;
class ExtensionInfoMap;
@@ -63,7 +63,7 @@
// Initialize the new NaCl process. Result is returned by sending ipc
// message reply_msg.
- void Launch(ChromeRenderMessageFilter* chrome_render_message_filter,
+ void Launch(NaClHostMessageFilter* nacl_host_message_filter,
IPC::Message* reply_msg,
scoped_refptr<ExtensionInfoMap> extension_info_map);
@@ -168,9 +168,9 @@
// the NaCl loader.
bool process_launched_by_broker_;
#endif
- // The ChromeRenderMessageFilter that requested this NaCl process. We use
+ // The NaClHostMessageFilter that requested this NaCl process. We use
// this for sending the reply once the process has started.
- scoped_refptr<ChromeRenderMessageFilter> chrome_render_message_filter_;
+ scoped_refptr<NaClHostMessageFilter> nacl_host_message_filter_;
// The reply message to send. We must always send this message when the
// sub-process either succeeds or fails to unblock the renderer waiting for
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index ee2e428..7166497f 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -177,16 +177,6 @@
bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, *message_was_ok)
-#if !defined(DISABLE_NACL)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_LaunchNaCl, OnLaunchNaCl)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetReadonlyPnaclFD,
- OnGetReadonlyPnaclFd)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_NaClCreateTemporaryFile,
- OnNaClCreateTemporaryFile)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NaClErrorStatus, OnNaClErrorStatus)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_OpenNaClExecutable,
- OnOpenNaClExecutable)
-#endif
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DnsPrefetch, OnDnsPrefetch)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_Preconnect, OnPreconnect)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ResourceTypeStats,
@@ -286,49 +276,6 @@
return request_context_->GetURLRequestContext()->host_resolver();
}
-#if !defined(DISABLE_NACL)
-void ChromeRenderMessageFilter::OnLaunchNaCl(
- const nacl::NaClLaunchParams& launch_params,
- IPC::Message* reply_msg) {
- NaClProcessHost* host = new NaClProcessHost(
- GURL(launch_params.manifest_url),
- launch_params.render_view_id,
- launch_params.permission_bits,
- launch_params.uses_irt,
- launch_params.enable_dyncode_syscalls,
- launch_params.enable_exception_handling,
- off_the_record_,
- profile_->GetPath());
- host->Launch(this, reply_msg, extension_info_map_);
-}
-
-void ChromeRenderMessageFilter::OnGetReadonlyPnaclFd(
- const std::string& filename, IPC::Message* reply_msg) {
- // This posts a task to another thread, but the renderer will
- // block until the reply is sent.
- nacl_file_host::GetReadonlyPnaclFd(this, filename, reply_msg);
-}
-
-void ChromeRenderMessageFilter::OnNaClCreateTemporaryFile(
- IPC::Message* reply_msg) {
- nacl_file_host::CreateTemporaryFile(this, reply_msg);
-}
-
-void ChromeRenderMessageFilter::OnNaClErrorStatus(int render_view_id,
- int error_id) {
- // Currently there is only one kind of error status, for which
- // we want to show the user an infobar.
- ShowNaClInfobar(render_process_id_, render_view_id, error_id);
-}
-
-void ChromeRenderMessageFilter::OnOpenNaClExecutable(int render_view_id,
- const GURL& file_url,
- IPC::Message* reply_msg) {
- nacl_file_host::OpenNaClExecutable(this, extension_info_map_,
- render_view_id, file_url, reply_msg);
-}
-#endif
-
void ChromeRenderMessageFilter::OnDnsPrefetch(
const std::vector<std::string>& hostnames) {
if (profile_->GetNetworkPredictor())
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h
index 87512b2..a4469288 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.h
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.h
@@ -24,10 +24,6 @@
class ExtensionInfoMap;
class GURL;
-namespace nacl {
-struct NaClLaunchParams;
-}
-
namespace net {
class HostResolver;
class URLRequestContextGetter;
@@ -84,17 +80,6 @@
virtual ~ChromeRenderMessageFilter();
-#if !defined(DISABLE_NACL)
- void OnLaunchNaCl(const nacl::NaClLaunchParams& launch_params,
- IPC::Message* reply_msg);
- void OnGetReadonlyPnaclFd(const std::string& filename,
- IPC::Message* reply_msg);
- void OnNaClCreateTemporaryFile(IPC::Message* reply_msg);
- void OnNaClErrorStatus(int render_view_id, int error_id);
- void OnOpenNaClExecutable(int render_view_id,
- const GURL& file_url,
- IPC::Message* reply_msg);
-#endif
void OnDnsPrefetch(const std::vector<std::string>& hostnames);
void OnPreconnect(const GURL& url);
void OnResourceTypeStats(const WebKit::WebCache::ResourceTypeStats& stats);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 8c562a7d..d3e9af4b 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2484,6 +2484,8 @@
'browser/nacl_host/nacl_browser.h',
'browser/nacl_host/nacl_file_host.cc',
'browser/nacl_host/nacl_file_host.h',
+ 'browser/nacl_host/nacl_host_message_filter.cc',
+ 'browser/nacl_host/nacl_host_message_filter.h',
'browser/nacl_host/nacl_infobar.cc',
'browser/nacl_host/nacl_infobar.h',
'browser/nacl_host/nacl_process_host.cc',
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 1d3b44e..bb53e51 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -375,6 +375,7 @@
'common/multi_process_lock_win.cc',
'common/nacl_cmd_line.cc',
'common/nacl_cmd_line.h',
+ 'common/nacl_host_messages.h',
'common/nacl_messages.cc',
'common/nacl_messages.h',
'common/nacl_types.cc',
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index dce23eb9..0c1fedf 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -8,6 +8,7 @@
#include "chrome/common/benchmarking_messages.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/nacl_host_messages.h"
#include "chrome/common/one_click_signin_messages.h"
#include "chrome/common/prerender_messages.h"
#include "chrome/common/print_messages.h"
diff --git a/chrome/common/nacl_host_messages.h b/chrome/common/nacl_host_messages.h
new file mode 100644
index 0000000..ca9b76e
--- /dev/null
+++ b/chrome/common/nacl_host_messages.h
@@ -0,0 +1,65 @@
+// Copyright 2013 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.
+
+// Multiply-included file, no traditional include guard.
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/process.h"
+#include "build/build_config.h"
+#include "chrome/common/common_param_traits.h"
+#include "chrome/common/nacl_types.h"
+#include "content/public/common/common_param_traits.h"
+#include "googleurl/src/gurl.h"
+#include "ipc/ipc_channel_handle.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_platform_file.h"
+
+#define IPC_MESSAGE_START NaClHostMsgStart
+
+IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchParams)
+ IPC_STRUCT_TRAITS_MEMBER(manifest_url)
+ IPC_STRUCT_TRAITS_MEMBER(render_view_id)
+ IPC_STRUCT_TRAITS_MEMBER(permission_bits)
+ IPC_STRUCT_TRAITS_MEMBER(uses_irt)
+ IPC_STRUCT_TRAITS_MEMBER(enable_dyncode_syscalls)
+ IPC_STRUCT_TRAITS_MEMBER(enable_exception_handling)
+IPC_STRUCT_TRAITS_END()
+
+// A renderer sends this to the browser process when it wants to start
+// a new instance of the Native Client process. The browser will launch
+// the process and return an IPC channel handle. This handle will only
+// be valid if the NaCl IPC proxy is enabled.
+IPC_SYNC_MESSAGE_CONTROL1_4(NaClHostMsg_LaunchNaCl,
+ nacl::NaClLaunchParams /* launch_params */,
+ nacl::FileDescriptor /* imc channel handle */,
+ IPC::ChannelHandle /* ipc_channel_handle */,
+ base::ProcessId /* plugin_pid */,
+ int /* plugin_child_id */)
+
+// A renderer sends this to the browser process when it wants to
+// open a file for from the Pnacl component directory.
+IPC_SYNC_MESSAGE_CONTROL1_1(NaClHostMsg_GetReadonlyPnaclFD,
+ std::string /* name of requested PNaCl file */,
+ IPC::PlatformFileForTransit /* output file */)
+
+// A renderer sends this to the browser process when it wants to
+// create a temporary file.
+IPC_SYNC_MESSAGE_CONTROL0_1(NaClHostMsg_NaClCreateTemporaryFile,
+ IPC::PlatformFileForTransit /* out file */)
+
+// A renderer sends this to the browser process to display infobar
+IPC_MESSAGE_CONTROL2(NaClHostMsg_NaClErrorStatus,
+ int /* render_view_id */,
+ int /* Error ID */)
+
+// A renderer sends this to the browser process when it wants to
+// open a NaCl executable file from an installed application directory.
+IPC_SYNC_MESSAGE_CONTROL2_3(NaClHostMsg_OpenNaClExecutable,
+ int /* render_view_id */,
+ GURL /* URL of NaCl executable file */,
+ IPC::PlatformFileForTransit /* output file */,
+ uint64 /* file_token_lo */,
+ uint64 /* file_token_hi */)
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index e2ed838..15dd718 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -196,15 +196,6 @@
IPC_STRUCT_TRAITS_MEMBER(origin)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_TRAITS_BEGIN(nacl::NaClLaunchParams)
- IPC_STRUCT_TRAITS_MEMBER(manifest_url)
- IPC_STRUCT_TRAITS_MEMBER(render_view_id)
- IPC_STRUCT_TRAITS_MEMBER(permission_bits)
- IPC_STRUCT_TRAITS_MEMBER(uses_irt)
- IPC_STRUCT_TRAITS_MEMBER(enable_dyncode_syscalls)
- IPC_STRUCT_TRAITS_MEMBER(enable_exception_handling)
-IPC_STRUCT_TRAITS_END()
-
IPC_STRUCT_TRAITS_BEGIN(RendererContentSettingRules)
IPC_STRUCT_TRAITS_MEMBER(image_rules)
IPC_STRUCT_TRAITS_MEMBER(script_rules)
@@ -598,42 +589,6 @@
std::string /* origin */,
std::string /* target */)
-// A renderer sends this to the browser process when it wants to start
-// a new instance of the Native Client process. The browser will launch
-// the process and return an IPC channel handle. This handle will only
-// be valid if the NaCl IPC proxy is enabled.
-IPC_SYNC_MESSAGE_CONTROL1_4(ChromeViewHostMsg_LaunchNaCl,
- nacl::NaClLaunchParams /* launch_params */,
- nacl::FileDescriptor /* imc channel handle */,
- IPC::ChannelHandle /* ipc_channel_handle */,
- base::ProcessId /* plugin_pid */,
- int /* plugin_child_id */)
-
-// A renderer sends this to the browser process when it wants to
-// open a file for from the Pnacl component directory.
-IPC_SYNC_MESSAGE_CONTROL1_1(ChromeViewHostMsg_GetReadonlyPnaclFD,
- std::string /* name of requested PNaCl file */,
- IPC::PlatformFileForTransit /* output file */)
-
-// A renderer sends this to the browser process when it wants to
-// create a temporary file.
-IPC_SYNC_MESSAGE_CONTROL0_1(ChromeViewHostMsg_NaClCreateTemporaryFile,
- IPC::PlatformFileForTransit /* out file */)
-
-// A renderer sends this to the browser process to display infobar
-IPC_MESSAGE_CONTROL2(ChromeViewHostMsg_NaClErrorStatus,
- int /* render_view_id */,
- int /* Error ID */)
-
-// A renderer sends this to the browser process when it wants to
-// open a NaCl executable file from an installed application directory.
-IPC_SYNC_MESSAGE_CONTROL2_3(ChromeViewHostMsg_OpenNaClExecutable,
- int /* render_view_id */,
- GURL /* URL of NaCl executable file */,
- IPC::PlatformFileForTransit /* output file */,
- uint64_t /* file_token_lo */,
- uint64_t /* file_token_hi */)
-
// Notification that the page has an OpenSearch description document
// associated with it.
IPC_MESSAGE_ROUTED3(ChromeViewHostMsg_PageHasOSDD,
diff --git a/chrome/renderer/pepper/ppb_nacl_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
index 307ed79..54ba85e 100644
--- a/chrome/renderer/pepper/ppb_nacl_private_impl.cc
+++ b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
@@ -11,7 +11,7 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/render_messages.h"
+#include "chrome/common/nacl_host_messages.h"
#include "chrome/renderer/chrome_render_process_observer.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
@@ -103,7 +103,7 @@
instance_info.permissions =
ppapi::PpapiPermissions::GetForCommandLine(perm_bits);
- if (!sender->Send(new ChromeViewHostMsg_LaunchNaCl(
+ if (!sender->Send(new NaClHostMsg_LaunchNaCl(
nacl::NaClLaunchParams(instance_info.url.spec(),
routing_id,
perm_bits,
@@ -213,7 +213,7 @@
if (sender == NULL)
sender = g_background_thread_sender.Pointer()->get();
- if (!sender->Send(new ChromeViewHostMsg_GetReadonlyPnaclFD(
+ if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD(
std::string(filename),
&out_fd))) {
return base::kInvalidPlatformFileValue;
@@ -234,7 +234,7 @@
if (sender == NULL)
sender = g_background_thread_sender.Pointer()->get();
- if (!sender->Send(new ChromeViewHostMsg_NaClCreateTemporaryFile(
+ if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile(
&transit_fd))) {
return base::kInvalidPlatformFileValue;
}
@@ -262,7 +262,7 @@
IPC::Sender* sender = content::RenderThread::Get();
if (!sender->Send(
- new ChromeViewHostMsg_NaClErrorStatus(
+ new NaClHostMsg_NaClErrorStatus(
// TODO(dschuff): does this enum need to be sent as an int,
// or is it safe to include the appropriate headers in
// render_messages.h?
@@ -285,7 +285,7 @@
*nonce_hi = 0;
base::FilePath file_path;
if (!sender->Send(
- new ChromeViewHostMsg_OpenNaClExecutable(GetRoutingID(instance),
+ new NaClHostMsg_OpenNaClExecutable(GetRoutingID(instance),
GURL(file_url),
&out_fd,
nonce_lo,
diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h
index 3992307..8226bc1 100644
--- a/ipc/ipc_message_start.h
+++ b/ipc/ipc_message_start.h
@@ -83,6 +83,7 @@
TtsMsgStart,
MemoryBenchmarkMsgStart,
WebSocketMsgStart,
+ NaClHostMsgStart,
LastIPCMsgStart // Must come last.
};