Commit 76a6893c authored by deepak.m1's avatar deepak.m1 Committed by Commit bot

Content settings clean-up: Clarify resource identifier & get rid of NO_RESOURCE_IDENTIFIER.

current NO_RESOURCE_IDENTIFIER usage is aganinst style guidelines.
Made a class in content_settings.h and using function to get std::string()
To get rid of NO_RESOURCE_IDENTIFIER.
Now no need to add content_settings_provider.h in places like
desktop_notification_profile_util.cc and other places.

BUG=399592

Review URL: https://codereview.chromium.org/1034143002

Cr-Commit-Position: refs/heads/master@{#324362}
parent 2ba251cb
......@@ -28,7 +28,6 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/content_settings_provider.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
......@@ -423,7 +422,7 @@ bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
security_origin,
security_origin,
contentSettingsType,
NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
content_settings::ResourceIdentifier()) == CONTENT_SETTING_ALLOW) {
return true;
}
......@@ -469,7 +468,7 @@ bool MediaCaptureDevicesDispatcher::CheckMediaAccessPermission(
security_origin,
security_origin,
contentSettingsType,
NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_ALLOW) {
content_settings::ResourceIdentifier()) == CONTENT_SETTING_ALLOW) {
return true;
}
......
......@@ -17,7 +17,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/content_settings_provider.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
......@@ -543,9 +542,11 @@ bool MediaStreamDevicesController::IsRequestAllowedByDefault() const {
return false;
}
if (profile_->GetHostContentSettingsMap()->GetContentSetting(
request_.security_origin, request_.security_origin,
device_checks[i].settings_type, NO_RESOURCE_IDENTIFIER) !=
CONTENT_SETTING_ALLOW) {
request_.security_origin,
request_.security_origin,
device_checks[i].settings_type,
content_settings::ResourceIdentifier()) !=
CONTENT_SETTING_ALLOW) {
return false;
}
}
......@@ -561,10 +562,11 @@ int MediaStreamDevicesController::FilterBlockedByDefaultDevices() {
if (IsDeviceAudioCaptureRequestedAndAllowed()) {
if (profile_->GetHostContentSettingsMap()->GetContentSetting(
request_.security_origin,
request_.security_origin,
CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) {
request_.security_origin,
request_.security_origin,
CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
content_settings::ResourceIdentifier()) ==
CONTENT_SETTING_BLOCK) {
request_permissions_[content::MEDIA_DEVICE_AUDIO_CAPTURE].permission =
MEDIA_BLOCKED_BY_USER_SETTING;
} else {
......@@ -574,10 +576,11 @@ int MediaStreamDevicesController::FilterBlockedByDefaultDevices() {
if (IsDeviceVideoCaptureRequestedAndAllowed()) {
if (profile_->GetHostContentSettingsMap()->GetContentSetting(
request_.security_origin,
request_.security_origin,
CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
NO_RESOURCE_IDENTIFIER) == CONTENT_SETTING_BLOCK) {
request_.security_origin,
request_.security_origin,
CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
content_settings::ResourceIdentifier()) ==
CONTENT_SETTING_BLOCK) {
request_permissions_[content::MEDIA_DEVICE_VIDEO_CAPTURE].permission =
MEDIA_BLOCKED_BY_USER_SETTING;
} else {
......
......@@ -5,7 +5,6 @@
#include "chrome/browser/notifications/desktop_notification_profile_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/browser/content_settings_provider.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
......@@ -19,12 +18,9 @@ void DesktopNotificationProfileUtil::ResetToDefaultContentSetting(
void DesktopNotificationProfileUtil::ClearSetting(
Profile* profile, const ContentSettingsPattern& pattern) {
profile->GetHostContentSettingsMap()->SetContentSetting(
pattern,
ContentSettingsPattern::Wildcard(),
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
NO_RESOURCE_IDENTIFIER,
CONTENT_SETTING_DEFAULT);
content_settings::ResourceIdentifier(), CONTENT_SETTING_DEFAULT);
}
// Methods to setup and modify permission preferences.
......@@ -33,11 +29,9 @@ void DesktopNotificationProfileUtil::GrantPermission(
ContentSettingsPattern primary_pattern =
ContentSettingsPattern::FromURLNoWildcard(origin);
profile->GetHostContentSettingsMap()->SetContentSetting(
primary_pattern,
ContentSettingsPattern::Wildcard(),
primary_pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
NO_RESOURCE_IDENTIFIER,
CONTENT_SETTING_ALLOW);
content_settings::ResourceIdentifier(), CONTENT_SETTING_ALLOW);
}
void DesktopNotificationProfileUtil::DenyPermission(
......@@ -45,26 +39,21 @@ void DesktopNotificationProfileUtil::DenyPermission(
ContentSettingsPattern primary_pattern =
ContentSettingsPattern::FromURLNoWildcard(origin);
profile->GetHostContentSettingsMap()->SetContentSetting(
primary_pattern,
ContentSettingsPattern::Wildcard(),
primary_pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
NO_RESOURCE_IDENTIFIER,
CONTENT_SETTING_BLOCK);
content_settings::ResourceIdentifier(), CONTENT_SETTING_BLOCK);
}
void DesktopNotificationProfileUtil::GetNotificationsSettings(
Profile* profile, ContentSettingsForOneType* settings) {
profile->GetHostContentSettingsMap()->GetSettingsForOneType(
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
NO_RESOURCE_IDENTIFIER,
settings);
content_settings::ResourceIdentifier(), settings);
}
ContentSetting DesktopNotificationProfileUtil::GetContentSetting(
Profile* profile, const GURL& origin) {
return profile->GetHostContentSettingsMap()->GetContentSetting(
origin,
origin,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
NO_RESOURCE_IDENTIFIER);
origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
content_settings::ResourceIdentifier());
}
......@@ -179,7 +179,7 @@ PlatformNotificationServiceImpl::CheckPermissionOnIOThread(
origin,
origin,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
NO_RESOURCE_IDENTIFIER);
content_settings::ResourceIdentifier());
if (setting == CONTENT_SETTING_ALLOW)
return blink::WebNotificationPermissionAllowed;
......
......@@ -9,8 +9,7 @@
#include <string>
#include "base/memory/linked_ptr.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings.h"
class GURL;
......@@ -25,7 +24,6 @@ class RuleIterator;
class OriginIdentifierValueMap {
public:
typedef std::string ResourceIdentifier;
struct EntryMapKey {
ContentSettingsType content_type;
ResourceIdentifier resource_identifier;
......
......@@ -284,10 +284,8 @@ void PolicyProvider::GetContentSettingsFromPreferences(
ContentSettingsPattern secondary_pattern =
!pattern_pair.second.IsValid() ? ContentSettingsPattern::Wildcard()
: pattern_pair.second;
value_map->SetValue(pattern_pair.first,
secondary_pattern,
content_type,
NO_RESOURCE_IDENTIFIER,
value_map->SetValue(pattern_pair.first, secondary_pattern, content_type,
ResourceIdentifier(),
new base::FundamentalValue(
kPrefsForManagedContentSettingsMap[i].setting));
}
......
......@@ -7,12 +7,10 @@
#ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PROVIDER_H_
#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PROVIDER_H_
#define NO_RESOURCE_IDENTIFIER std::string()
#include <string>
#include "base/values.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings.h"
class ContentSettingsPattern;
......@@ -21,8 +19,6 @@ namespace content_settings {
struct Rule;
class RuleIterator;
typedef std::string ResourceIdentifier;
class ProviderInterface {
public:
virtual ~ProviderInterface() {}
......
......@@ -62,6 +62,8 @@ struct RendererContentSettingRules {
namespace content_settings {
typedef std::string ResourceIdentifier;
// Enum containing the various source for content settings. Settings can be
// set by policy, extension, the user or by the custodian of a supervised user.
// Certain (internal) schemes are whilelisted. For whilelisted schemes the
......
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