| Index: extensions/browser/extension_util.cc
|
| diff --git a/extensions/browser/extension_util.cc b/extensions/browser/extension_util.cc
|
| index 142e1e482dd1e1725bf834e63cf5924018cbc51e..0961f42713d89262da4d95e577c38509cd741f95 100644
|
| --- a/extensions/browser/extension_util.cc
|
| +++ b/extensions/browser/extension_util.cc
|
| @@ -8,12 +8,27 @@
|
| #include "content/public/browser/site_instance.h"
|
| #include "extensions/browser/extension_prefs.h"
|
| #include "extensions/browser/extension_registry.h"
|
| +#include "extensions/common/features/behavior_feature.h"
|
| +#include "extensions/common/features/feature.h"
|
| +#include "extensions/common/features/feature_provider.h"
|
| +#include "extensions/common/manifest.h"
|
| #include "extensions/common/manifest_handlers/app_isolation_info.h"
|
| #include "extensions/common/manifest_handlers/incognito_info.h"
|
|
|
| namespace extensions {
|
| namespace util {
|
|
|
| +namespace {
|
| +
|
| +// Returns true if |extension| should always be enabled in incognito mode.
|
| +bool IsWhitelistedForIncognito(const Extension* extension) {
|
| + const Feature* feature = FeatureProvider::GetBehaviorFeature(
|
| + behavior_feature::kWhitelistedForIncognito);
|
| + return feature && feature->IsAvailableToExtension(extension).is_available();
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| bool HasIsolatedStorage(const ExtensionInfo& info) {
|
| if (!info.extension_manifest.get())
|
| return false;
|
| @@ -45,6 +60,24 @@ bool CanBeIncognitoEnabled(const Extension* extension) {
|
| extension->location() == Manifest::COMPONENT);
|
| }
|
|
|
| +bool IsIncognitoEnabled(const std::string& extension_id,
|
| + content::BrowserContext* context) {
|
| + const Extension* extension =
|
| + ExtensionRegistry::Get(context)->GetExtensionById(
|
| + extension_id, ExtensionRegistry::ENABLED);
|
| + if (extension) {
|
| + if (!CanBeIncognitoEnabled(extension))
|
| + return false;
|
| + // If this is an existing component extension we always allow it to
|
| + // work in incognito mode.
|
| + if (Manifest::IsComponentLocation(extension->location()))
|
| + return true;
|
| + if (IsWhitelistedForIncognito(extension))
|
| + return true;
|
| + }
|
| + return ExtensionPrefs::Get(context)->IsIncognitoEnabled(extension_id);
|
| +}
|
| +
|
| content::StoragePartition* GetStoragePartitionForExtensionId(
|
| const std::string& extension_id,
|
| content::BrowserContext* browser_context) {
|
|
|