Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/site_settings_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| index 598bedeed366ac53c1b70909e6a5722a7bf74e28..bd7443d49c79075a15c14a6a8f0bce384afe7fb7 100644 |
| --- a/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc |
| @@ -7,7 +7,9 @@ |
| #include "base/bind.h" |
| #include "base/values.h" |
| #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| +#include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "components/content_settings/core/browser/host_content_settings_map.h" |
| #include "components/content_settings/core/common/content_settings_types.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/web_ui.h" |
| @@ -31,6 +33,14 @@ void SiteSettingsHandler::RegisterMessages() { |
| "clearUsage", |
| base::Bind(&SiteSettingsHandler::HandleClearUsage, |
| base::Unretained(this))); |
| + web_ui()->RegisterMessageCallback( |
| + "setDefaultValueForContentType", |
| + base::Bind(&SiteSettingsHandler::HandleSetDefaultValueForContentType, |
| + base::Unretained(this))); |
| + web_ui()->RegisterMessageCallback( |
| + "getDefaultValueForContentType", |
| + base::Bind(&SiteSettingsHandler::HandleGetDefaultValueForContentType, |
| + base::Unretained(this))); |
| } |
| void SiteSettingsHandler::OnGetUsageInfo( |
| @@ -99,4 +109,41 @@ void SiteSettingsHandler::HandleClearUsage( |
| } |
| } |
| +void SiteSettingsHandler::HandleSetDefaultValueForContentType( |
|
tommycli
2016/02/17 18:18:06
What was the motivation for changing this from usi
Finnur
2016/02/18 20:38:18
That's in the email I referred to but in short: pr
tommycli
2016/02/18 22:15:18
finnur: I brain farted and neglected to read the e
Finnur
2016/02/19 10:18:13
No harm, no foul. :)
|
| + const base::ListValue* args) { |
| + CHECK_EQ(2U, args->GetSize()); |
| + int content_type; |
| + CHECK(args->GetInteger(0, &content_type)); |
| + int default_setting; |
| + CHECK(args->GetInteger(1, &default_setting)); |
| + |
| + HostContentSettingsMap* map = |
| + HostContentSettingsMapFactory::GetForProfile(profile_); |
| + map->SetDefaultContentSetting(static_cast<ContentSettingsType>(content_type), |
| + static_cast<ContentSetting>(default_setting)); |
| +} |
| + |
| +void SiteSettingsHandler::HandleGetDefaultValueForContentType( |
| + const base::ListValue* args) { |
| + CHECK_EQ(2U, args->GetSize()); |
| + const base::Value* callback_id; |
| + CHECK(args->Get(0, &callback_id)); |
| + int type; |
| + CHECK(args->GetInteger(1, &type)); |
| + |
| + ContentSettingsType content_type = static_cast<ContentSettingsType>(type); |
| + HostContentSettingsMap* map = |
| + HostContentSettingsMapFactory::GetForProfile(profile_); |
| + ContentSetting setting = map->GetDefaultContentSetting(content_type, nullptr); |
| + |
| + // FullScreen is Allow vs. Ask. |
| + bool enabled; |
| + if (content_type == CONTENT_SETTINGS_TYPE_FULLSCREEN) |
| + enabled = setting != CONTENT_SETTING_ASK; |
| + else |
| + enabled = setting != CONTENT_SETTING_BLOCK; |
| + |
| + CallJavascriptCallback(*callback_id, base::FundamentalValue(enabled)); |
| +} |
| + |
| } // namespace settings |