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

Side by Side Diff: chrome/browser/ui/webui/options/website_settings_handler.cc

Issue 542203003: Split the Website Settings page's origin list into Allowed and Blocked lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/options/website_settings.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/website_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/website_settings_handler.h"
6 6
7 #include "chrome/browser/content_settings/content_settings_utils.h" 7 #include "chrome/browser/content_settings/content_settings_utils.h"
8 #include "chrome/browser/content_settings/host_content_settings_map.h" 8 #include "chrome/browser/content_settings/host_content_settings_map.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, 84 IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION},
85 {"websitesDownloadsDescription", 85 {"websitesDownloadsDescription",
86 IDS_WEBSITE_SETTINGS_DOWNLOAD_DESCRIPTION}, 86 IDS_WEBSITE_SETTINGS_DOWNLOAD_DESCRIPTION},
87 {"websitesPluginsDescription", IDS_WEBSITE_SETTINGS_PLUGINS_DESCRIPTION}, 87 {"websitesPluginsDescription", IDS_WEBSITE_SETTINGS_PLUGINS_DESCRIPTION},
88 {"websitesPopupsDescription", IDS_WEBSITE_SETTINGS_POPUPS_DESCRIPTION}, 88 {"websitesPopupsDescription", IDS_WEBSITE_SETTINGS_POPUPS_DESCRIPTION},
89 {"websitesJavascriptDescription", 89 {"websitesJavascriptDescription",
90 IDS_WEBSITE_SETTINGS_JAVASCRIPT_DESCRIPTION}, 90 IDS_WEBSITE_SETTINGS_JAVASCRIPT_DESCRIPTION},
91 {"websitesImagesDescription", IDS_WEBSITE_SETTINGS_IMAGES_DESCRIPTION}, 91 {"websitesImagesDescription", IDS_WEBSITE_SETTINGS_IMAGES_DESCRIPTION},
92 {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON}, 92 {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON},
93 {"websitesButtonStop", IDS_WEBSITE_SETTINGS_BATTERY_STOP_BUTTON}, 93 {"websitesButtonStop", IDS_WEBSITE_SETTINGS_BATTERY_STOP_BUTTON},
94 {"websitesBlockedListTitle", IDS_WEBSITE_SETTINGS_BLOCKED_LIST_TITLE},
94 }; 95 };
95 96
96 RegisterStrings(localized_strings, resources, arraysize(resources)); 97 RegisterStrings(localized_strings, resources, arraysize(resources));
97 RegisterTitle( 98 RegisterTitle(
98 localized_strings, "websiteSettingsPage", IDS_WEBSITE_SETTINGS_TITLE); 99 localized_strings, "websiteSettingsPage", IDS_WEBSITE_SETTINGS_TITLE);
99 } 100 }
100 101
101 void WebsiteSettingsHandler::InitializeHandler() { 102 void WebsiteSettingsHandler::InitializeHandler() {
102 Profile* profile = Profile::FromWebUI(web_ui()); 103 Profile* profile = Profile::FromWebUI(web_ui());
103 HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); 104 HostContentSettingsMap* settings = profile->GetHostContentSettingsMap();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 253
253 ContentSettingsForOneType all_settings; 254 ContentSettingsForOneType all_settings;
254 ContentSettingsType last_setting; 255 ContentSettingsType last_setting;
255 content_settings::GetTypeFromName(last_setting_, &last_setting); 256 content_settings::GetTypeFromName(last_setting_, &last_setting);
256 257
257 if (last_setting == CONTENT_SETTINGS_TYPE_MEDIASTREAM) 258 if (last_setting == CONTENT_SETTINGS_TYPE_MEDIASTREAM)
258 last_setting = CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; 259 last_setting = CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC;
259 260
260 settings->GetSettingsForOneType(last_setting, std::string(), &all_settings); 261 settings->GetSettingsForOneType(last_setting, std::string(), &all_settings);
261 262
262 base::DictionaryValue origins; 263 base::DictionaryValue allowed_origins;
264 base::DictionaryValue blocked_origins;
263 for (ContentSettingsForOneType::const_iterator it = all_settings.begin(); 265 for (ContentSettingsForOneType::const_iterator it = all_settings.begin();
264 it != all_settings.end(); 266 it != all_settings.end();
265 ++it) { 267 ++it) {
266 // Don't add default settings. 268 // Don't add default settings.
267 if (it->primary_pattern == ContentSettingsPattern::Wildcard() && 269 if (it->primary_pattern == ContentSettingsPattern::Wildcard() &&
268 it->secondary_pattern == ContentSettingsPattern::Wildcard() && 270 it->secondary_pattern == ContentSettingsPattern::Wildcard() &&
269 it->source != kPreferencesSource) { 271 it->source != kPreferencesSource) {
270 continue; 272 continue;
271 } 273 }
272 274
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 base::string16 usage_string; 308 base::string16 usage_string;
307 if (last_usage.ToDoubleT()) { 309 if (last_usage.ToDoubleT()) {
308 usage_string = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, 310 usage_string = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
309 ui::TimeFormat::LENGTH_SHORT, 311 ui::TimeFormat::LENGTH_SHORT,
310 base::Time::Now() - last_usage); 312 base::Time::Now() - last_usage);
311 } 313 }
312 origin_entry->SetStringWithoutPathExpansion("usageString", usage_string); 314 origin_entry->SetStringWithoutPathExpansion("usageString", usage_string);
313 origin_entry->SetStringWithoutPathExpansion("readableName", 315 origin_entry->SetStringWithoutPathExpansion("readableName",
314 GetReadableName(origin_url)); 316 GetReadableName(origin_url));
315 317
316 origins.SetWithoutPathExpansion(origin, origin_entry); 318 if (it->setting == CONTENT_SETTING_BLOCK)
319 blocked_origins.SetWithoutPathExpansion(origin, origin_entry);
320 else
321 allowed_origins.SetWithoutPathExpansion(origin, origin_entry);
317 } 322 }
318 323
319 web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins", 324 web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins",
320 origins); 325 allowed_origins,
326 blocked_origins);
321 } 327 }
322 328
323 void WebsiteSettingsHandler::HandleGetOriginInfo(const base::ListValue* args) { 329 void WebsiteSettingsHandler::HandleGetOriginInfo(const base::ListValue* args) {
324 std::string url; 330 std::string url;
325 bool rv = args->GetString(0, &url); 331 bool rv = args->GetString(0, &url);
326 DCHECK(rv); 332 DCHECK(rv);
327 GURL origin(url); 333 GURL origin(url);
328 334
329 if (!origin.is_valid()) 335 if (!origin.is_valid())
330 return; 336 return;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 // If extension is NULL, it was removed and we cannot look up its name. 627 // If extension is NULL, it was removed and we cannot look up its name.
622 if (!extension) 628 if (!extension)
623 return site_url.spec(); 629 return site_url.spec();
624 630
625 return extension->name(); 631 return extension->name();
626 } 632 }
627 return site_url.spec(); 633 return site_url.spec();
628 } 634 }
629 635
630 } // namespace options 636 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/website_settings.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698