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" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/nacl_host/nacl_infobar_delegate.h" | 12 #include "chrome/browser/nacl_host/nacl_infobar_delegate.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" | 15 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory
.h" |
16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/chrome_paths_internal.h" | 17 #include "chrome/common/chrome_paths_internal.h" |
18 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
19 #include "chrome/common/logging_chrome.h" | 19 #include "chrome/common/logging_chrome.h" |
20 #include "chrome/common/pepper_permission_util.h" | 20 #include "chrome/common/pepper_permission_util.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/render_frame_host.h" | |
23 #include "content/public/browser/site_instance.h" | |
24 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
25 #include "extensions/browser/info_map.h" | 23 #include "extensions/browser/info_map.h" |
26 #include "extensions/browser/process_manager.h" | 24 #include "extensions/browser/process_manager.h" |
27 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
28 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
29 #include "extensions/common/url_pattern.h" | 27 #include "extensions/common/url_pattern.h" |
30 #include "ppapi/c/private/ppb_nacl_private.h" | 28 #include "ppapi/c/private/ppb_nacl_private.h" |
| 29 #include "url/gurl.h" |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 // These are temporarily needed for testing non-sfi mode on ChromeOS without | 33 // These are temporarily needed for testing non-sfi mode on ChromeOS without |
35 // passing command-line arguments to Chrome. | 34 // passing command-line arguments to Chrome. |
36 const char* const kAllowedNonSfiOrigins[] = { | 35 const char* const kAllowedNonSfiOrigins[] = { |
37 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/355141 | 36 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/355141 |
38 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/355141 | 37 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/355141 |
39 }; | 38 }; |
40 | 39 |
(...skipping 15 matching lines...) Expand all Loading... |
56 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, | 55 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, |
57 const base::FilePath& profile_data_directory) { | 56 const base::FilePath& profile_data_directory) { |
58 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
59 | 58 |
60 // 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 |
61 // embed of the same plugin exists on the same page. | 60 // embed of the same plugin exists on the same page. |
62 DCHECK(instance_data.size() == 1); | 61 DCHECK(instance_data.size() == 1); |
63 if (instance_data.size() < 1) | 62 if (instance_data.size() < 1) |
64 return; | 63 return; |
65 | 64 |
66 content::RenderFrameHost* render_frame_host = | 65 extensions::ProcessManager::OnKeepaliveFromPlugin( |
67 content::RenderFrameHost::FromID( | 66 instance_data[0].render_process_id, |
68 instance_data[0].render_process_id, instance_data[0].render_frame_id); | 67 instance_data[0].render_frame_id, |
69 if (!render_frame_host) | 68 instance_data[0].document_url.host()); |
70 return; | |
71 | |
72 content::SiteInstance* site_instance = render_frame_host->GetSiteInstance(); | |
73 if (!site_instance) | |
74 return; | |
75 | |
76 extensions::ExtensionSystem* extension_system = | |
77 extensions::ExtensionSystem::Get(site_instance->GetBrowserContext()); | |
78 if (!extension_system) | |
79 return; | |
80 | |
81 const ExtensionService* extension_service = | |
82 extension_system->extension_service(); | |
83 if (!extension_service) | |
84 return; | |
85 | |
86 const extensions::Extension* extension = extension_service->GetExtensionById( | |
87 instance_data[0].document_url.host(), false); | |
88 if (!extension) | |
89 return; | |
90 | |
91 extensions::ProcessManager* pm = extension_system->process_manager(); | |
92 if (!pm) | |
93 return; | |
94 | |
95 pm->KeepaliveImpulse(extension); | |
96 } | 69 } |
97 | 70 |
98 // Calls OnKeepaliveOnUIThread on UI thread. | 71 // Calls OnKeepaliveOnUIThread on UI thread. |
99 void OnKeepalive( | 72 void OnKeepalive( |
100 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, | 73 const content::BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, |
101 const base::FilePath& profile_data_directory) { | 74 const base::FilePath& profile_data_directory) { |
102 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 75 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
103 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 76 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
104 base::Bind(&OnKeepaliveOnUIThread, | 77 base::Bind(&OnKeepaliveOnUIThread, |
105 instance_data, | 78 instance_data, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 scoped_refptr<extensions::InfoMap> NaClBrowserDelegateImpl::GetExtensionInfoMap( | 213 scoped_refptr<extensions::InfoMap> NaClBrowserDelegateImpl::GetExtensionInfoMap( |
241 const base::FilePath& profile_directory) { | 214 const base::FilePath& profile_directory) { |
242 // Get the profile associated with the renderer. | 215 // Get the profile associated with the renderer. |
243 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); | 216 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); |
244 DCHECK(profile); | 217 DCHECK(profile); |
245 scoped_refptr<extensions::InfoMap> extension_info_map = | 218 scoped_refptr<extensions::InfoMap> extension_info_map = |
246 extensions::ExtensionSystem::Get(profile)->info_map(); | 219 extensions::ExtensionSystem::Get(profile)->info_map(); |
247 DCHECK(extension_info_map); | 220 DCHECK(extension_info_map); |
248 return extension_info_map; | 221 return extension_info_map; |
249 } | 222 } |
OLD | NEW |