This source file includes following definitions.
- IsWebScheme
- HasWebScheme
- IsExtensionScheme
- HasExtensionScheme
- DoesOriginMatchMask
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/child_process_security_policy.h"
#include "extensions/common/constants.h"
#include "url/gurl.h"
bool BrowsingDataHelper::IsWebScheme(const std::string& scheme) {
if (scheme == content::kFileScheme) {
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableFileCookies);
} else {
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
return (policy->IsWebSafeScheme(scheme) &&
!BrowsingDataHelper::IsExtensionScheme(scheme) &&
scheme != content::kChromeDevToolsScheme);
}
}
bool BrowsingDataHelper::HasWebScheme(const GURL& origin) {
return BrowsingDataHelper::IsWebScheme(origin.scheme());
}
bool BrowsingDataHelper::IsExtensionScheme(const std::string& scheme) {
return scheme == extensions::kExtensionScheme;
}
bool BrowsingDataHelper::HasExtensionScheme(const GURL& origin) {
return BrowsingDataHelper::IsExtensionScheme(origin.scheme());
}
bool BrowsingDataHelper::DoesOriginMatchMask(const GURL& origin,
int origin_set_mask, ExtensionSpecialStoragePolicy* policy) {
if (BrowsingDataHelper::HasExtensionScheme(origin.GetOrigin()) &&
origin_set_mask & EXTENSION)
return true;
if (!policy->IsStorageProtected(origin.GetOrigin()) &&
BrowsingDataHelper::HasWebScheme(origin.GetOrigin()) &&
origin_set_mask & UNPROTECTED_WEB)
return true;
if (policy->IsStorageProtected(origin.GetOrigin()) &&
BrowsingDataHelper::HasWebScheme(origin.GetOrigin()) &&
origin_set_mask & PROTECTED_WEB)
return true;
return false;
}