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

Unified Diff: chrome/browser/ui/webui/site_settings_helper.cc

Issue 2298283002: Site Settings Desktop: Support adding exceptions for incognito mode. (Closed)
Patch Set: Fix test 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
« no previous file with comments | « chrome/browser/ui/webui/site_settings_helper.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/site_settings_helper.cc
diff --git a/chrome/browser/ui/webui/site_settings_helper.cc b/chrome/browser/ui/webui/site_settings_helper.cc
index a0b57cf132ffdb93416861016d055715c122dbe9..716baad3d1087f89e753e99151021bb8b29a4ba4 100644
--- a/chrome/browser/ui/webui/site_settings_helper.cc
+++ b/chrome/browser/ui/webui/site_settings_helper.cc
@@ -19,6 +19,7 @@ const char kSetting[] = "setting";
const char kOrigin[] = "origin";
const char kPolicyProviderId[] = "policy";
const char kSource[] = "source";
+const char kIncognito[] = "incognito";
const char kEmbeddingOrigin[] = "embeddingOrigin";
const char kPreferencesSource[] = "preference";
const char kObject[] = "object";
@@ -80,7 +81,8 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
const ContentSettingsPattern& pattern,
const ContentSettingsPattern& secondary_pattern,
const ContentSetting& setting,
- const std::string& provider_name) {
+ const std::string& provider_name,
+ bool incognito) {
base::DictionaryValue* exception = new base::DictionaryValue();
exception->SetString(kOrigin, pattern.ToString());
exception->SetString(kEmbeddingOrigin,
@@ -94,12 +96,14 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
exception->SetString(kSetting, setting_string);
exception->SetString(kSource, provider_name);
+ exception->SetBoolean(kIncognito, incognito);
return base::WrapUnique(exception);
}
void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map,
ContentSettingsType type,
content::WebUI* web_ui,
+ bool incognito,
base::ListValue* exceptions) {
ContentSettingsForOneType entries;
map->GetSettingsForOneType(type, std::string(), &entries);
@@ -157,7 +161,7 @@ void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map,
const ContentSettingsPattern& secondary_pattern =
parent == one_settings.end() ? primary_pattern : parent->first;
this_provider_exceptions.push_back(GetExceptionForPage(
- primary_pattern, secondary_pattern, parent_setting, source));
+ primary_pattern, secondary_pattern, parent_setting, source, incognito));
// Add the "children" for any embedded settings.
for (OnePatternSettings::const_iterator j = one_settings.begin();
@@ -168,7 +172,7 @@ void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map,
ContentSetting content_setting = j->second;
this_provider_exceptions.push_back(GetExceptionForPage(
- primary_pattern, j->first, content_setting, source));
+ primary_pattern, j->first, content_setting, source, incognito));
}
}
@@ -179,7 +183,7 @@ void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map,
auto& policy_exceptions = all_provider_exceptions
[HostContentSettingsMap::GetProviderTypeFromSource(kPolicyProviderId)];
DCHECK(policy_exceptions.empty());
- GetPolicyAllowedUrls(type, &policy_exceptions, web_ui);
+ GetPolicyAllowedUrls(type, &policy_exceptions, web_ui, incognito);
}
for (auto& one_provider_exceptions : all_provider_exceptions) {
@@ -191,7 +195,8 @@ void GetExceptionsFromHostContentSettingsMap(const HostContentSettingsMap* map,
void GetPolicyAllowedUrls(
ContentSettingsType type,
std::vector<std::unique_ptr<base::DictionaryValue>>* exceptions,
- content::WebUI* web_ui) {
+ content::WebUI* web_ui,
+ bool incognito) {
DCHECK(type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
@@ -224,7 +229,7 @@ void GetPolicyAllowedUrls(
for (const ContentSettingsPattern& pattern : patterns) {
exceptions->push_back(GetExceptionForPage(pattern, ContentSettingsPattern(),
CONTENT_SETTING_ALLOW,
- kPolicyProviderId));
+ kPolicyProviderId, incognito));
}
}
@@ -242,6 +247,7 @@ std::unique_ptr<base::DictionaryValue> GetChooserExceptionForPage(
const GURL& requesting_origin,
const GURL& embedding_origin,
const std::string& provider_name,
+ bool incognito,
const std::string& name,
const base::DictionaryValue* object) {
std::unique_ptr<base::DictionaryValue> exception(new base::DictionaryValue());
@@ -255,6 +261,7 @@ std::unique_ptr<base::DictionaryValue> GetChooserExceptionForPage(
exception->SetString(
site_settings::kEmbeddingOrigin, embedding_origin.spec());
exception->SetString(site_settings::kSource, provider_name);
+ exception->SetBoolean(kIncognito, incognito);
if (object) {
exception->SetString(kObjectName, name);
exception->Set(kObject, object->CreateDeepCopy());
@@ -316,8 +323,9 @@ void GetChooserExceptionsFromProfile(
for (const auto& sorted_objects_entry : sorted_objects) {
this_provider_exceptions.push_back(GetChooserExceptionForPage(
- requesting_origin, embedding_origin, source,
- sorted_objects_entry.first, sorted_objects_entry.second));
+ requesting_origin, embedding_origin, source, incognito,
+ sorted_objects_entry.first,
+ sorted_objects_entry.second));
}
}
@@ -326,7 +334,8 @@ void GetChooserExceptionsFromProfile(
// where |requesting_origin| has been embedded.
this_provider_exceptions.push_back(
GetChooserExceptionForPage(requesting_origin, requesting_origin,
- source, std::string(), nullptr));
+ source, incognito, std::string(),
+ nullptr));
// Add the "children" for any embedded settings.
for (const auto& one_origin_objects_entry : one_origin_objects) {
@@ -339,7 +348,7 @@ void GetChooserExceptionsFromProfile(
for (const auto& sorted_objects_entry : sorted_objects) {
this_provider_exceptions.push_back(GetChooserExceptionForPage(
- requesting_origin, embedding_origin, source,
+ requesting_origin, embedding_origin, source, incognito,
sorted_objects_entry.first, sorted_objects_entry.second));
}
}
« no previous file with comments | « chrome/browser/ui/webui/site_settings_helper.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698