OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_nacl_browser_delegate.h" | 5 #include "extensions/shell/browser/shell_nacl_browser_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
24 #include "extensions/common/url_pattern.h" | 24 #include "extensions/common/url_pattern.h" |
25 #include "extensions/shell/common/version.h" // Generated file. | 25 #include "extensions/shell/common/version.h" // Generated file. |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
28 using content::BrowserContext; | 28 using content::BrowserContext; |
29 using content::BrowserThread; | 29 using content::BrowserThread; |
30 using content::BrowserPpapiHost; | 30 using content::BrowserPpapiHost; |
31 | 31 |
32 namespace extensions { | 32 namespace extensions { |
33 namespace { | |
34 | |
35 // Handles an extension's NaCl process transitioning in or out of idle state by | |
36 // relaying the state to the extension's process manager. See Chrome's | |
37 // NaClBrowserDelegateImpl for another example. | |
38 void OnKeepaliveOnUIThread( | |
39 const BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, | |
40 const base::FilePath& profile_data_directory) { | |
41 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
42 | |
43 // Only one instance will exist for NaCl embeds, even when more than one | |
44 // embed of the same plugin exists on the same page. | |
45 DCHECK(instance_data.size() == 1); | |
46 if (instance_data.size() < 1) | |
47 return; | |
48 | |
49 ProcessManager::OnKeepaliveFromPlugin(instance_data[0].render_process_id, | |
50 instance_data[0].render_frame_id, | |
51 instance_data[0].document_url.host()); | |
52 } | |
53 | |
54 // Calls OnKeepaliveOnUIThread on UI thread. | |
55 void OnKeepalive(const BrowserPpapiHost::OnKeepaliveInstanceData& instance_data, | |
56 const base::FilePath& profile_data_directory) { | |
57 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
58 BrowserThread::PostTask( | |
59 BrowserThread::UI, | |
60 FROM_HERE, | |
61 base::Bind( | |
62 &OnKeepaliveOnUIThread, instance_data, profile_data_directory)); | |
63 } | |
64 | |
65 } // namespace | |
66 | 33 |
67 ShellNaClBrowserDelegate::ShellNaClBrowserDelegate(BrowserContext* context) | 34 ShellNaClBrowserDelegate::ShellNaClBrowserDelegate(BrowserContext* context) |
68 : browser_context_(context) { | 35 : browser_context_(context) { |
69 DCHECK(browser_context_); | 36 DCHECK(browser_context_); |
70 } | 37 } |
71 | 38 |
72 ShellNaClBrowserDelegate::~ShellNaClBrowserDelegate() { | 39 ShellNaClBrowserDelegate::~ShellNaClBrowserDelegate() { |
73 } | 40 } |
74 | 41 |
75 void ShellNaClBrowserDelegate::ShowMissingArchInfobar(int render_process_id, | 42 void ShellNaClBrowserDelegate::ShowMissingArchInfobar(int render_process_id, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 142 |
176 // GetFilePath is a blocking function call. | 143 // GetFilePath is a blocking function call. |
177 const base::FilePath resource_file_path = resource.GetFilePath(); | 144 const base::FilePath resource_file_path = resource.GetFilePath(); |
178 if (resource_file_path.empty()) | 145 if (resource_file_path.empty()) |
179 return false; | 146 return false; |
180 | 147 |
181 *file_path = resource_file_path; | 148 *file_path = resource_file_path; |
182 return true; | 149 return true; |
183 } | 150 } |
184 | 151 |
185 content::BrowserPpapiHost::OnKeepaliveCallback | |
186 ShellNaClBrowserDelegate::GetOnKeepaliveCallback() { | |
187 return base::Bind(&OnKeepalive); | |
188 } | |
189 | |
190 bool ShellNaClBrowserDelegate::IsNonSfiModeAllowed( | 152 bool ShellNaClBrowserDelegate::IsNonSfiModeAllowed( |
191 const base::FilePath& profile_directory, | 153 const base::FilePath& profile_directory, |
192 const GURL& manifest_url) { | 154 const GURL& manifest_url) { |
193 return false; | 155 return false; |
194 } | 156 } |
195 | 157 |
196 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |