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

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

Issue 264923011: Add a whitelist check for nacl-nonsfi mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add includes (windows compile fail) Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/nacl_host/nacl_browser_delegate_impl.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 5 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" 11 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/nacl_host/nacl_infobar_delegate.h" 13 #include "chrome/browser/nacl_host/nacl_infobar_delegate.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h" 16 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_paths_internal.h" 18 #include "chrome/common/chrome_paths_internal.h"
19 #include "chrome/common/chrome_version_info.h" 19 #include "chrome/common/chrome_version_info.h"
20 #include "chrome/common/logging_chrome.h" 20 #include "chrome/common/logging_chrome.h"
21 #include "chrome/common/pepper_permission_util.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/site_instance.h" 24 #include "content/public/browser/site_instance.h"
24 #include "extensions/browser/extension_system.h" 25 #include "extensions/browser/extension_system.h"
25 #include "extensions/browser/info_map.h" 26 #include "extensions/browser/info_map.h"
26 #include "extensions/browser/process_manager.h" 27 #include "extensions/browser/process_manager.h"
27 #include "extensions/common/constants.h" 28 #include "extensions/common/constants.h"
28 #include "extensions/common/extension.h" 29 #include "extensions/common/extension.h"
29 #include "extensions/common/manifest_handlers/shared_module_info.h" 30 #include "extensions/common/manifest_handlers/shared_module_info.h"
30 #include "extensions/common/url_pattern.h" 31 #include "extensions/common/url_pattern.h"
31 #include "ppapi/c/private/ppb_nacl_private.h" 32 #include "ppapi/c/private/ppb_nacl_private.h"
32 33
33 using extensions::SharedModuleInfo; 34 using extensions::SharedModuleInfo;
34 35
35 namespace { 36 namespace {
36 37
38 // These are temporarily needed for testing non-sfi mode on ChromeOS without
39 // passing command-line arguments to Chrome.
40 const char* const kAllowedNonSfiOrigins[] = {
41 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/355141
42 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/355141
43 };
44
37 // Handles an extension's NaCl process transitioning in or out of idle state by 45 // Handles an extension's NaCl process transitioning in or out of idle state by
38 // relaying the state to the extension's process manager. 46 // relaying the state to the extension's process manager.
39 // 47 //
40 // A NaCl instance, when active (making PPAPI calls or receiving callbacks), 48 // A NaCl instance, when active (making PPAPI calls or receiving callbacks),
41 // sends keepalive IPCs to the browser process BrowserPpapiHost at a throttled 49 // sends keepalive IPCs to the browser process BrowserPpapiHost at a throttled
42 // rate. The content::BrowserPpapiHost passes context information up to the 50 // rate. The content::BrowserPpapiHost passes context information up to the
43 // chrome level NaClProcessHost where we use the instance's context to find the 51 // chrome level NaClProcessHost where we use the instance's context to find the
44 // associated extension process manager. 52 // associated extension process manager.
45 // 53 //
46 // There is a 1:many relationship for extension:nacl-embeds, but only a 54 // There is a 1:many relationship for extension:nacl-embeds, but only a
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 instance_data, 109 instance_data,
102 profile_data_directory)); 110 profile_data_directory));
103 } 111 }
104 112
105 } // namespace 113 } // namespace
106 114
107 NaClBrowserDelegateImpl::NaClBrowserDelegateImpl( 115 NaClBrowserDelegateImpl::NaClBrowserDelegateImpl(
108 ProfileManager* profile_manager) 116 ProfileManager* profile_manager)
109 : profile_manager_(profile_manager), inverse_debug_patterns_(false) { 117 : profile_manager_(profile_manager), inverse_debug_patterns_(false) {
110 DCHECK(profile_manager_); 118 DCHECK(profile_manager_);
119 for (size_t i = 0; i < arraysize(kAllowedNonSfiOrigins); ++i) {
120 allowed_nonsfi_origins_.insert(kAllowedNonSfiOrigins[i]);
121 }
111 } 122 }
112 123
113 NaClBrowserDelegateImpl::~NaClBrowserDelegateImpl() { 124 NaClBrowserDelegateImpl::~NaClBrowserDelegateImpl() {
114 } 125 }
115 126
116 void NaClBrowserDelegateImpl::ShowMissingArchInfobar(int render_process_id, 127 void NaClBrowserDelegateImpl::ShowMissingArchInfobar(int render_process_id,
117 int render_view_id) { 128 int render_view_id) {
118 content::BrowserThread::PostTask( 129 content::BrowserThread::PostTask(
119 content::BrowserThread::UI, FROM_HERE, 130 content::BrowserThread::UI, FROM_HERE,
120 base::Bind(&NaClInfoBarDelegate::Create, render_process_id, 131 base::Bind(&NaClInfoBarDelegate::Create, render_process_id,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 214 }
204 } 215 }
205 216
206 // This function is security sensitive. Be sure to check with a security 217 // This function is security sensitive. Be sure to check with a security
207 // person before you modify it. 218 // person before you modify it.
208 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( 219 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath(
209 const GURL& file_url, 220 const GURL& file_url,
210 bool use_blocking_api, 221 bool use_blocking_api,
211 const base::FilePath& profile_directory, 222 const base::FilePath& profile_directory,
212 base::FilePath* file_path) { 223 base::FilePath* file_path) {
213 // Get the profile associated with the renderer.
214 Profile* profile = profile_manager_->GetProfileByPath(profile_directory);
215 if (!profile)
216 return false;
217
218 scoped_refptr<extensions::InfoMap> extension_info_map = 224 scoped_refptr<extensions::InfoMap> extension_info_map =
219 extensions::ExtensionSystem::Get(profile)->info_map(); 225 GetExtensionInfoMap(profile_directory);
220 DCHECK(extension_info_map);
221
222 // Check that the URL is recognized by the extension system. 226 // Check that the URL is recognized by the extension system.
223 const extensions::Extension* extension = 227 const extensions::Extension* extension =
224 extension_info_map->extensions().GetExtensionOrAppByURL(file_url); 228 extension_info_map->extensions().GetExtensionOrAppByURL(file_url);
225 if (!extension) 229 if (!extension)
226 return false; 230 return false;
227 231
228 // This is a short-cut which avoids calling a blocking file operation 232 // This is a short-cut which avoids calling a blocking file operation
229 // (GetFilePath()), so that this can be called on the IO thread. It only 233 // (GetFilePath()), so that this can be called on the IO thread. It only
230 // handles a subset of the urls. 234 // handles a subset of the urls.
231 if (!use_blocking_api) { 235 if (!use_blocking_api) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return false; 276 return false;
273 277
274 *file_path = resource_file_path; 278 *file_path = resource_file_path;
275 return true; 279 return true;
276 } 280 }
277 281
278 content::BrowserPpapiHost::OnKeepaliveCallback 282 content::BrowserPpapiHost::OnKeepaliveCallback
279 NaClBrowserDelegateImpl::GetOnKeepaliveCallback() { 283 NaClBrowserDelegateImpl::GetOnKeepaliveCallback() {
280 return base::Bind(&OnKeepalive); 284 return base::Bind(&OnKeepalive);
281 } 285 }
286
287 bool NaClBrowserDelegateImpl::IsNonSfiModeAllowed(
288 const base::FilePath& profile_directory,
289 const GURL& manifest_url) {
290 const extensions::ExtensionSet* extension_set =
291 &GetExtensionInfoMap(profile_directory)->extensions();
292 return chrome::IsExtensionOrSharedModuleWhitelisted(
293 manifest_url, extension_set, allowed_nonsfi_origins_);
294 }
295
296 scoped_refptr<extensions::InfoMap> NaClBrowserDelegateImpl::GetExtensionInfoMap(
297 const base::FilePath& profile_directory) {
298 // Get the profile associated with the renderer.
299 Profile* profile = profile_manager_->GetProfileByPath(profile_directory);
300 DCHECK(profile);
301 scoped_refptr<extensions::InfoMap> extension_info_map =
302 extensions::ExtensionSystem::Get(profile)->info_map();
303 DCHECK(extension_info_map);
304 return extension_info_map;
305 }
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_browser_delegate_impl.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698