OLD | NEW |
---|---|
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 "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | 10 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, | 55 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, |
56 const base::FilePath& profile_data_directory) { | 56 const base::FilePath& profile_data_directory) { |
57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
58 | 58 |
59 // Only one instance will exist for NaCl embeds, even when more than one | 59 // Only one instance will exist for NaCl embeds, even when more than one |
60 // embed of the same plugin exists on the same page. | 60 // embed of the same plugin exists on the same page. |
61 DCHECK(instance_data.size() == 1); | 61 DCHECK(instance_data.size() == 1); |
62 if (instance_data.size() < 1) | 62 if (instance_data.size() < 1) |
63 return; | 63 return; |
64 | 64 |
65 #if defined(ENABLE_EXTENSIONS) | |
65 extensions::ProcessManager::OnKeepaliveFromPlugin( | 66 extensions::ProcessManager::OnKeepaliveFromPlugin( |
66 instance_data[0].render_process_id, | 67 instance_data[0].render_process_id, |
67 instance_data[0].render_frame_id, | 68 instance_data[0].render_frame_id, |
68 instance_data[0].document_url.host()); | 69 instance_data[0].document_url.host()); |
70 #endif | |
69 } | 71 } |
70 | 72 |
71 // Calls OnKeepaliveOnUIThread on UI thread. | 73 // Calls OnKeepaliveOnUIThread on UI thread. |
72 void OnKeepalive( | 74 void OnKeepalive( |
73 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, | 75 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, |
74 const base::FilePath& profile_data_directory) { | 76 const base::FilePath& profile_data_directory) { |
75 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 77 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
76 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 78 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
77 base::Bind(&OnKeepaliveOnUIThread, | 79 base::Bind(&OnKeepaliveOnUIThread, |
78 instance_data, | 80 instance_data, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 } | 185 } |
184 } | 186 } |
185 | 187 |
186 // This function is security sensitive. Be sure to check with a security | 188 // This function is security sensitive. Be sure to check with a security |
187 // person before you modify it. | 189 // person before you modify it. |
188 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( | 190 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( |
189 const GURL& file_url, | 191 const GURL& file_url, |
190 bool use_blocking_api, | 192 bool use_blocking_api, |
191 const base::FilePath& profile_directory, | 193 const base::FilePath& profile_directory, |
192 base::FilePath* file_path) { | 194 base::FilePath* file_path) { |
195 #if defined(ENABLE_EXTENSIONS) | |
193 scoped_refptr<extensions::InfoMap> extension_info_map = | 196 scoped_refptr<extensions::InfoMap> extension_info_map = |
194 GetExtensionInfoMap(profile_directory); | 197 GetExtensionInfoMap(profile_directory); |
195 return extension_info_map->MapUrlToLocalFilePath( | 198 return extension_info_map->MapUrlToLocalFilePath( |
196 file_url, use_blocking_api, file_path); | 199 file_url, use_blocking_api, file_path); |
200 #else | |
201 return false; | |
202 #endif | |
197 } | 203 } |
198 | 204 |
199 content::BrowserPpapiHost::OnKeepaliveCallback | 205 content::BrowserPpapiHost::OnKeepaliveCallback |
200 NaClBrowserDelegateImpl::GetOnKeepaliveCallback() { | 206 NaClBrowserDelegateImpl::GetOnKeepaliveCallback() { |
201 return base::Bind(&OnKeepalive); | 207 return base::Bind(&OnKeepalive); |
202 } | 208 } |
203 | 209 |
204 bool NaClBrowserDelegateImpl::IsNonSfiModeAllowed( | 210 bool NaClBrowserDelegateImpl::IsNonSfiModeAllowed( |
205 const base::FilePath& profile_directory, | 211 const base::FilePath& profile_directory, |
206 const GURL& manifest_url) { | 212 const GURL& manifest_url) { |
213 #if defined(ENABLE_EXTENSIONS) | |
207 const extensions::ExtensionSet* extension_set = | 214 const extensions::ExtensionSet* extension_set = |
208 &GetExtensionInfoMap(profile_directory)->extensions(); | 215 &GetExtensionInfoMap(profile_directory)->extensions(); |
209 return chrome::IsExtensionOrSharedModuleWhitelisted( | 216 return chrome::IsExtensionOrSharedModuleWhitelisted( |
210 manifest_url, extension_set, allowed_nonsfi_origins_); | 217 manifest_url, extension_set, allowed_nonsfi_origins_); |
218 #else | |
219 return false; | |
220 #endif | |
211 } | 221 } |
212 | 222 |
213 scoped_refptr<extensions::InfoMap> NaClBrowserDelegateImpl::GetExtensionInfoMap( | 223 scoped_refptr<extensions::InfoMap> NaClBrowserDelegateImpl::GetExtensionInfoMap( |
214 const base::FilePath& profile_directory) { | 224 const base::FilePath& profile_directory) { |
225 #if defined(ENABLE_EXTENSIONS) | |
215 // Get the profile associated with the renderer. | 226 // Get the profile associated with the renderer. |
216 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); | 227 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); |
217 DCHECK(profile); | 228 DCHECK(profile); |
218 scoped_refptr<extensions::InfoMap> extension_info_map = | 229 scoped_refptr<extensions::InfoMap> extension_info_map = |
219 extensions::ExtensionSystem::Get(profile)->info_map(); | 230 extensions::ExtensionSystem::Get(profile)->info_map(); |
220 DCHECK(extension_info_map); | 231 DCHECK(extension_info_map); |
221 return extension_info_map; | 232 return extension_info_map; |
233 #else | |
234 return NULL; | |
Mark Seaborn
2014/08/19 23:41:30
It doesn't look like all the call sites handle Get
David Yen
2014/08/21 17:31:48
This function is private so I believe you are righ
| |
235 #endif | |
222 } | 236 } |
OLD | NEW |