Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index c124c7220426bfb711cdadf209dff771b5f2d326..c7ef94cb4cbbb53591dcd2a83110be8b57fb7844 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/command_line.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/sha1.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -1990,6 +1991,9 @@ void ExtensionService::FinishInstallation( |
| extension_prefs_->SetAllowFileAccess(extension->id(), true); |
| } |
| + if (ShouldEnableForIncognito(extension)) |
| + extension_prefs_->SetIsIncognitoEnabled(extension->id(), true); |
| + |
| AddExtension(extension); |
| // If this is a new external extension that was disabled, alert the user |
| @@ -2536,6 +2540,32 @@ void ExtensionService::RemoveUpdateObserver( |
| update_observers_.RemoveObserver(observer); |
| } |
| +bool ExtensionService::ShouldEnableForIncognito( |
| + const extensions::Extension* extension) { |
| + // NB: Component extensions are already always enabled via logic in |
| + // extensions::util::IsIncognitoEnabled. |
| + if (extension->location() != Manifest::EXTERNAL_COMPONENT) |
| + return false; |
| + |
| + // External component extensions with hashes in this array are always enabled |
| + // in incognito mode. |
| + static const char* kIncognitoEnabledExternalComponentExtensionHash[] = { |
| + "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900 |
| + "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444 |
| + "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562 |
|
not at google - send to devlin
2014/06/18 00:42:02
This code would be better contained in here, is wh
Mike Wittman
2014/06/18 03:17:50
Moved the hashes and logic to extension_utils.{cc,
|
| + }; |
| + |
| + std::string hash = base::SHA1HashString(extension->id()); |
| + hash = base::HexEncode(hash.c_str(), hash.length()); |
| + for (size_t i = 0; |
| + i < arraysize(kIncognitoEnabledExternalComponentExtensionHash); i++) { |
| + if (hash == kIncognitoEnabledExternalComponentExtensionHash[i]) |
| + return true; |
| + } |
| + |
| + return true; |
| +} |
| + |
| // Used only by test code. |
| void ExtensionService::UnloadAllExtensionsInternal() { |
| profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |