Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: extensions/browser/extension_util.cc

Issue 2758103003: Extensions: Move IsIncognitoEnabled to extensions/ from chrome/. (Closed)
Patch Set: Address review Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/extension_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « extensions/browser/extension_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698