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

Unified Diff: extensions/browser/extension_util.cc

Issue 2758103003: Extensions: Move IsIncognitoEnabled to extensions/ from chrome/. (Closed)
Patch Set: -- 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..b09faae0f64e33848d10df212df78ee5c316866d 100644
--- a/extensions/browser/extension_util.cc
+++ b/extensions/browser/extension_util.cc
@@ -8,12 +8,26 @@
#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_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 +59,26 @@ 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 (!util::CanBeIncognitoEnabled(extension))
Devlin 2017/03/27 14:54:56 nit: this is now the same namespace as CanBeIncogn
karandeepb 2017/04/05 20:15:56 Done.
+ return false;
+ // If this is an existing component extension we always allow it to
+ // work in incognito mode.
+ if (extension->location() == Manifest::COMPONENT ||
Devlin 2017/03/27 14:54:56 nit: I know this was copy-paste, but since we're h
karandeepb 2017/04/05 20:15:56 Done.
+ extension->location() == Manifest::EXTERNAL_COMPONENT) {
+ 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