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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 133 |
134 std::string NaClBrowserDelegateImpl::GetVersionString() const { | 134 std::string NaClBrowserDelegateImpl::GetVersionString() const { |
135 return chrome::VersionInfo().CreateVersionString(); | 135 return chrome::VersionInfo().CreateVersionString(); |
136 } | 136 } |
137 | 137 |
138 ppapi::host::HostFactory* NaClBrowserDelegateImpl::CreatePpapiHostFactory( | 138 ppapi::host::HostFactory* NaClBrowserDelegateImpl::CreatePpapiHostFactory( |
139 content::BrowserPpapiHost* ppapi_host) { | 139 content::BrowserPpapiHost* ppapi_host) { |
140 return new chrome::ChromeBrowserPepperHostFactory(ppapi_host); | 140 return new chrome::ChromeBrowserPepperHostFactory(ppapi_host); |
141 } | 141 } |
142 | 142 |
143 void NaClBrowserDelegateImpl::SetDebugPatterns(std::string debug_patterns) { | 143 void NaClBrowserDelegateImpl::SetDebugPatterns(std::string debug_patterns) { |
Lei Zhang
2015/01/21 21:32:22
BTW, would you mind making |debug_patterns| const
sehr
2015/01/22 19:57:22
Done.
| |
144 #if defined(ENABLE_EXTENSIONS) | |
144 if (!debug_patterns.empty() && debug_patterns[0] == '!') { | 145 if (!debug_patterns.empty() && debug_patterns[0] == '!') { |
145 inverse_debug_patterns_ = true; | 146 inverse_debug_patterns_ = true; |
146 debug_patterns.erase(0, 1); | 147 debug_patterns.erase(0, 1); |
147 } | 148 } |
148 if (debug_patterns.empty()) { | 149 if (debug_patterns.empty()) { |
149 return; | 150 return; |
150 } | 151 } |
151 std::vector<std::string> patterns; | 152 std::vector<std::string> patterns; |
152 base::SplitString(debug_patterns, ',', &patterns); | 153 base::SplitString(debug_patterns, ',', &patterns); |
153 for (std::vector<std::string>::iterator iter = patterns.begin(); | 154 for (std::vector<std::string>::iterator iter = patterns.begin(); |
154 iter != patterns.end(); ++iter) { | 155 iter != patterns.end(); ++iter) { |
155 // Allow chrome:// schema, which is used to filter out the internal | 156 // Allow chrome:// schema, which is used to filter out the internal |
156 // PNaCl translator. Also allow chrome-extension:// schema (which | 157 // PNaCl translator. Also allow chrome-extension:// schema (which |
157 // can have NaCl modules). The default is to disallow these schema | 158 // can have NaCl modules). The default is to disallow these schema |
158 // since they can be dangerous in the context of chrome extension | 159 // since they can be dangerous in the context of chrome extension |
159 // permissions, but they are okay here, for NaCl GDB avoidance. | 160 // permissions, but they are okay here, for NaCl GDB avoidance. |
160 URLPattern pattern(URLPattern::SCHEME_ALL); | 161 URLPattern pattern(URLPattern::SCHEME_ALL); |
161 if (pattern.Parse(*iter) == URLPattern::PARSE_SUCCESS) { | 162 if (pattern.Parse(*iter) == URLPattern::PARSE_SUCCESS) { |
162 // If URL pattern has scheme equal to *, Parse method resets valid | 163 // If URL pattern has scheme equal to *, Parse method resets valid |
163 // schemes mask to http and https only, so we need to reset it after | 164 // schemes mask to http and https only, so we need to reset it after |
164 // Parse to re-include chrome-extension and chrome schema. | 165 // Parse to re-include chrome-extension and chrome schema. |
165 pattern.SetValidSchemes(URLPattern::SCHEME_ALL); | 166 pattern.SetValidSchemes(URLPattern::SCHEME_ALL); |
166 debug_patterns_.push_back(pattern); | 167 debug_patterns_.push_back(pattern); |
167 } | 168 } |
168 } | 169 } |
170 #endif // defined(ENABLE_EXTENSIONS) | |
169 } | 171 } |
170 | 172 |
171 bool NaClBrowserDelegateImpl::URLMatchesDebugPatterns( | 173 bool NaClBrowserDelegateImpl::URLMatchesDebugPatterns( |
172 const GURL& manifest_url) { | 174 const GURL& manifest_url) { |
175 #if defined(ENABLE_EXTENSIONS) | |
173 // Empty patterns are forbidden so we ignore them. | 176 // Empty patterns are forbidden so we ignore them. |
174 if (debug_patterns_.empty()) { | 177 if (debug_patterns_.empty()) { |
175 return true; | 178 return true; |
176 } | 179 } |
177 bool matches = false; | 180 bool matches = false; |
178 for (std::vector<URLPattern>::iterator iter = debug_patterns_.begin(); | 181 for (std::vector<URLPattern>::iterator iter = debug_patterns_.begin(); |
179 iter != debug_patterns_.end(); ++iter) { | 182 iter != debug_patterns_.end(); ++iter) { |
180 if (iter->MatchesURL(manifest_url)) { | 183 if (iter->MatchesURL(manifest_url)) { |
181 matches = true; | 184 matches = true; |
182 break; | 185 break; |
183 } | 186 } |
184 } | 187 } |
185 if (inverse_debug_patterns_) { | 188 if (inverse_debug_patterns_) { |
186 return !matches; | 189 return !matches; |
187 } else { | 190 } else { |
188 return matches; | 191 return matches; |
189 } | 192 } |
193 #else | |
194 return false; | |
195 #endif // defined(ENABLE_EXTENSIONS) | |
190 } | 196 } |
191 | 197 |
192 // This function is security sensitive. Be sure to check with a security | 198 // This function is security sensitive. Be sure to check with a security |
193 // person before you modify it. | 199 // person before you modify it. |
194 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( | 200 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( |
bbudge
2015/01/21 21:22:07
It seems like the body of this fn could also be ex
Lei Zhang
2015/01/21 21:32:22
Looks like it already is excluded.
sehr
2015/01/22 19:57:22
It is already excluded, I think.
sehr
2015/01/22 19:57:22
Acknowledged.
| |
195 const GURL& file_url, | 201 const GURL& file_url, |
196 bool use_blocking_api, | 202 bool use_blocking_api, |
197 const base::FilePath& profile_directory, | 203 const base::FilePath& profile_directory, |
198 base::FilePath* file_path) { | 204 base::FilePath* file_path) { |
199 #if defined(ENABLE_EXTENSIONS) | 205 #if defined(ENABLE_EXTENSIONS) |
200 scoped_refptr<extensions::InfoMap> extension_info_map = | 206 scoped_refptr<extensions::InfoMap> extension_info_map = |
201 GetExtensionInfoMap(profile_directory); | 207 GetExtensionInfoMap(profile_directory); |
202 return extension_info_map->MapUrlToLocalFilePath( | 208 return extension_info_map->MapUrlToLocalFilePath( |
203 file_url, use_blocking_api, file_path); | 209 file_url, use_blocking_api, file_path); |
204 #else | 210 #else |
(...skipping 24 matching lines...) Expand all Loading... | |
229 const base::FilePath& profile_directory) { | 235 const base::FilePath& profile_directory) { |
230 // Get the profile associated with the renderer. | 236 // Get the profile associated with the renderer. |
231 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); | 237 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); |
232 DCHECK(profile); | 238 DCHECK(profile); |
233 scoped_refptr<extensions::InfoMap> extension_info_map = | 239 scoped_refptr<extensions::InfoMap> extension_info_map = |
234 extensions::ExtensionSystem::Get(profile)->info_map(); | 240 extensions::ExtensionSystem::Get(profile)->info_map(); |
235 DCHECK(extension_info_map.get()); | 241 DCHECK(extension_info_map.get()); |
236 return extension_info_map; | 242 return extension_info_map; |
237 } | 243 } |
238 #endif | 244 #endif |
OLD | NEW |