Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: chrome/browser/nacl_host/nacl_host_message_filter.cc

Issue 15906013: Separate NaCl messages from the rest of chrome messages and create a new message filter. This is pa… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/nacl_host/nacl_host_message_filter.h"
6
7 #include "base/bind.h"
8 #include "base/command_line.h"
9 #include "base/file_util.h"
10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/extensions/extension_info_map.h"
12 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/nacl_host/nacl_file_host.h"
14 #include "chrome/browser/nacl_host/nacl_infobar.h"
15 #include "chrome/browser/nacl_host/nacl_process_host.h"
16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/nacl_host_messages.h"
18 #include "googleurl/src/gurl.h"
19 #include "net/url_request/url_request_context.h"
20 #include "net/url_request/url_request_context_getter.h"
21
22 NaClHostMessageFilter::NaClHostMessageFilter(
23 int render_process_id,
24 Profile* profile,
25 net::URLRequestContextGetter* request_context)
26 : render_process_id_(render_process_id),
27 profile_(profile),
28 off_the_record_(profile_->IsOffTheRecord()),
29 request_context_(request_context),
30 extension_info_map_(
31 extensions::ExtensionSystem::Get(profile)->info_map()),
32 weak_ptr_factory_(this) {
33 }
34
35 NaClHostMessageFilter::~NaClHostMessageFilter() {
36 }
37
38 bool NaClHostMessageFilter::OnMessageReceived(const IPC::Message& message,
39 bool* message_was_ok) {
40 bool handled = true;
41 IPC_BEGIN_MESSAGE_MAP_EX(NaClHostMessageFilter, message, *message_was_ok)
42 #if !defined(DISABLE_NACL)
43 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_LaunchNaCl, OnLaunchNaCl)
44 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_GetReadonlyPnaclFD,
45 OnGetReadonlyPnaclFd)
46 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_NaClCreateTemporaryFile,
47 OnNaClCreateTemporaryFile)
48 IPC_MESSAGE_HANDLER(NaClHostMsg_NaClErrorStatus, OnNaClErrorStatus)
49 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_OpenNaClExecutable,
50 OnOpenNaClExecutable)
51 #endif
52 IPC_MESSAGE_UNHANDLED(handled = false)
53 IPC_END_MESSAGE_MAP()
54
55 return handled;
56 }
57
58 net::HostResolver* NaClHostMessageFilter::GetHostResolver() {
59 return request_context_->GetURLRequestContext()->host_resolver();
60 }
61
62 #if !defined(DISABLE_NACL)
63 void NaClHostMessageFilter::OnLaunchNaCl(
64 const nacl::NaClLaunchParams& launch_params,
65 IPC::Message* reply_msg) {
66 NaClProcessHost* host = new NaClProcessHost(
67 GURL(launch_params.manifest_url),
68 launch_params.render_view_id,
69 launch_params.permission_bits,
70 launch_params.uses_irt,
71 launch_params.enable_dyncode_syscalls,
72 launch_params.enable_exception_handling,
73 off_the_record_,
74 profile_->GetPath());
75 host->Launch(this, reply_msg, extension_info_map_);
76 }
77
78 void NaClHostMessageFilter::OnGetReadonlyPnaclFd(
79 const std::string& filename, IPC::Message* reply_msg) {
80 // This posts a task to another thread, but the renderer will
81 // block until the reply is sent.
82 nacl_file_host::GetReadonlyPnaclFd(this, filename, reply_msg);
83 }
84
85 void NaClHostMessageFilter::OnNaClCreateTemporaryFile(
86 IPC::Message* reply_msg) {
87 nacl_file_host::CreateTemporaryFile(this, reply_msg);
88 }
89
90 void NaClHostMessageFilter::OnNaClErrorStatus(int render_view_id,
91 int error_id) {
92 // Currently there is only one kind of error status, for which
93 // we want to show the user an infobar.
94 ShowNaClInfobar(render_process_id_, render_view_id, error_id);
95 }
96
97 void NaClHostMessageFilter::OnOpenNaClExecutable(int render_view_id,
98 const GURL& file_url,
99 IPC::Message* reply_msg) {
100 nacl_file_host::OpenNaClExecutable(this, extension_info_map_,
101 render_view_id, file_url, reply_msg);
102 }
103 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698