Commit 94c80d54 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Replace incognito with off_the_record in ContentSettingsPref*.

ContentSettingsPref and ContentSettingsPrefProfovider classes receive
an |incognito| argument that actually triggers the off-the-record
behavior and is not necessarily an incognito mode specifier.
The argument and all related items are renamed to off_the_record to
remove ambiguity.

Bug: 968028
Change-Id: Ida0818f993baef9ebc3c9521d24c2b8ae2b10c66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634729
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665828}
parent 604d29e8
......@@ -78,13 +78,13 @@ ContentSettingsPref::ContentSettingsPref(
PrefService* prefs,
PrefChangeRegistrar* registrar,
const std::string& pref_name,
bool incognito,
bool off_the_record,
NotifyObserversCallback notify_callback)
: content_type_(content_type),
prefs_(prefs),
registrar_(registrar),
pref_name_(pref_name),
is_incognito_(incognito),
off_the_record_(off_the_record),
updating_preferences_(false),
notify_callback_(notify_callback),
allow_resource_identifiers_(false) {
......@@ -102,16 +102,15 @@ ContentSettingsPref::~ContentSettingsPref() {
std::unique_ptr<RuleIterator> ContentSettingsPref::GetRuleIterator(
const ResourceIdentifier& resource_identifier,
bool incognito) const {
bool off_the_record) const {
// Resource Identifiers have been supported by the API but never used by any
// users of the API.
// TODO(crbug.com/754178): remove |resource_identifier| from the API.
DCHECK(resource_identifier.empty() || allow_resource_identifiers_);
if (incognito)
return incognito_value_map_.GetRuleIterator(content_type_,
resource_identifier,
&lock_);
if (off_the_record)
return off_the_record_value_map_.GetRuleIterator(
content_type_, resource_identifier, &lock_);
return value_map_.GetRuleIterator(content_type_, resource_identifier, &lock_);
}
......@@ -137,8 +136,8 @@ bool ContentSettingsPref::SetWebsiteSetting(
std::unique_ptr<base::Value> value(std::move(in_value));
// Update in memory value map.
OriginIdentifierValueMap* map_to_modify = &incognito_value_map_;
if (!is_incognito_)
OriginIdentifierValueMap* map_to_modify = &off_the_record_value_map_;
if (!off_the_record_)
map_to_modify = &value_map_;
{
......@@ -156,7 +155,7 @@ bool ContentSettingsPref::SetWebsiteSetting(
}
}
// Update the content settings preference.
if (!is_incognito_) {
if (!off_the_record_) {
UpdatePref(primary_pattern, secondary_pattern, resource_identifier,
modified_time, value.get());
}
......@@ -171,8 +170,8 @@ base::Time ContentSettingsPref::GetWebsiteSettingLastModified(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
const ResourceIdentifier& resource_identifier) {
OriginIdentifierValueMap* map_to_modify = &incognito_value_map_;
if (!is_incognito_)
OriginIdentifierValueMap* map_to_modify = &off_the_record_value_map_;
if (!off_the_record_)
map_to_modify = &value_map_;
base::Time last_modified = map_to_modify->GetLastModified(
......@@ -200,9 +199,9 @@ void ContentSettingsPref::ClearAllContentSettingsRules() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(prefs_);
if (is_incognito_) {
if (off_the_record_) {
base::AutoLock auto_lock(lock_);
incognito_value_map_.clear();
off_the_record_value_map_.clear();
} else {
ClearPref();
}
......@@ -320,12 +319,12 @@ void ContentSettingsPref::ReadContentSettingsFromPref() {
}
}
// Canonicalization is unnecessary when |is_incognito_|. Both incognito and
// non-incognito read from the same pref and non-incognito reads occur
// before incognito reads. Thus, by the time the incognito call to
// ReadContentSettingsFromPref() occurs, the regular profile will have
// canonicalized the stored pref data.
if (!is_incognito_) {
// Canonicalization is unnecessary when |off_the_record_|. Both
// off_the_record and non off_the_record read from the same pref and
// non off_the_record reads occur before off_the_record reads. Thus, by the
// time the off_the_record call to ReadContentSettingsFromPref() occurs, the
// regular profile will have canonicalized the stored pref data.
if (!off_the_record_) {
auto mutable_settings = update.Get();
for (const auto& pattern : non_canonical_patterns_to_remove) {
......
......@@ -39,14 +39,14 @@ class ContentSettingsPref {
PrefService* prefs,
PrefChangeRegistrar* registrar,
const std::string& pref_name,
bool incognito,
bool off_the_record,
NotifyObserversCallback notify_callback);
~ContentSettingsPref();
// Returns nullptr to indicate the RuleIterator is empty.
std::unique_ptr<RuleIterator> GetRuleIterator(
const ResourceIdentifier& resource_identifier,
bool incognito) const;
bool off_the_record) const;
bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
......@@ -110,7 +110,7 @@ class ContentSettingsPref {
// Name of the dictionary preference managed by this class.
const std::string& pref_name_;
bool is_incognito_;
bool off_the_record_;
// Whether we are currently updating preferences, this is used to ignore
// notifications from the preferences service that we triggered ourself.
......@@ -118,7 +118,7 @@ class ContentSettingsPref {
OriginIdentifierValueMap value_map_;
OriginIdentifierValueMap incognito_value_map_;
OriginIdentifierValueMap off_the_record_value_map_;
NotifyObserversCallback notify_callback_;
......
......@@ -88,10 +88,10 @@ void PrefProvider::RegisterProfilePrefs(
}
PrefProvider::PrefProvider(PrefService* prefs,
bool incognito,
bool off_the_record,
bool store_last_modified)
: prefs_(prefs),
is_incognito_(incognito),
off_the_record_(off_the_record),
store_last_modified_(store_last_modified),
clock_(base::DefaultClock::GetInstance()) {
TRACE_EVENT_BEGIN0("startup", "PrefProvider::PrefProvider");
......@@ -126,20 +126,20 @@ PrefProvider::PrefProvider(PrefService* prefs,
info->type(),
std::make_unique<ContentSettingsPref>(
info->type(), prefs_, &pref_change_registrar_, info->pref_name(),
is_incognito_,
off_the_record_,
base::Bind(&PrefProvider::Notify, base::Unretained(this)))));
} else if (info->type() == CONTENT_SETTINGS_TYPE_PLUGINS) {
// TODO(https://crbug.com/850062): Remove after M71, two milestones after
// migration of the Flash permissions to ephemeral provider.
flash_content_settings_pref_ = std::make_unique<ContentSettingsPref>(
info->type(), prefs_, &pref_change_registrar_, info->pref_name(),
is_incognito_,
off_the_record_,
base::Bind(&PrefProvider::Notify, base::Unretained(this)));
}
}
size_t num_exceptions = 0;
if (!is_incognito_) {
if (!off_the_record_) {
for (const auto& pref : content_settings_prefs_)
num_exceptions += pref.second->GetNumExceptions();
......@@ -158,11 +158,12 @@ PrefProvider::~PrefProvider() {
std::unique_ptr<RuleIterator> PrefProvider::GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
bool incognito) const {
bool off_the_record) const {
if (!supports_type(content_type))
return nullptr;
return GetPref(content_type)->GetRuleIterator(resource_identifier, incognito);
return GetPref(content_type)
->GetRuleIterator(resource_identifier, off_the_record);
}
bool PrefProvider::SetWebsiteSetting(
......@@ -265,7 +266,7 @@ void PrefProvider::Notify(
}
void PrefProvider::DiscardObsoletePreferences() {
if (is_incognito_)
if (off_the_record_)
return;
prefs_->ClearPref(kObsoleteDomainToOriginMigrationStatus);
......
......@@ -36,14 +36,16 @@ class PrefProvider : public UserModifiableProvider {
public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
PrefProvider(PrefService* prefs, bool incognito, bool store_last_modified);
PrefProvider(PrefService* prefs,
bool off_the_record,
bool store_last_modified);
~PrefProvider() override;
// UserModifiableProvider implementations.
std::unique_ptr<RuleIterator> GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
bool incognito) const override;
bool off_the_record) const override;
bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
......@@ -83,7 +85,7 @@ class PrefProvider : public UserModifiableProvider {
// Weak; owned by the Profile and reset in ShutdownOnUIThread.
PrefService* prefs_;
const bool is_incognito_;
const bool off_the_record_;
bool store_last_modified_;
......
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