Chromium Code Reviews| 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 "chrome/browser/extensions/extension_system_impl.h" | 5 #include "chrome/browser/extensions/extension_system_impl.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram.h" | |
| 13 #include "base/strings/string_tokenizer.h" | 14 #include "base/strings/string_tokenizer.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/content_settings/cookie_settings.h" | 16 #include "chrome/browser/content_settings/cookie_settings.h" |
| 16 #include "chrome/browser/extensions/blacklist.h" | 17 #include "chrome/browser/extensions/blacklist.h" |
| 17 #include "chrome/browser/extensions/component_loader.h" | 18 #include "chrome/browser/extensions/component_loader.h" |
| 18 #include "chrome/browser/extensions/error_console/error_console.h" | 19 #include "chrome/browser/extensions/error_console/error_console.h" |
| 19 #include "chrome/browser/extensions/extension_error_reporter.h" | 20 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_system_factory.h" | 22 #include "chrome/browser/extensions/extension_system_factory.h" |
| 22 #include "chrome/browser/extensions/extension_util.h" | 23 #include "chrome/browser/extensions/extension_util.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 virtual std::set<base::FilePath> GetBrowserImagePaths( | 221 virtual std::set<base::FilePath> GetBrowserImagePaths( |
| 221 const extensions::Extension* extension) OVERRIDE { | 222 const extensions::Extension* extension) OVERRIDE { |
| 222 return extension_file_util::GetBrowserImagePaths(extension); | 223 return extension_file_util::GetBrowserImagePaths(extension); |
| 223 } | 224 } |
| 224 | 225 |
| 225 virtual void VerifyFailed(const std::string& extension_id) OVERRIDE { | 226 virtual void VerifyFailed(const std::string& extension_id) OVERRIDE { |
| 226 if (!service_) | 227 if (!service_) |
| 227 return; | 228 return; |
| 228 ExtensionRegistry* registry = ExtensionRegistry::Get(service_->profile()); | 229 ExtensionRegistry* registry = ExtensionRegistry::Get(service_->profile()); |
| 229 const Extension* extension = | 230 const Extension* extension = |
| 230 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); | 231 registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
| 231 if (!extension) | 232 if (!extension) |
| 232 return; | 233 return; |
| 233 Mode mode = ShouldBeVerified(*extension); | 234 Mode mode = ShouldBeVerified(*extension); |
| 234 if (mode >= ContentVerifierDelegate::ENFORCE) | 235 if (mode >= ContentVerifierDelegate::ENFORCE) { |
| 235 service_->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED); | 236 service_->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED); |
| 237 ExtensionPrefs::Get(service_->profile()) | |
| 238 ->IncrementCorruptedDisableCount(); | |
| 239 UMA_HISTOGRAM_BOOLEAN("Extensions.CorruptExtensionBecameDisabled", true); | |
| 240 } else if (!ContainsKey(would_be_disabled_ids_, extension_id)) { | |
|
Ken Rockot(use gerrit already)
2014/07/24 03:56:01
Your choice between readability vs efficiency here
asargent_no_longer_on_chrome
2014/07/24 17:08:12
I'm going to pick readability, since this won't be
| |
| 241 UMA_HISTOGRAM_BOOLEAN("Extensions.CorruptExtensionWouldBeDisabled", true); | |
| 242 would_be_disabled_ids_.insert(extension_id); | |
| 243 } | |
| 236 } | 244 } |
| 237 | 245 |
| 238 static Mode GetDefaultMode() { | 246 static Mode GetDefaultMode() { |
| 239 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 247 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 240 | 248 |
| 241 Mode experiment_value = NONE; | 249 Mode experiment_value = NONE; |
| 242 const std::string group = base::FieldTrialList::FindFullName( | 250 const std::string group = base::FieldTrialList::FindFullName( |
| 243 kContentVerificationExperimentName); | 251 kContentVerificationExperimentName); |
| 244 if (group == "EnforceStrict") | 252 if (group == "EnforceStrict") |
| 245 experiment_value = ContentVerifierDelegate::ENFORCE_STRICT; | 253 experiment_value = ContentVerifierDelegate::ENFORCE_STRICT; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 | 288 |
| 281 // We don't want to allow the command-line flags to eg disable enforcement | 289 // We don't want to allow the command-line flags to eg disable enforcement |
| 282 // if the experiment group says it should be on, or malware may just modify | 290 // if the experiment group says it should be on, or malware may just modify |
| 283 // the command line flags. So return the more restrictive of the 2 values. | 291 // the command line flags. So return the more restrictive of the 2 values. |
| 284 return std::max(experiment_value, cmdline_value); | 292 return std::max(experiment_value, cmdline_value); |
| 285 } | 293 } |
| 286 | 294 |
| 287 private: | 295 private: |
| 288 base::WeakPtr<ExtensionService> service_; | 296 base::WeakPtr<ExtensionService> service_; |
| 289 ContentVerifierDelegate::Mode default_mode_; | 297 ContentVerifierDelegate::Mode default_mode_; |
| 298 | |
| 299 // For reporting metrics in BOOTSTRAP mode, when an extension would be | |
| 300 // disabled if content verification was in ENFORCE mode. | |
| 301 std::set<std::string> would_be_disabled_ids_; | |
| 302 | |
| 290 DISALLOW_COPY_AND_ASSIGN(ContentVerifierDelegateImpl); | 303 DISALLOW_COPY_AND_ASSIGN(ContentVerifierDelegateImpl); |
| 291 }; | 304 }; |
| 292 | 305 |
| 293 } // namespace | 306 } // namespace |
| 294 | 307 |
| 295 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { | 308 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { |
| 296 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 309 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 297 | 310 |
| 298 navigation_observer_.reset(new NavigationObserver(profile_)); | 311 navigation_observer_.reset(new NavigationObserver(profile_)); |
| 299 | 312 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 634 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
| 622 const std::string& extension_id, | 635 const std::string& extension_id, |
| 623 const UnloadedExtensionInfo::Reason reason) { | 636 const UnloadedExtensionInfo::Reason reason) { |
| 624 BrowserThread::PostTask( | 637 BrowserThread::PostTask( |
| 625 BrowserThread::IO, | 638 BrowserThread::IO, |
| 626 FROM_HERE, | 639 FROM_HERE, |
| 627 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); | 640 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
| 628 } | 641 } |
| 629 | 642 |
| 630 } // namespace extensions | 643 } // namespace extensions |
| OLD | NEW |