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( |
| 144 const std::string& debug_patterns) { |
| 145 #if defined(ENABLE_EXTENSIONS) |
144 if (!debug_patterns.empty() && debug_patterns[0] == '!') { | 146 if (!debug_patterns.empty() && debug_patterns[0] == '!') { |
145 inverse_debug_patterns_ = true; | 147 inverse_debug_patterns_ = true; |
146 debug_patterns.erase(0, 1); | 148 debug_patterns.erase(0, 1); |
147 } | 149 } |
148 if (debug_patterns.empty()) { | 150 if (debug_patterns.empty()) { |
149 return; | 151 return; |
150 } | 152 } |
151 std::vector<std::string> patterns; | 153 std::vector<std::string> patterns; |
152 base::SplitString(debug_patterns, ',', &patterns); | 154 base::SplitString(debug_patterns, ',', &patterns); |
153 for (std::vector<std::string>::iterator iter = patterns.begin(); | 155 for (std::vector<std::string>::iterator iter = patterns.begin(); |
154 iter != patterns.end(); ++iter) { | 156 iter != patterns.end(); ++iter) { |
155 // Allow chrome:// schema, which is used to filter out the internal | 157 // Allow chrome:// schema, which is used to filter out the internal |
156 // PNaCl translator. Also allow chrome-extension:// schema (which | 158 // PNaCl translator. Also allow chrome-extension:// schema (which |
157 // can have NaCl modules). The default is to disallow these schema | 159 // can have NaCl modules). The default is to disallow these schema |
158 // since they can be dangerous in the context of chrome extension | 160 // since they can be dangerous in the context of chrome extension |
159 // permissions, but they are okay here, for NaCl GDB avoidance. | 161 // permissions, but they are okay here, for NaCl GDB avoidance. |
160 URLPattern pattern(URLPattern::SCHEME_ALL); | 162 URLPattern pattern(URLPattern::SCHEME_ALL); |
161 if (pattern.Parse(*iter) == URLPattern::PARSE_SUCCESS) { | 163 if (pattern.Parse(*iter) == URLPattern::PARSE_SUCCESS) { |
162 // If URL pattern has scheme equal to *, Parse method resets valid | 164 // 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 | 165 // schemes mask to http and https only, so we need to reset it after |
164 // Parse to re-include chrome-extension and chrome schema. | 166 // Parse to re-include chrome-extension and chrome schema. |
165 pattern.SetValidSchemes(URLPattern::SCHEME_ALL); | 167 pattern.SetValidSchemes(URLPattern::SCHEME_ALL); |
166 debug_patterns_.push_back(pattern); | 168 debug_patterns_.push_back(pattern); |
167 } | 169 } |
168 } | 170 } |
| 171 #endif // defined(ENABLE_EXTENSIONS) |
169 } | 172 } |
170 | 173 |
171 bool NaClBrowserDelegateImpl::URLMatchesDebugPatterns( | 174 bool NaClBrowserDelegateImpl::URLMatchesDebugPatterns( |
172 const GURL& manifest_url) { | 175 const GURL& manifest_url) { |
| 176 #if defined(ENABLE_EXTENSIONS) |
173 // Empty patterns are forbidden so we ignore them. | 177 // Empty patterns are forbidden so we ignore them. |
174 if (debug_patterns_.empty()) { | 178 if (debug_patterns_.empty()) { |
175 return true; | 179 return true; |
176 } | 180 } |
177 bool matches = false; | 181 bool matches = false; |
178 for (std::vector<URLPattern>::iterator iter = debug_patterns_.begin(); | 182 for (std::vector<URLPattern>::iterator iter = debug_patterns_.begin(); |
179 iter != debug_patterns_.end(); ++iter) { | 183 iter != debug_patterns_.end(); ++iter) { |
180 if (iter->MatchesURL(manifest_url)) { | 184 if (iter->MatchesURL(manifest_url)) { |
181 matches = true; | 185 matches = true; |
182 break; | 186 break; |
183 } | 187 } |
184 } | 188 } |
185 if (inverse_debug_patterns_) { | 189 if (inverse_debug_patterns_) { |
186 return !matches; | 190 return !matches; |
187 } else { | 191 } else { |
188 return matches; | 192 return matches; |
189 } | 193 } |
| 194 #else |
| 195 return false; |
| 196 #endif // defined(ENABLE_EXTENSIONS) |
190 } | 197 } |
191 | 198 |
192 // This function is security sensitive. Be sure to check with a security | 199 // This function is security sensitive. Be sure to check with a security |
193 // person before you modify it. | 200 // person before you modify it. |
194 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( | 201 bool NaClBrowserDelegateImpl::MapUrlToLocalFilePath( |
195 const GURL& file_url, | 202 const GURL& file_url, |
196 bool use_blocking_api, | 203 bool use_blocking_api, |
197 const base::FilePath& profile_directory, | 204 const base::FilePath& profile_directory, |
198 base::FilePath* file_path) { | 205 base::FilePath* file_path) { |
199 #if defined(ENABLE_EXTENSIONS) | 206 #if defined(ENABLE_EXTENSIONS) |
(...skipping 29 matching lines...) Expand all Loading... |
229 const base::FilePath& profile_directory) { | 236 const base::FilePath& profile_directory) { |
230 // Get the profile associated with the renderer. | 237 // Get the profile associated with the renderer. |
231 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); | 238 Profile* profile = profile_manager_->GetProfileByPath(profile_directory); |
232 DCHECK(profile); | 239 DCHECK(profile); |
233 scoped_refptr<extensions::InfoMap> extension_info_map = | 240 scoped_refptr<extensions::InfoMap> extension_info_map = |
234 extensions::ExtensionSystem::Get(profile)->info_map(); | 241 extensions::ExtensionSystem::Get(profile)->info_map(); |
235 DCHECK(extension_info_map.get()); | 242 DCHECK(extension_info_map.get()); |
236 return extension_info_map; | 243 return extension_info_map; |
237 } | 244 } |
238 #endif | 245 #endif |
OLD | NEW |