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

Unified Diff: chrome/browser/ui/webui/settings/site_settings_handler.cc

Issue 2338163004: [MD settings] add getSiteDetails to site settings browser proxy (Closed)
Patch Set: review changes 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
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 5de10e0fb465db07b8c0efdd6c94d4cac3bcbeca..90f2b508f7b82ece96fd8a309d3654a832afd331 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/site_settings_handler.h"
+#include <algorithm>
#include <memory>
#include <string>
#include <utility>
@@ -157,6 +158,10 @@ void SiteSettingsHandler::RegisterMessages() {
base::Bind(&SiteSettingsHandler::HandleSetCategoryPermissionForOrigin,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "getSiteDetails",
+ base::Bind(&SiteSettingsHandler::HandleGetSiteDetails,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"isPatternValid",
base::Bind(&SiteSettingsHandler::HandleIsPatternValid,
base::Unretained(this)));
@@ -436,13 +441,15 @@ void SiteSettingsHandler::HandleGetExceptionList(const base::ListValue* args) {
AddExceptionsGrantedByHostedApps(profile_, APIPermissionFromGroupName(type),
exceptions.get());
site_settings::GetExceptionsFromHostContentSettingsMap(
- map, content_type, web_ui(), false, exceptions.get());
+ map, content_type, web_ui(), /*incognito=*/false, /*filter=*/nullptr,
+ exceptions.get());
if (profile_->HasOffTheRecordProfile()) {
Profile* incognito = profile_->GetOffTheRecordProfile();
map = HostContentSettingsMapFactory::GetForProfile(incognito);
site_settings::GetExceptionsFromHostContentSettingsMap(
- map, content_type, web_ui(), true, exceptions.get());
+ map, content_type, web_ui(), /*incognito=*/true, /*filter=*/nullptr,
+ exceptions.get());
}
ResolveJavascriptCallback(*callback_id, *exceptions.get());
@@ -522,6 +529,68 @@ void SiteSettingsHandler::HandleSetCategoryPermissionForOrigin(
content_type, "", setting);
}
+void SiteSettingsHandler::HandleGetSiteDetails(
+ const base::ListValue* args) {
+ AllowJavascript();
+
+ CHECK_EQ(2U, args->GetSize());
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+ std::string site;
+ CHECK(args->GetString(1, &site));
+
+ // A subset of the ContentSettingsType enum that we show in the settings UI.
+ const ContentSettingsType kSettingsDetailTypes[] = {
+ CONTENT_SETTINGS_TYPE_COOKIES,
+ CONTENT_SETTINGS_TYPE_IMAGES,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ CONTENT_SETTINGS_TYPE_GEOLOCATION,
+ CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+ CONTENT_SETTINGS_TYPE_FULLSCREEN,
+ CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
+ CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
+ CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS,
+ CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
+ CONTENT_SETTINGS_TYPE_KEYGEN,
+ CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC,
+ CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA,
+ CONTENT_SETTINGS_TYPE_PROMPT_NO_DECISION_COUNT,
+ };
+
+ // Create a list to be consistent with existing API, we are expecting a single
+ // element (or none).
+ std::unique_ptr<base::ListValue> exceptions(new base::ListValue);
+ for (size_t type = 0; type < arraysize(kSettingsDetailTypes); ++type) {
+ ContentSettingsType content_type = kSettingsDetailTypes[type];
+
+ HostContentSettingsMap* map =
+ HostContentSettingsMapFactory::GetForProfile(profile_);
+ site_settings::GetExceptionsFromHostContentSettingsMap(
+ map, content_type, web_ui(), /*incognito=*/false, /*filter=*/&site,
+ exceptions.get());
+
+ if (profile_->HasOffTheRecordProfile()) {
+ Profile* incognito = profile_->GetOffTheRecordProfile();
+ map = HostContentSettingsMapFactory::GetForProfile(incognito);
+ site_settings::GetExceptionsFromHostContentSettingsMap(
+ map, content_type, web_ui(), /*incognito=*/true, /*filter=*/&site,
+ exceptions.get());
+ }
+ }
+
+ if (!exceptions->GetSize()) {
+ RejectJavascriptCallback(*callback_id, *base::Value::CreateNullValue());
+ return;
+ }
+
+ // We only need a single response element.
+ const base::DictionaryValue* exception = nullptr;
+ exceptions->GetDictionary(0, &exception);
+ ResolveJavascriptCallback(*callback_id, *exception);
+}
+
void SiteSettingsHandler::HandleIsPatternValid(
const base::ListValue* args) {
CHECK_EQ(2U, args->GetSize());
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.h ('k') | chrome/browser/ui/webui/site_settings_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698