| 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 4144fba60bc32c95fcf0a2c6fd9f56adad9a5696..1d03e27e947c0199f6ba30e17d7e2aeb89faacea 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"
|
| @@ -33,6 +35,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(
|
| @@ -101,4 +111,41 @@ void SiteSettingsHandler::HandleClearUsage(
|
| }
|
| }
|
|
|
| +void SiteSettingsHandler::HandleSetDefaultValueForContentType(
|
| + 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
|
|
|