Chromium Code Reviews| 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); |
|
stevenjb
2016/09/01 15:47:55
It *looks* like the only thing we use |incognito|
Finnur
2016/09/01 16:48:17
Correct.
We send down (to .js) a single Array<Si
stevenjb
2016/09/01 17:07:54
I was suggesting (1). I don't think the inefficien
|
| 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)); |
| } |
| } |