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

Unified Diff: chrome/browser/extensions/extension_special_storage_policy.cc

Issue 2351803002: Switching ExtensionSpecialStoragePolicy::IsStorageDurable to use DurableStoragePermissionContext. (Closed)
Patch Set: Using PermissionManager::Get(). Created 4 years, 3 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
Index: chrome/browser/extensions/extension_special_storage_policy.cc
diff --git a/chrome/browser/extensions/extension_special_storage_policy.cc b/chrome/browser/extensions/extension_special_storage_policy.cc
index 95e0719eeaae0de24292da927d0474132e6cce82..da51df6114408f852346cf6960f1a952116604fa 100644
--- a/chrome/browser/extensions/extension_special_storage_policy.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy.cc
@@ -15,6 +15,8 @@
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
+#include "chrome/browser/permissions/permission_manager.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/url_constants.h"
@@ -23,6 +25,7 @@
#include "components/content_settings/core/common/content_settings_types.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/permission_type.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
@@ -80,8 +83,12 @@ void LogHostedAppUnlimitedStorageUsage(
} // namespace
ExtensionSpecialStoragePolicy::ExtensionSpecialStoragePolicy(
- content_settings::CookieSettings* cookie_settings)
- : cookie_settings_(cookie_settings) {
+ content::BrowserContext* browser_context)
+ : browser_context_(browser_context) {
+ if (browser_context_) {
+ Profile* profile = Profile::FromBrowserContext(browser_context_);
+ cookie_settings_ = CookieSettingsFactory::GetForProfile(profile).get();
+ }
}
ExtensionSpecialStoragePolicy::~ExtensionSpecialStoragePolicy() {}
@@ -109,7 +116,7 @@ bool ExtensionSpecialStoragePolicy::IsStorageUnlimited(const GURL& origin) {
}
bool ExtensionSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) {
- if (cookie_settings_.get() == NULL)
+ if (cookie_settings_ == NULL)
pfeldman 2016/09/23 17:12:20 Since you touch those lines, you could migrate the
return false;
return cookie_settings_->IsCookieSessionOnly(origin);
}
@@ -120,7 +127,7 @@ bool ExtensionSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) {
}
bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() {
- if (cookie_settings_.get() == NULL)
+ if (cookie_settings_ == NULL)
return false;
if (cookie_settings_->GetDefaultCookieSetting(NULL) ==
CONTENT_SETTING_SESSION_ONLY)
@@ -140,7 +147,11 @@ bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
}
bool ExtensionSpecialStoragePolicy::IsStorageDurable(const GURL& origin) {
- return cookie_settings_->IsStorageDurable(origin);
+ Profile* profile = Profile::FromBrowserContext(browser_context_);
pfeldman 2016/09/23 17:12:20 Just store a pointer to the profile, no need to co
+ blink::mojom::PermissionStatus status =
+ PermissionManager::Get(profile)->GetPermissionStatus(
+ content::PermissionType::DURABLE_STORAGE, origin, origin);
+ return status == blink::mojom::PermissionStatus::GRANTED;
}
bool ExtensionSpecialStoragePolicy::NeedsProtection(

Powered by Google App Engine
This is Rietveld 408576698