Commit ff585652 authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

ContentSettings: Prefer allowlist.

Replace all uses of whitelist with allowlist in ContentSettings code.

Bug: 842296
Change-Id: I51442289ad63651313515ab3e2db76e2bc2dfe06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2439554Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Darwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812949}
parent f9b59f38
...@@ -309,7 +309,7 @@ TEST_F(PluginInfoHostImplTest, RunAllFlashInAllowMode) { ...@@ -309,7 +309,7 @@ TEST_F(PluginInfoHostImplTest, RunAllFlashInAllowMode) {
EXPECT_THAT(status, Eq(chrome::mojom::PluginStatus::kAllowed)); EXPECT_THAT(status, Eq(chrome::mojom::PluginStatus::kAllowed));
} }
TEST_F(PluginInfoHostImplTest, PluginsOnlyAllowedInWhitelistedSchemes) { TEST_F(PluginInfoHostImplTest, PluginsOnlyAllowedInAllowlistedSchemes) {
host_content_settings_map()->SetDefaultContentSetting( host_content_settings_map()->SetDefaultContentSetting(
ContentSettingsType::PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); ContentSettingsType::PLUGINS, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
......
...@@ -292,7 +292,7 @@ bool IsPatternValidForType(const std::string& pattern_string, ...@@ -292,7 +292,7 @@ bool IsPatternValidForType(const std::string& pattern_string,
// Don't allow patterns for WebUI schemes, even though it's a valid pattern. // Don't allow patterns for WebUI schemes, even though it's a valid pattern.
// WebUI permissions are controlled by ContentSettingsRegistry // WebUI permissions are controlled by ContentSettingsRegistry
// WhitelistedSchemes and WebUIAllowlist. Users shouldn't be able to grant // AllowlistedSchemes and WebUIAllowlist. Users shouldn't be able to grant
// extra permissions or revoke existing permissions. // extra permissions or revoke existing permissions.
if (pattern.GetScheme() == ContentSettingsPattern::SCHEME_CHROME || if (pattern.GetScheme() == ContentSettingsPattern::SCHEME_CHROME ||
pattern.GetScheme() == ContentSettingsPattern::SCHEME_CHROMEUNTRUSTED || pattern.GetScheme() == ContentSettingsPattern::SCHEME_CHROMEUNTRUSTED ||
......
...@@ -57,7 +57,7 @@ bool ChromeContentSettingsAgentDelegate::IsPluginTemporarilyAllowed( ...@@ -57,7 +57,7 @@ bool ChromeContentSettingsAgentDelegate::IsPluginTemporarilyAllowed(
base::Contains(temporarily_allowed_plugins_, std::string()); base::Contains(temporarily_allowed_plugins_, std::string());
} }
bool ChromeContentSettingsAgentDelegate::IsSchemeWhitelisted( bool ChromeContentSettingsAgentDelegate::IsSchemeAllowlisted(
const std::string& scheme) { const std::string& scheme) {
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
return scheme == extensions::kExtensionScheme; return scheme == extensions::kExtensionScheme;
......
...@@ -34,7 +34,7 @@ class ChromeContentSettingsAgentDelegate ...@@ -34,7 +34,7 @@ class ChromeContentSettingsAgentDelegate
bool IsPluginTemporarilyAllowed(const std::string& identifier); bool IsPluginTemporarilyAllowed(const std::string& identifier);
// content_settings::ContentSettingsAgentImpl::Delegate: // content_settings::ContentSettingsAgentImpl::Delegate:
bool IsSchemeWhitelisted(const std::string& scheme) override; bool IsSchemeAllowlisted(const std::string& scheme) override;
base::Optional<bool> AllowReadFromClipboard() override; base::Optional<bool> AllowReadFromClipboard() override;
base::Optional<bool> AllowWriteToClipboard() override; base::Optional<bool> AllowWriteToClipboard() override;
base::Optional<bool> AllowMutationEvents() override; base::Optional<bool> AllowMutationEvents() override;
......
...@@ -12,13 +12,13 @@ namespace content_settings { ...@@ -12,13 +12,13 @@ namespace content_settings {
ContentSettingsInfo::ContentSettingsInfo( ContentSettingsInfo::ContentSettingsInfo(
const WebsiteSettingsInfo* website_settings_info, const WebsiteSettingsInfo* website_settings_info,
const std::vector<std::string>& whitelisted_schemes, const std::vector<std::string>& allowlisted_schemes,
const std::set<ContentSetting>& valid_settings, const std::set<ContentSetting>& valid_settings,
IncognitoBehavior incognito_behavior, IncognitoBehavior incognito_behavior,
StorageBehavior storage_behavior, StorageBehavior storage_behavior,
OriginRestriction origin_restriction) OriginRestriction origin_restriction)
: website_settings_info_(website_settings_info), : website_settings_info_(website_settings_info),
whitelisted_schemes_(whitelisted_schemes), allowlisted_schemes_(allowlisted_schemes),
valid_settings_(valid_settings), valid_settings_(valid_settings),
incognito_behavior_(incognito_behavior), incognito_behavior_(incognito_behavior),
storage_behavior_(storage_behavior), storage_behavior_(storage_behavior),
......
...@@ -50,7 +50,7 @@ class ContentSettingsInfo { ...@@ -50,7 +50,7 @@ class ContentSettingsInfo {
// This object does not take ownership of |website_settings_info|. // This object does not take ownership of |website_settings_info|.
ContentSettingsInfo(const WebsiteSettingsInfo* website_settings_info, ContentSettingsInfo(const WebsiteSettingsInfo* website_settings_info,
const std::vector<std::string>& whitelisted_schemes, const std::vector<std::string>& allowlisted_schemes,
const std::set<ContentSetting>& valid_settings, const std::set<ContentSetting>& valid_settings,
IncognitoBehavior incognito_behavior, IncognitoBehavior incognito_behavior,
StorageBehavior storage_behavior, StorageBehavior storage_behavior,
...@@ -60,8 +60,8 @@ class ContentSettingsInfo { ...@@ -60,8 +60,8 @@ class ContentSettingsInfo {
const WebsiteSettingsInfo* website_settings_info() const { const WebsiteSettingsInfo* website_settings_info() const {
return website_settings_info_; return website_settings_info_;
} }
const std::vector<std::string>& whitelisted_schemes() const { const std::vector<std::string>& allowlisted_schemes() const {
return whitelisted_schemes_; return allowlisted_schemes_;
} }
// Gets the original default setting for a particular content type. // Gets the original default setting for a particular content type.
...@@ -76,7 +76,7 @@ class ContentSettingsInfo { ...@@ -76,7 +76,7 @@ class ContentSettingsInfo {
private: private:
const WebsiteSettingsInfo* website_settings_info_; const WebsiteSettingsInfo* website_settings_info_;
const std::vector<std::string> whitelisted_schemes_; const std::vector<std::string> allowlisted_schemes_;
const std::set<ContentSetting> valid_settings_; const std::set<ContentSetting> valid_settings_;
const IncognitoBehavior incognito_behavior_; const IncognitoBehavior incognito_behavior_;
const StorageBehavior storage_behavior_; const StorageBehavior storage_behavior_;
......
...@@ -62,7 +62,7 @@ class ContentSettingsRegistry { ...@@ -62,7 +62,7 @@ class ContentSettingsRegistry {
const std::string& name, const std::string& name,
ContentSetting initial_default_value, ContentSetting initial_default_value,
WebsiteSettingsInfo::SyncStatus sync_status, WebsiteSettingsInfo::SyncStatus sync_status,
const std::vector<std::string>& whitelisted_schemes, const std::vector<std::string>& allowlisted_schemes,
const std::set<ContentSetting>& valid_settings, const std::set<ContentSetting>& valid_settings,
WebsiteSettingsInfo::ScopingType scoping_type, WebsiteSettingsInfo::ScopingType scoping_type,
Platforms platforms, Platforms platforms,
......
...@@ -68,7 +68,7 @@ TEST_F(ContentSettingsRegistryTest, Properties) { ...@@ -68,7 +68,7 @@ TEST_F(ContentSettingsRegistryTest, Properties) {
registry()->Get(ContentSettingsType::COOKIES); registry()->Get(ContentSettingsType::COOKIES);
ASSERT_TRUE(info); ASSERT_TRUE(info);
EXPECT_THAT(info->whitelisted_schemes(), ElementsAre("chrome", "devtools")); EXPECT_THAT(info->allowlisted_schemes(), ElementsAre("chrome", "devtools"));
// Check the other properties are populated correctly. // Check the other properties are populated correctly.
EXPECT_TRUE(info->IsSettingValid(CONTENT_SETTING_SESSION_ONLY)); EXPECT_TRUE(info->IsSettingValid(CONTENT_SETTING_SESSION_ONLY));
......
...@@ -149,7 +149,7 @@ class CookieSettingsTest : public testing::Test { ...@@ -149,7 +149,7 @@ class CookieSettingsTest : public testing::Test {
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
}; };
TEST_F(CookieSettingsTest, TestWhitelistedScheme) { TEST_F(CookieSettingsTest, TestAllowlistedScheme) {
cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); cookie_settings_->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
EXPECT_FALSE(cookie_settings_->IsCookieAccessAllowed(kHttpSite, kChromeURL)); EXPECT_FALSE(cookie_settings_->IsCookieAccessAllowed(kHttpSite, kChromeURL));
EXPECT_TRUE(cookie_settings_->IsCookieAccessAllowed(kHttpsSite, kChromeURL)); EXPECT_TRUE(cookie_settings_->IsCookieAccessAllowed(kHttpsSite, kChromeURL));
......
...@@ -107,7 +107,7 @@ bool SupportsResourceIdentifier(ContentSettingsType content_type) { ...@@ -107,7 +107,7 @@ bool SupportsResourceIdentifier(ContentSettingsType content_type) {
return content_type == ContentSettingsType::PLUGINS; return content_type == ContentSettingsType::PLUGINS;
} }
bool SchemeCanBeWhitelisted(const std::string& scheme) { bool SchemeCanBeAllowlisted(const std::string& scheme) {
return scheme == content_settings::kChromeDevToolsScheme || return scheme == content_settings::kChromeDevToolsScheme ||
scheme == content_settings::kExtensionScheme || scheme == content_settings::kExtensionScheme ||
scheme == content_settings::kChromeUIScheme; scheme == content_settings::kChromeUIScheme;
...@@ -895,7 +895,7 @@ std::unique_ptr<base::Value> HostContentSettingsMap::GetWebsiteSetting( ...@@ -895,7 +895,7 @@ std::unique_ptr<base::Value> HostContentSettingsMap::GetWebsiteSetting(
DCHECK(SupportsResourceIdentifier(content_type) || DCHECK(SupportsResourceIdentifier(content_type) ||
resource_identifier.empty()); resource_identifier.empty());
// Check if the requested setting is whitelisted. // Check if the requested setting is allowlisted.
// TODO(raymes): Move this into GetContentSetting. This has nothing to do with // TODO(raymes): Move this into GetContentSetting. This has nothing to do with
// website settings // website settings
const content_settings::ContentSettingsInfo* content_settings_info = const content_settings::ContentSettingsInfo* content_settings_info =
...@@ -903,8 +903,8 @@ std::unique_ptr<base::Value> HostContentSettingsMap::GetWebsiteSetting( ...@@ -903,8 +903,8 @@ std::unique_ptr<base::Value> HostContentSettingsMap::GetWebsiteSetting(
content_type); content_type);
if (content_settings_info) { if (content_settings_info) {
for (const std::string& scheme : for (const std::string& scheme :
content_settings_info->whitelisted_schemes()) { content_settings_info->allowlisted_schemes()) {
DCHECK(SchemeCanBeWhitelisted(scheme)); DCHECK(SchemeCanBeAllowlisted(scheme));
if (primary_url.SchemeIs(scheme)) { if (primary_url.SchemeIs(scheme)) {
if (info) { if (info) {
......
...@@ -107,7 +107,7 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -107,7 +107,7 @@ class HostContentSettingsMap : public content_settings::Observer,
std::string* provider_id) const; std::string* provider_id) const;
// Returns a single |ContentSetting| which applies to the given URLs. Note // Returns a single |ContentSetting| which applies to the given URLs. Note
// that certain internal schemes are whitelisted. For |CONTENT_TYPE_COOKIES|, // that certain internal schemes are allowlisted. For |CONTENT_TYPE_COOKIES|,
// |CookieSettings| should be used instead. For content types that can't be // |CookieSettings| should be used instead. For content types that can't be
// converted to a |ContentSetting|, |GetContentSettingValue| should be called. // converted to a |ContentSetting|, |GetContentSettingValue| should be called.
// If there is no content setting, returns CONTENT_SETTING_DEFAULT. // If there is no content setting, returns CONTENT_SETTING_DEFAULT.
...@@ -132,7 +132,7 @@ class HostContentSettingsMap : public content_settings::Observer, ...@@ -132,7 +132,7 @@ class HostContentSettingsMap : public content_settings::Observer,
// source of the returned |Value| (POLICY, EXTENSION, USER, ...) and the // source of the returned |Value| (POLICY, EXTENSION, USER, ...) and the
// |primary_pattern| and the |secondary_pattern| fields of |info| are set to // |primary_pattern| and the |secondary_pattern| fields of |info| are set to
// the patterns of the applying rule. Note that certain internal schemes are // the patterns of the applying rule. Note that certain internal schemes are
// whitelisted. For whitelisted schemes the |source| field of |info| is set // allowlisted. For allowlisted schemes the |source| field of |info| is set
// the |SETTING_SOURCE_ALLOWLIST| and the |primary_pattern| and // the |SETTING_SOURCE_ALLOWLIST| and the |primary_pattern| and
// |secondary_pattern| are set to a wildcard pattern. If there is no content // |secondary_pattern| are set to a wildcard pattern. If there is no content
// setting, NULL is returned and the |source| field of |info| is set to // setting, NULL is returned and the |source| field of |info| is set to
......
...@@ -76,7 +76,7 @@ bool IsFrameWithOpaqueOrigin(WebFrame* frame) { ...@@ -76,7 +76,7 @@ bool IsFrameWithOpaqueOrigin(WebFrame* frame) {
ContentSettingsAgentImpl::Delegate::~Delegate() = default; ContentSettingsAgentImpl::Delegate::~Delegate() = default;
bool ContentSettingsAgentImpl::Delegate::IsSchemeWhitelisted( bool ContentSettingsAgentImpl::Delegate::IsSchemeAllowlisted(
const std::string& scheme) { const std::string& scheme) {
return false; return false;
} }
...@@ -100,12 +100,12 @@ void ContentSettingsAgentImpl::Delegate::PassiveInsecureContentFound( ...@@ -100,12 +100,12 @@ void ContentSettingsAgentImpl::Delegate::PassiveInsecureContentFound(
ContentSettingsAgentImpl::ContentSettingsAgentImpl( ContentSettingsAgentImpl::ContentSettingsAgentImpl(
content::RenderFrame* render_frame, content::RenderFrame* render_frame,
bool should_whitelist, bool should_allowlist,
std::unique_ptr<Delegate> delegate) std::unique_ptr<Delegate> delegate)
: content::RenderFrameObserver(render_frame), : content::RenderFrameObserver(render_frame),
content::RenderFrameObserverTracker<ContentSettingsAgentImpl>( content::RenderFrameObserverTracker<ContentSettingsAgentImpl>(
render_frame), render_frame),
should_whitelist_(should_whitelist), should_allowlist_(should_allowlist),
delegate_(std::move(delegate)) { delegate_(std::move(delegate)) {
DCHECK(delegate_); DCHECK(delegate_);
ClearBlockedContentSettings(); ClearBlockedContentSettings();
...@@ -337,7 +337,7 @@ bool ContentSettingsAgentImpl::AllowImage(bool enabled_per_settings, ...@@ -337,7 +337,7 @@ bool ContentSettingsAgentImpl::AllowImage(bool enabled_per_settings,
if (is_interstitial_page_) if (is_interstitial_page_)
return true; return true;
if (IsWhitelistedForContentSettings()) if (IsAllowlistedForContentSettings())
return true; return true;
if (content_setting_rules_) { if (content_setting_rules_) {
...@@ -365,7 +365,7 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) { ...@@ -365,7 +365,7 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) {
return it->second; return it->second;
// Evaluate the content setting rules before // Evaluate the content setting rules before
// IsWhitelistedForContentSettings(); if there is only the default rule // IsAllowlistedForContentSettings(); if there is only the default rule
// allowing all scripts, it's quicker this way. // allowing all scripts, it's quicker this way.
bool allow = true; bool allow = true;
if (content_setting_rules_) { if (content_setting_rules_) {
...@@ -374,7 +374,7 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) { ...@@ -374,7 +374,7 @@ bool ContentSettingsAgentImpl::AllowScript(bool enabled_per_settings) {
url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()); url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL());
allow = setting != CONTENT_SETTING_BLOCK; allow = setting != CONTENT_SETTING_BLOCK;
} }
allow = allow || IsWhitelistedForContentSettings(); allow = allow || IsAllowlistedForContentSettings();
cached_script_permissions_[frame] = allow; cached_script_permissions_[frame] = allow;
return allow; return allow;
...@@ -397,7 +397,7 @@ bool ContentSettingsAgentImpl::AllowScriptFromSource( ...@@ -397,7 +397,7 @@ bool ContentSettingsAgentImpl::AllowScriptFromSource(
render_frame()->GetWebFrame(), script_url); render_frame()->GetWebFrame(), script_url);
allow = setting != CONTENT_SETTING_BLOCK; allow = setting != CONTENT_SETTING_BLOCK;
} }
return allow || IsWhitelistedForContentSettings(); return allow || IsAllowlistedForContentSettings();
} }
bool ContentSettingsAgentImpl::AllowReadFromClipboard(bool default_value) { bool ContentSettingsAgentImpl::AllowReadFromClipboard(bool default_value) {
...@@ -471,11 +471,11 @@ void ContentSettingsAgentImpl::ClearBlockedContentSettings() { ...@@ -471,11 +471,11 @@ void ContentSettingsAgentImpl::ClearBlockedContentSettings() {
cached_script_permissions_.clear(); cached_script_permissions_.clear();
} }
bool ContentSettingsAgentImpl::IsWhitelistedForContentSettings() const { bool ContentSettingsAgentImpl::IsAllowlistedForContentSettings() const {
if (should_whitelist_) if (should_allowlist_)
return true; return true;
// Whitelist ftp directory listings, as they require JavaScript to function // Allowlist ftp directory listings, as they require JavaScript to function
// properly. // properly.
if (render_frame()->IsFTPDirectoryListing()) if (render_frame()->IsFTPDirectoryListing())
return true; return true;
...@@ -497,7 +497,7 @@ bool ContentSettingsAgentImpl::IsWhitelistedForContentSettings() const { ...@@ -497,7 +497,7 @@ bool ContentSettingsAgentImpl::IsWhitelistedForContentSettings() const {
if (protocol == content::kChromeDevToolsScheme) if (protocol == content::kChromeDevToolsScheme)
return true; // DevTools UI elements should still work. return true; // DevTools UI elements should still work.
if (delegate_->IsSchemeWhitelisted(protocol.Utf8())) if (delegate_->IsSchemeAllowlisted(protocol.Utf8()))
return true; return true;
// If the scheme is file:, an empty file name indicates a directory listing, // If the scheme is file:, an empty file name indicates a directory listing,
......
...@@ -47,8 +47,8 @@ class ContentSettingsAgentImpl ...@@ -47,8 +47,8 @@ class ContentSettingsAgentImpl
public: public:
virtual ~Delegate(); virtual ~Delegate();
// Return true if this scheme should be whitelisted for content settings. // Return true if this scheme should be allowlisted for content settings.
virtual bool IsSchemeWhitelisted(const std::string& scheme); virtual bool IsSchemeAllowlisted(const std::string& scheme);
// Allows the delegate to override logic for various // Allows the delegate to override logic for various
// blink::WebContentSettingsClient methods. If an optional value is // blink::WebContentSettingsClient methods. If an optional value is
...@@ -59,10 +59,10 @@ class ContentSettingsAgentImpl ...@@ -59,10 +59,10 @@ class ContentSettingsAgentImpl
virtual void PassiveInsecureContentFound(const blink::WebURL& resource_url); virtual void PassiveInsecureContentFound(const blink::WebURL& resource_url);
}; };
// Set |should_whitelist| to true if |render_frame()| contains content that // Set |should_allowlist| to true if |render_frame()| contains content that
// should be whitelisted for content settings. // should be allowlisted for content settings.
ContentSettingsAgentImpl(content::RenderFrame* render_frame, ContentSettingsAgentImpl(content::RenderFrame* render_frame,
bool should_whitelist, bool should_allowlist,
std::unique_ptr<Delegate> delegate); std::unique_ptr<Delegate> delegate);
~ContentSettingsAgentImpl() override; ~ContentSettingsAgentImpl() override;
...@@ -122,7 +122,7 @@ class ContentSettingsAgentImpl ...@@ -122,7 +122,7 @@ class ContentSettingsAgentImpl
private: private:
FRIEND_TEST_ALL_PREFIXES(ContentSettingsAgentImplBrowserTest, FRIEND_TEST_ALL_PREFIXES(ContentSettingsAgentImplBrowserTest,
WhitelistedSchemes); AllowlistedSchemes);
FRIEND_TEST_ALL_PREFIXES(ContentSettingsAgentImplBrowserTest, FRIEND_TEST_ALL_PREFIXES(ContentSettingsAgentImplBrowserTest,
ContentSettingsInterstitialPages); ContentSettingsInterstitialPages);
...@@ -142,9 +142,9 @@ class ContentSettingsAgentImpl ...@@ -142,9 +142,9 @@ class ContentSettingsAgentImpl
void ClearBlockedContentSettings(); void ClearBlockedContentSettings();
// Helpers. // Helpers.
// True if |render_frame()| contains content that is white-listed for content // True if |render_frame()| contains content that is allowlisted for content
// settings. // settings.
bool IsWhitelistedForContentSettings() const; bool IsAllowlistedForContentSettings() const;
// A getter for |content_settings_manager_| that ensures it is bound. // A getter for |content_settings_manager_| that ensures it is bound.
mojom::ContentSettingsManager& GetContentSettingsManager(); mojom::ContentSettingsManager& GetContentSettingsManager();
...@@ -173,8 +173,8 @@ class ContentSettingsAgentImpl ...@@ -173,8 +173,8 @@ class ContentSettingsAgentImpl
bool is_interstitial_page_ = false; bool is_interstitial_page_ = false;
bool mixed_content_autoupgrades_disabled_ = false; bool mixed_content_autoupgrades_disabled_ = false;
// If true, IsWhitelistedForContentSettings will always return true. // If true, IsAllowlistedForContentSettings will always return true.
const bool should_whitelist_; const bool should_allowlist_;
std::unique_ptr<Delegate> delegate_; std::unique_ptr<Delegate> delegate_;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
namespace content_settings { namespace content_settings {
namespace { namespace {
constexpr char kWhitelistScheme[] = "foo"; constexpr char kAllowlistScheme[] = "foo";
constexpr char kEndUrl[] = ":something"; constexpr char kEndUrl[] = ":something";
constexpr char kScriptHtml[] = R"HTML( constexpr char kScriptHtml[] = R"HTML(
...@@ -86,8 +86,8 @@ class MockContentSettingsManagerImpl : public mojom::ContentSettingsManager { ...@@ -86,8 +86,8 @@ class MockContentSettingsManagerImpl : public mojom::ContentSettingsManager {
class MockContentSettingsAgentDelegate class MockContentSettingsAgentDelegate
: public ContentSettingsAgentImpl::Delegate { : public ContentSettingsAgentImpl::Delegate {
public: public:
bool IsSchemeWhitelisted(const std::string& scheme) override { bool IsSchemeAllowlisted(const std::string& scheme) override {
return scheme == kWhitelistScheme; return scheme == kAllowlistScheme;
} }
}; };
...@@ -182,32 +182,32 @@ class ContentSettingsAgentImplBrowserTest : public content::RenderViewTest { ...@@ -182,32 +182,32 @@ class ContentSettingsAgentImplBrowserTest : public content::RenderViewTest {
} }
}; };
TEST_F(ContentSettingsAgentImplBrowserTest, WhitelistedSchemes) { TEST_F(ContentSettingsAgentImplBrowserTest, AllowlistedSchemes) {
url::ScopedSchemeRegistryForTests scoped_registry; url::ScopedSchemeRegistryForTests scoped_registry;
url::AddStandardScheme(kWhitelistScheme, url::SCHEME_WITH_HOST); url::AddStandardScheme(kAllowlistScheme, url::SCHEME_WITH_HOST);
MockContentSettingsAgentImpl mock_agent(view_->GetMainRenderFrame()); MockContentSettingsAgentImpl mock_agent(view_->GetMainRenderFrame());
GURL chrome_ui_url = GURL chrome_ui_url =
GURL(std::string(content::kChromeUIScheme).append(kEndUrl)); GURL(std::string(content::kChromeUIScheme).append(kEndUrl));
LoadHTMLWithUrlOverride("<html></html>", chrome_ui_url.spec().c_str()); LoadHTMLWithUrlOverride("<html></html>", chrome_ui_url.spec().c_str());
EXPECT_TRUE(mock_agent.IsWhitelistedForContentSettings()); EXPECT_TRUE(mock_agent.IsAllowlistedForContentSettings());
GURL chrome_dev_tools_url = GURL chrome_dev_tools_url =
GURL(std::string(content::kChromeDevToolsScheme).append(kEndUrl)); GURL(std::string(content::kChromeDevToolsScheme).append(kEndUrl));
LoadHTMLWithUrlOverride("<html></html>", chrome_dev_tools_url.spec().c_str()); LoadHTMLWithUrlOverride("<html></html>", chrome_dev_tools_url.spec().c_str());
EXPECT_TRUE(mock_agent.IsWhitelistedForContentSettings()); EXPECT_TRUE(mock_agent.IsAllowlistedForContentSettings());
GURL whitelist_url = GURL(std::string(kWhitelistScheme).append(kEndUrl)); GURL allowlist_url = GURL(std::string(kAllowlistScheme).append(kEndUrl));
LoadHTMLWithUrlOverride("<html></html>", whitelist_url.spec().c_str()); LoadHTMLWithUrlOverride("<html></html>", allowlist_url.spec().c_str());
EXPECT_TRUE(mock_agent.IsWhitelistedForContentSettings()); EXPECT_TRUE(mock_agent.IsAllowlistedForContentSettings());
LoadHTMLWithUrlOverride("<html></html>", "file:///dir/"); LoadHTMLWithUrlOverride("<html></html>", "file:///dir/");
EXPECT_TRUE(mock_agent.IsWhitelistedForContentSettings()); EXPECT_TRUE(mock_agent.IsAllowlistedForContentSettings());
LoadHTMLWithUrlOverride("<html></html>", "file:///dir/file"); LoadHTMLWithUrlOverride("<html></html>", "file:///dir/file");
EXPECT_FALSE(mock_agent.IsWhitelistedForContentSettings()); EXPECT_FALSE(mock_agent.IsAllowlistedForContentSettings());
LoadHTMLWithUrlOverride("<html></html>", "http://server.com/path"); LoadHTMLWithUrlOverride("<html></html>", "http://server.com/path");
EXPECT_FALSE(mock_agent.IsWhitelistedForContentSettings()); EXPECT_FALSE(mock_agent.IsAllowlistedForContentSettings());
} }
TEST_F(ContentSettingsAgentImplBrowserTest, DidBlockContentType) { TEST_F(ContentSettingsAgentImplBrowserTest, DidBlockContentType) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment