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

Side by Side Diff: components/nacl/browser/nacl_host_message_filter.cc

Issue 1548113002: Switch to standard integer types in components/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 12 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/browser/nacl_host_message_filter.h" 5 #include "components/nacl/browser/nacl_host_message_filter.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/sys_info.h" 10 #include "base/sys_info.h"
11 #include "build/build_config.h"
8 #include "components/nacl/browser/bad_message.h" 12 #include "components/nacl/browser/bad_message.h"
9 #include "components/nacl/browser/nacl_browser.h" 13 #include "components/nacl/browser/nacl_browser.h"
10 #include "components/nacl/browser/nacl_file_host.h" 14 #include "components/nacl/browser/nacl_file_host.h"
11 #include "components/nacl/browser/nacl_process_host.h" 15 #include "components/nacl/browser/nacl_process_host.h"
12 #include "components/nacl/browser/pnacl_host.h" 16 #include "components/nacl/browser/pnacl_host.h"
13 #include "components/nacl/common/nacl_host_messages.h" 17 #include "components/nacl/common/nacl_host_messages.h"
14 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/plugin_service.h" 19 #include "content/public/browser/plugin_service.h"
16 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
18 #include "ipc/ipc_platform_file.h" 22 #include "ipc/ipc_platform_file.h"
19 #include "net/url_request/url_request_context.h" 23 #include "net/url_request/url_request_context.h"
20 #include "net/url_request/url_request_context_getter.h" 24 #include "net/url_request/url_request_context_getter.h"
21 #include "ppapi/shared_impl/ppapi_permissions.h" 25 #include "ppapi/shared_impl/ppapi_permissions.h"
22 #include "url/gurl.h" 26 #include "url/gurl.h"
23 27
24 namespace nacl { 28 namespace nacl {
25 29
26 namespace { 30 namespace {
27 31
28 // The maximum number of resource file handles the browser process accepts. Use 32 // The maximum number of resource file handles the browser process accepts. Use
29 // 200 because ARC's nmf has ~128 resource files as of May 2015. This prevents 33 // 200 because ARC's nmf has ~128 resource files as of May 2015. This prevents
30 // untrusted code filling the FD/handle table. 34 // untrusted code filling the FD/handle table.
31 const size_t kMaxPreOpenResourceFiles = 200; 35 const size_t kMaxPreOpenResourceFiles = 200;
32 36
33 ppapi::PpapiPermissions GetNaClPermissions( 37 ppapi::PpapiPermissions GetNaClPermissions(
34 uint32 permission_bits, 38 uint32_t permission_bits,
35 content::BrowserContext* browser_context, 39 content::BrowserContext* browser_context,
36 const GURL& document_url) { 40 const GURL& document_url) {
37 // Only allow NaCl plugins to request certain permissions. We don't want 41 // Only allow NaCl plugins to request certain permissions. We don't want
38 // a compromised renderer to be able to start a nacl plugin with e.g. Flash 42 // a compromised renderer to be able to start a nacl plugin with e.g. Flash
39 // permissions which may expand the surface area of the sandbox. 43 // permissions which may expand the surface area of the sandbox.
40 uint32 masked_bits = permission_bits & ppapi::PERMISSION_DEV; 44 uint32_t masked_bits = permission_bits & ppapi::PERMISSION_DEV;
41 if (content::PluginService::GetInstance()->PpapiDevChannelSupported( 45 if (content::PluginService::GetInstance()->PpapiDevChannelSupported(
42 browser_context, document_url)) 46 browser_context, document_url))
43 masked_bits |= ppapi::PERMISSION_DEV_CHANNEL; 47 masked_bits |= ppapi::PERMISSION_DEV_CHANNEL;
44 return ppapi::PpapiPermissions::GetForCommandLine(masked_bits); 48 return ppapi::PpapiPermissions::GetForCommandLine(masked_bits);
45 } 49 }
46 50
47 51 ppapi::PpapiPermissions GetPpapiPermissions(uint32_t permission_bits,
48 ppapi::PpapiPermissions GetPpapiPermissions(uint32 permission_bits,
49 int render_process_id, 52 int render_process_id,
50 int render_view_id) { 53 int render_view_id) {
51 // We get the URL from WebContents from the RenderViewHost, since we don't 54 // We get the URL from WebContents from the RenderViewHost, since we don't
52 // have a BrowserPpapiHost yet. 55 // have a BrowserPpapiHost yet.
53 content::RenderProcessHost* host = 56 content::RenderProcessHost* host =
54 content::RenderProcessHost::FromID(render_process_id); 57 content::RenderProcessHost::FromID(render_process_id);
55 content::RenderViewHost* view_host = 58 content::RenderViewHost* view_host =
56 content::RenderViewHost::FromID(render_process_id, render_view_id); 59 content::RenderViewHost::FromID(render_process_id, render_view_id);
57 if (!view_host) 60 if (!view_host)
58 return ppapi::PpapiPermissions(); 61 return ppapi::PpapiPermissions();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return request_context_->GetURLRequestContext()->host_resolver(); 123 return request_context_->GetURLRequestContext()->host_resolver();
121 } 124 }
122 125
123 void NaClHostMessageFilter::OnLaunchNaCl( 126 void NaClHostMessageFilter::OnLaunchNaCl(
124 const nacl::NaClLaunchParams& launch_params, 127 const nacl::NaClLaunchParams& launch_params,
125 IPC::Message* reply_msg) { 128 IPC::Message* reply_msg) {
126 // If we're running llc or ld for the PNaCl translator, we don't need to look 129 // If we're running llc or ld for the PNaCl translator, we don't need to look
127 // up permissions, and we don't have the right browser state to look up some 130 // up permissions, and we don't have the right browser state to look up some
128 // of the whitelisting parameters anyway. 131 // of the whitelisting parameters anyway.
129 if (launch_params.process_type == kPNaClTranslatorProcessType) { 132 if (launch_params.process_type == kPNaClTranslatorProcessType) {
130 uint32 perms = launch_params.permission_bits & ppapi::PERMISSION_DEV; 133 uint32_t perms = launch_params.permission_bits & ppapi::PERMISSION_DEV;
131 LaunchNaClContinuationOnIOThread( 134 LaunchNaClContinuationOnIOThread(
132 launch_params, 135 launch_params,
133 reply_msg, 136 reply_msg,
134 std::vector<NaClResourcePrefetchResult>(), 137 std::vector<NaClResourcePrefetchResult>(),
135 ppapi::PpapiPermissions(perms)); 138 ppapi::PpapiPermissions(perms));
136 return; 139 return;
137 } 140 }
138 content::BrowserThread::PostTask( 141 content::BrowserThread::PostTask(
139 content::BrowserThread::UI, 142 content::BrowserThread::UI,
140 FROM_HERE, 143 FROM_HERE,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 reply_msg); 402 reply_msg);
400 } 403 }
401 404
402 void NaClHostMessageFilter::OnNaClDebugEnabledForURL(const GURL& nmf_url, 405 void NaClHostMessageFilter::OnNaClDebugEnabledForURL(const GURL& nmf_url,
403 bool* should_debug) { 406 bool* should_debug) {
404 *should_debug = 407 *should_debug =
405 nacl::NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(nmf_url); 408 nacl::NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(nmf_url);
406 } 409 }
407 410
408 } // namespace nacl 411 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_host_message_filter.h ('k') | components/nacl/browser/nacl_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698