diff options
author | raymes <raymes@chromium.org> | 2015-05-31 18:32:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-01 01:32:49 +0000 |
commit | 9a66ed01a85062d9ed2a70138597825bd1e4651f (patch) | |
tree | 41d1470f74523c7cc133b87afe88e85c09778938 | |
parent | 82171fab092ec778bbec44b521a0f73495e7783e (diff) | |
download | chromium_src-9a66ed01a85062d9ed2a70138597825bd1e4651f.zip chromium_src-9a66ed01a85062d9ed2a70138597825bd1e4651f.tar.gz chromium_src-9a66ed01a85062d9ed2a70138597825bd1e4651f.tar.bz2 |
Remove unused "Website Settings" view of content settings
This code has been unused for 8+months.
BUG=492024
Review URL: https://codereview.chromium.org/1156983002
Cr-Commit-Position: refs/heads/master@{#332150}
27 files changed, 12 insertions, 2010 deletions
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 0bfb13b..a8a8c3d 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp @@ -2091,12 +2091,6 @@ Press any key to continue exploring. <message name="IDS_OPTIONS_BATTERY_STATUS_LABEL" desc="The label for the battery information in the 'Power' overlay."> Battery: </message> - <message name="IDS_OPTIONS_SETTINGS_BATTERY_DESCRIPTION" desc="The 'Battery' button on the chrome://settings page."> - Battery... - </message> - <message name="IDS_OPTIONS_SETTINGS_STORAGE_DESCRIPTION" desc="The 'Storage' button on the chrome://settings page."> - Stored data... - </message> <message name="IDS_OPTIONS_SETTINGS_SET_TIME_BUTTON" desc="In the settings tab, the prompt on the button to open a dialog to set date and time."> Set date and time </message> diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 2e08aea..8a6acf5 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -304,6 +304,9 @@ are declared in build/common.gypi. </if> <!-- Website Settings UI --> + <message name="IDS_WEBSITE_SETTINGS_TITLE" desc="Title for Website Settings dialog."> + Manage sites + </message> <message name="IDS_WEBSITE_SETTINGS_INFOBAR_TEXT" desc="The string shown in the infobar after the user has changed site permissions settings, reminding them to reload the page in order for the new settings to take effect."> New site permissions settings will take effect after reloading the page. </message> @@ -6791,12 +6794,6 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_ENABLE_WEB_APP_FRAME_DESCRIPTION" desc="Description of the flag that enables the web app style frame for hosted apps."> Enables the web app style frame for hosted apps, including bookmark apps. This is currently only available for Ash. </message> - <message name="IDS_FLAGS_ENABLE_WEBSITE_SETTINGS_NAME" desc="Name of the flag that enables the website settings manager in chrome://settings."> - Enables the website settings manager. - </message> - <message name="IDS_FLAGS_ENABLE_WEBSITE_SETTINGS_DESCRIPTION" desc="Description of the flag that enables the website settings manager in chrome://settings."> - Enables the website settings manager on the settings page. - </message> <message name="IDS_FLAGS_ENABLE_TAB_AUDIO_MUTING_NAME" desc="Name of the flag that enables the tab audio muting UI experiment in chrome://extensions."> Enable tab audio muting UI control. </message> @@ -8375,74 +8372,6 @@ I don't think this site should be blocked! Manage... </message> - <message name="IDS_WEBSITE_SETTINGS_TITLE" desc="Title for Website Settings dialog."> - Manage sites - </message> - <message name="IDS_WEBSITE_SETTINGS_EDIT_TITLE" desc="Title for Website Settings site edit dialog."> - Site settings - </message> - <message name="IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION" desc="Label for granting cookies permission on the Website Settings single site view dialog."> - Stores data - </message> - <message name="IDS_WEBSITE_SETTINGS_DOWNLOAD_DESCRIPTION" desc="Label for granting multiple automatic downloads permission on the Website Settings single site view dialog."> - Automatic downloads - </message> - <message name="IDS_WEBSITE_SETTINGS_JAVASCRIPT_DESCRIPTION" desc="Label for granting scripts permission on the Website Settings single site view dialog."> - Runs scripts - </message> - <message name="IDS_WEBSITE_SETTINGS_IMAGES_DESCRIPTION" desc="Label for granting images permission on the Website Settings single site view dialog."> - Displays images - </message> - <message name="IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION" desc="Label for granting geolocation permission on the Website Settings single site view dialog."> - Knows device location - </message> - <message name="IDS_WEBSITE_SETTINGS_MANAGE" desc="The label on the button that launches the Websites Settings dialog."> - Manage... - </message> - <message name="IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION" desc="Label for granting mediastream permission on the Website Settings single site view dialog."> - Uses camera and microphone - </message> - <message name="IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION" desc="Label for granting notifications permission on the Website Settings single site view dialog."> - Shows notifications - </message> - <message name="IDS_WEBSITE_SETTINGS_PLUGINS_DESCRIPTION" desc="Label for granting plugins permission on the Website Settings single site view dialog."> - Uses plugins - </message> - <message name="IDS_WEBSITE_SETTINGS_POPUPS_DESCRIPTION" desc="Label for granting popup permission on the Website Settings single site view dialog."> - Displays popups - </message> - <message name="IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS" desc="Placeholder text shown in the search box in the Website Settings dialog."> - Search sites - </message> - <message name="IDS_WEBSITE_SETTINGS_STORAGE_USED" desc="The status text for how much local storage a website origin is using."> - <ph name="USAGE">$1<ex>2.0 KB</ex></ph> stored data - </message> - <message name="IDS_WEBSITE_SETTINGS_BATTERY_USED" desc="The status text for how much power a website origin is using."> - <ph name="USAGE">$1<ex>16</ex></ph>% of battery - </message> - <message name="IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON" desc="The 'Clear' button in the Website Settings single site view dialog."> - Clear - </message> - <message name="IDS_WEBSITE_SETTINGS_BATTERY_STOP_BUTTON" desc="The 'Stop' button in the Website Settings single site view dialog."> - Stop - </message> - <message name="IDS_WEBSITE_SETTINGS_BATTERY_PERCENT" desc="The percent from 1 to 100 of battery consumption from a given origin or app on the Website Settings dialog."> - <ph name="VALUE">$1<ex>100</ex></ph>% - </message> - <message name="IDS_WEBSITE_SETTINGS_BATTERY_ZERO_PERCENT" desc="The percent shown when less than 1% of battery was consumed from a given origin or app on the Website Settings dialog."> - <1% - </message> - <message name="IDS_WEBSITE_SETTINGS_ALLOWED_LIST_TITLE" desc="Label above the list of allowed origins for a given permission on the Website Settings dialog."> - Allowed - </message> - <message name="IDS_WEBSITE_SETTINGS_BLOCKED_LIST_TITLE" desc="Label above the list of blocked origins for a given permission on the Website Settings dialog."> - Blocked - </message> - <message name="IDS_WEBSITE_SETTINGS_CONTENT_SETTING_ENABLED" desc="Label next to the checkbox that enables/disables a content setting."> - On - </message> - - <!-- Automatic updates --> <if expr="is_macosx"> <message name="IDS_PROMOTE_INFOBAR_TEXT" desc="The text to show in the automatic update setup info bar. Mac-only."> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 56b8576..0a5edb1 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -2018,13 +2018,6 @@ const Experiment kExperiments[] = { }, #endif { - "enable-website-settings-manager", - IDS_FLAGS_ENABLE_WEBSITE_SETTINGS_NAME, - IDS_FLAGS_ENABLE_WEBSITE_SETTINGS_DESCRIPTION, - kOsDesktop, - SINGLE_VALUE_TYPE(switches::kEnableWebsiteSettingsManager) - }, - { "remember-cert-error-decisions", IDS_FLAGS_REMEMBER_CERTIFICATE_ERROR_DECISIONS_NAME, IDS_FLAGS_REMEMBER_CERTIFICATE_ERROR_DECISIONS_DESCRIPTION, diff --git a/chrome/browser/resources/options/browser_options.html b/chrome/browser/resources/options/browser_options.html index 2f6aad4..8a6be13 100644 --- a/chrome/browser/resources/options/browser_options.html +++ b/chrome/browser/resources/options/browser_options.html @@ -113,10 +113,6 @@ <a is="action-link" id="power-settings-button" i18n-content="powerSettingsButton"></a> </div> - <div class="settings-row"> - <button id="battery-button" i18n-content="batteryButton"></button> - <button id="stored-data-button" i18n-content="storageButton"></button> - </div> <div id="touchpad-settings" class="settings-row" hidden> <span class="option-name" i18n-content="touchpadSpeed"></span> <input id="touchpad-sensitivity-range" type="range" min="1" max="5" @@ -618,10 +614,6 @@ <section id="web-content-section"> <h3 i18n-content="advancedSectionTitleContent"></h3> <div> - <div id="website-settings-section" class="settings-row" hidden> - <button id="website-management-button" - i18n-content="websitesManage"></button> - </div> <div class="settings-row"> <label class="web-content-select-label"> <span i18n-content="defaultFontSizeLabel"></span> diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js index d9456b7..b59cb45 100644 --- a/chrome/browser/resources/options/browser_options.js +++ b/chrome/browser/resources/options/browser_options.js @@ -300,12 +300,6 @@ cr.define('options', function() { chrome.send('coreOptionsUserMetricsAction', ['Options_ShowPowerSettings']); }; - $('battery-button').onclick = function(evt) { - WebsiteSettingsManager.showWebsiteSettings('battery'); - }; - $('stored-data-button').onclick = function(evt) { - WebsiteSettingsManager.showWebsiteSettings('storage'); - }; $('keyboard-settings-button').onclick = function(evt) { PageManager.showPageByName('keyboard-overlay'); chrome.send('coreOptionsUserMetricsAction', @@ -592,14 +586,6 @@ cr.define('options', function() { $('easy-unlock-enable-proximity-detection').hidden = !loadTimeData.getBoolean('easyUnlockProximityDetectionAllowed'); - // Website Settings section. - if (loadTimeData.getBoolean('websiteSettingsManagerEnabled')) { - $('website-settings-section').hidden = false; - $('website-management-button').onclick = function(event) { - PageManager.showPageByName('websiteSettings'); - }; - } - // Web Content section. $('fontSettingsCustomizeFontsButton').onclick = function(event) { PageManager.showPageByName('fonts'); diff --git a/chrome/browser/resources/options/content_settings.html b/chrome/browser/resources/options/content_settings.html index 4eec231..251ad12 100644 --- a/chrome/browser/resources/options/content_settings.html +++ b/chrome/browser/resources/options/content_settings.html @@ -5,7 +5,7 @@ <!-- Cookie filter tab contents --> <section> <h3 i18n-content="cookiesTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="cookies" value="allow"> @@ -64,20 +64,11 @@ i18n-content="cookiesShowCookies"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="cookies-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="cookies" i18n-content="websitesManage"></button> - <button id="show-cookies-button" - i18n-content="cookiesShowCookies"></button> - </div> - </div> </section> <!-- Image filter --> <section> <h3 i18n-content="imagesTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="images" value="allow"> @@ -103,18 +94,11 @@ i18n-content="manageExceptions"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="images-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="images" i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- JavaScript filter --> <section> <h3 i18n-content="javascriptTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="javascript" value="allow"> @@ -140,13 +124,6 @@ i18n-content="manageExceptions"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="javascript-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="javascript" i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- Handlers settings --> <section id="handlers-section"> @@ -175,7 +152,7 @@ <!-- Plugins filter --> <section> <h3 i18n-content="pluginsTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input id="plugins-allow-radio" type="radio" name="plugins" @@ -216,18 +193,11 @@ target="_blank"></a> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="plugins-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="plugins" i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- Pop-ups filter --> <section> <h3 i18n-content="popupsTabLabel" class="content-settings-header"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="popups" value="allow"> @@ -253,18 +223,11 @@ i18n-content="manageExceptions"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="popups-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="popups" i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- Location filter --> <section> <h3 i18n-content="locationTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="location" value="allow"> @@ -316,18 +279,11 @@ i18n-content="manageExceptions"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="location-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="geolocation" i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- Notifications filter tab contents --> <section id="notifications-section"> <h3 i18n-content="notificationsTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="notifications" value="allow"> @@ -363,14 +319,6 @@ i18n-content="manageExceptions"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="notifications-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="notifications" - i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- Fullscreen filter --> <section> @@ -488,7 +436,7 @@ </span> </label> </div> - <div class="settings-row replace-with-website-settings"> + <div class="settings-row"> <button class="exceptions-list-button" contentType="media-stream" i18n-content="manageExceptions"></button> </div> @@ -498,12 +446,6 @@ i18n-values="href:mediaPepperFlashGlobalPrivacyURL"></a> </div> </div> - <div class="experimental-website-settings" hidden> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="media-stream" i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- PPAPI broker --> <section> @@ -548,7 +490,7 @@ <!-- Automatic Downloads filter --> <section> <h3 i18n-content="multipleAutomaticDownloadsTabLabel"></h3> - <div class="replace-with-website-settings"> + <div> <div class="radio controlled-setting-with-label"> <label> <input type="radio" name="multiple-automatic-downloads" @@ -590,14 +532,6 @@ i18n-content="manageExceptions"></button> </div> </div> - <div class="experimental-website-settings" hidden> - <span id="multiple-automatic-downloads-default-string"></span> - <div class="settings-row"> - <button class="website-settings-permission-button" - contentType="multiple-automatic-downloads" - i18n-content="websitesManage"></button> - </div> - </div> </section> <!-- MIDI system exclusive messages filter --> <section> diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js index 31e6a60..f77b3f4 100644 --- a/chrome/browser/resources/options/content_settings.js +++ b/chrome/browser/resources/options/content_settings.js @@ -66,15 +66,6 @@ cr.define('options', function() { }; } - var experimentalExceptionsButtons = - this.pageDiv.querySelectorAll('.website-settings-permission-button'); - for (var i = 0; i < experimentalExceptionsButtons.length; i++) { - experimentalExceptionsButtons[i].onclick = function(event) { - var hash = event.currentTarget.getAttribute('contentType'); - WebsiteSettingsManager.showWebsiteSettings(hash); - }; - } - var manageHandlersButton = $('manage-handlers-button'); if (manageHandlersButton) { manageHandlersButton.onclick = function(event) { @@ -106,20 +97,6 @@ cr.define('options', function() { ContentSettings.setDefaultMicrophone_); $('media-select-camera').addEventListener('change', ContentSettings.setDefaultCamera_); - - if (loadTimeData.getBoolean('websiteSettingsManagerEnabled')) { - var oldUI = - this.pageDiv.querySelectorAll('.replace-with-website-settings'); - for (var i = 0; i < oldUI.length; i++) { - oldUI[i].hidden = true; - } - - var newUI = - this.pageDiv.querySelectorAll('.experimental-website-settings'); - for (var i = 0; i < newUI.length; i++) { - newUI[i].hidden = false; - } - } }, }; diff --git a/chrome/browser/resources/options/options.html b/chrome/browser/resources/options/options.html index 662762c..e71868e 100644 --- a/chrome/browser/resources/options/options.html +++ b/chrome/browser/resources/options/options.html @@ -48,7 +48,6 @@ <link rel="stylesheet" href="supervised_user_create_confirm.css"> <link rel="stylesheet" href="supervised_user_import.css"> <link rel="stylesheet" href="supervised_user_learn_more.css"> -<link rel="stylesheet" href="website_settings.css"> <link rel="stylesheet" href="../help/help_content.css"> <link rel="stylesheet" href="sync_setup_overlay.css"> <if expr="chromeos"> @@ -156,7 +155,6 @@ <include src="language_add_language_overlay.html"> <include src="supervised_user_import.html"> <include src="supervised_user_learn_more.html"> - <include src="website_settings.html"> <if expr="not is_macosx"> <include src="language_dictionary_overlay.html"> </if> @@ -173,9 +171,6 @@ <include src="certificate_edit_ca_trust_overlay.html"> <include src="certificate_import_error_overlay.html"> </if> -<div id="overlay-container-3" class="overlay transparent" hidden> - <include src="website_settings_edit_site.html"> -</div> </div> <div id="extension-controlled-settings-bubble-template" hidden> <div class="controlled-setting-bubble-content-row"> diff --git a/chrome/browser/resources/options/options.js b/chrome/browser/resources/options/options.js index e060024..c7e2911 100644 --- a/chrome/browser/resources/options/options.js +++ b/chrome/browser/resources/options/options.js @@ -45,8 +45,6 @@ var SupervisedUserCreateConfirmOverlay = var SupervisedUserImportOverlay = options.SupervisedUserImportOverlay; var SupervisedUserLearnMoreOverlay = options.SupervisedUserLearnMoreOverlay; var SyncSetupOverlay = options.SyncSetupOverlay; -var WebsiteSettingsEditor = options.WebsiteSettings.WebsiteSettingsEditor; -var WebsiteSettingsManager = options.ContentSettings.WebsiteSettingsManager; var ThirdPartyImeConfirmOverlay = options.ThirdPartyImeConfirmOverlay; /** @@ -116,10 +114,6 @@ function load() { PageManager.registerOverlay(ContentSettings.getInstance(), BrowserOptions.getInstance(), [$('privacyContentSettingsButton')]); - PageManager.registerOverlay(WebsiteSettingsManager.getInstance(), - ContentSettings.getInstance()); - PageManager.registerOverlay(WebsiteSettingsEditor.getInstance(), - WebsiteSettingsManager.getInstance()); PageManager.registerOverlay(ContentSettingsExceptionsArea.getInstance(), ContentSettings.getInstance()); PageManager.registerOverlay(CookiesView.getInstance(), diff --git a/chrome/browser/resources/options/options_bundle.js b/chrome/browser/resources/options/options_bundle.js index 6b90d4f..2e55cc8 100644 --- a/chrome/browser/resources/options/options_bundle.js +++ b/chrome/browser/resources/options/options_bundle.js @@ -102,7 +102,6 @@ var CertificateImportErrorOverlay = options.CertificateImportErrorOverlay; <include src="language_options.js"> <include src="manage_profile_overlay.js"> <include src="options_focus_manager.js"> -<include src="origin_resources_list.js"> <include src="password_manager.js"> <include src="password_manager_list.js"> <include src="profiles_icon_grid.js"> @@ -117,8 +116,6 @@ var CertificateImportErrorOverlay = options.CertificateImportErrorOverlay; <include src="supervised_user_learn_more.js"> <include src="supervised_user_list.js"> <include src="supervised_user_list_data.js"> -<include src="website_settings.js"> -<include src="website_settings_edit_page.js"> <include src="../help/help_page.js"> <include src="sync_setup_overlay.js"> <include src="../uber/uber_page_manager_observer.js"> diff --git a/chrome/browser/resources/options/origin_resources_list.js b/chrome/browser/resources/options/origin_resources_list.js deleted file mode 100644 index 1b35bc2..0000000 --- a/chrome/browser/resources/options/origin_resources_list.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.define('options', function() { - /** @const */ var List = cr.ui.List; - /** @const */ var ListItem = cr.ui.ListItem; - - /** - * Creates a new list item for the origin's data. - * @param {!Object} origin Data used to create the origin list item. - * @constructor - * @extends {cr.ui.ListItem} - */ - function OriginListItem(origin) { - var el = cr.doc.createElement('div'); - el.origin_ = origin.origin; - el.usage_ = origin.usage; - el.usageString_ = origin.usageString; - el.readableName_ = origin.readableName; - el.__proto__ = OriginListItem.prototype; - el.decorate(); - return el; - } - - OriginListItem.prototype = { - __proto__: ListItem.prototype, - - /** @override */ - decorate: function() { - ListItem.prototype.decorate.call(this); - - this.className = 'deletable-item origin-list-item'; - this.contentElement_ = this.ownerDocument.createElement('div'); - this.appendChild(this.contentElement_); - - var titleEl = this.ownerDocument.createElement('div'); - titleEl.className = 'title favicon-cell weaktrl'; - titleEl.textContent = this.readableName_; - titleEl.originPattern = this.origin_; - titleEl.style.backgroundImage = getFaviconImageSet(this.origin_); - this.contentElement_.appendChild(titleEl); - - this.contentElement_.onclick = function() { - chrome.send('maybeShowEditPage', [titleEl.originPattern]); - }; - - if (this.usageString_) { - var usageEl = this.ownerDocument.createElement('span'); - usageEl.className = 'local-storage-usage'; - usageEl.textContent = this.usageString_; - this.appendChild(usageEl); - } - } - }; - - /** - * @constructor - * @extends {cr.ui.List} - */ - var OriginList = cr.ui.define('list'); - - OriginList.prototype = { - __proto__: List.prototype, - - /** - * @override - * @param {!Object} entry - */ - createItem: function(entry) { - return new OriginListItem(entry); - }, - }; - - return { - OriginListItem: OriginListItem, - OriginList: OriginList, - }; -}); diff --git a/chrome/browser/resources/options/website_settings.css b/chrome/browser/resources/options/website_settings.css deleted file mode 100644 index 52c2b7d..0000000 --- a/chrome/browser/resources/options/website_settings.css +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright 2014 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. */ - -#website-settings-page { - min-height: 445px; - min-width: 540px; -} - -#website-settings-edit-page { - min-width: 540px; -} - -.website-column-headers { - padding: 3px 0 6px; -} - -.website-header-controls { - align-items: center; - display: flex; - justify-content: space-between; -} - -.website-header-controls > div { - font-weight: bold; -} - -#allowed-origin-list-title { - font-size: 1.3em; -} - -#website-settings-search-box { - width: 165px; -} - -#website-settings-page .action-area { - padding-bottom: 20px; -} - -.website-list-content-area { - display: flex; - flex-direction: column; -} - -.permission-name { - -webkit-margin-start: 7px; - font-size: 13px; - width: 300px; -} - -#website-settings-edit-page .permission-selection-option { - -webkit-margin-end: 20px; - -webkit-margin-start: 35px; - width: 12em; -} - -#website-settings-permission-column { - -webkit-margin-start: 8px; -} - -.website-properties { - -webkit-margin-start: 8px; - margin-bottom: 8px; - padding-bottom: 4px; -} - -.website-property-area { - align-items: center; - display: flex; - justify-content: space-between; - margin-bottom: 8px; -} - -.website-property-button { - margin-bottom: 9em; -} - -#website-title { - -webkit-padding-start: 21px; - font-size: 15px; - line-height: 20px; - margin-bottom: 22px; - margin-top: 0; -} - -#website-settings-page .content-area { - padding: auto 20px; -} - -#website-settings-page .action-area { - padding: auto 20px; - -} - -#website-settings-edit-page .action-area { - padding: auto 20px; - -} - -.origin-permission-list { - border: 1px solid #d9d9d9; - height: 192px; - padding-top: 4px; -} - -#website-settings-edit-page .website-property-button { - min-width: 70px; -} - -#website-settings-edit-page .website-property-controls { - min-width: 165px; -} - -#website-settings-global-controls { - align-items: center; - display: flex; - margin-bottom: 24px; -} - -#global-setting { - -webkit-margin-start: 35px; - flex: 1; -} - -/* Styles for the origin list elements in the website settings page. */ -.origin-list { - border: 1px solid #d9d9d9; - font-size: 13px; - height: 192px; - margin: 5px 0 0; -} - -#website-settings-page .blocked-origin-list { - height: 128px; - min-height: 128px; -} - -#website-settings-page .nonsplit-origin-list { - height: 357px; - min-height: 357px; -} - -#origin-list-item { - height: 30px; -} - -.local-storage-usage { - color: #7f7f7f; - margin: auto 0; -} - -list.origin-list .favicon-cell { - -webkit-margin-start: 6px; - -webkit-padding-start: 21px; -} - -list.origin-list .favicon-cell { - -webkit-margin-start: 5px; - -webkit-padding-start: 21px; - font-size: 13px; -} - -.permission-option { - align-items: center; - display: flex; - justify-content: space-between; - margin-top: 4px; -} diff --git a/chrome/browser/resources/options/website_settings.html b/chrome/browser/resources/options/website_settings.html deleted file mode 100644 index 8bd13db..0000000 --- a/chrome/browser/resources/options/website_settings.html +++ /dev/null @@ -1,36 +0,0 @@ -<div id="website-settings-page" class="page website-settings-page not-resizable" - hidden> - <div class="close-button"></div> - <h1 id="website-settings-title" i18n-content="websiteSettingsPage"></h1> - <div id="website-list-content-area" class="content-area"> - <div class="website-column-headers"> - <div id="website-settings-global-controls"> - <div class="checkbox"> - <label> - <input id="global-setting-toggle" type="checkbox"> - <span i18n-content="websitesLabelOn"></span> - </label> - </div> - <select id="global-setting"></select> - </div> - <div class="website-header-controls"> - <span id="allowed-origin-list-title" - i18n-content="websitesAllowedListTitle"> - </span> - <input type="search" id="website-settings-search-box" - i18n-values="placeholder:websitesSearch" incremental> - </div> - </div> - <list id="allowed-origin-list" class="origin-list"></list> - <h2 id="blocked-origin-list-title" i18n-content="websitesBlockedListTitle"> - </h2> - <list id="blocked-origin-list" class="blocked-origin-list origin-list"> - </list> - </div> - <div class="action-area"> - <div class="button-strip"> - <button id="website-settings-overlay-confirm" i18n-content="done"> - </button> - </div> - </div> -</div> diff --git a/chrome/browser/resources/options/website_settings.js b/chrome/browser/resources/options/website_settings.js deleted file mode 100644 index f8aa136..0000000 --- a/chrome/browser/resources/options/website_settings.js +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.define('options.ContentSettings', function() { - /** @const */ var Page = cr.ui.pageManager.Page; - /** @const */ var PageManager = cr.ui.pageManager.PageManager; - /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; - - // Lookup table to generate the i18n strings. - /** @const */ var permissionsLookup = { - 'geolocation': 'location', - 'notifications': 'notifications', - 'media-stream': 'mediaStream', - 'cookies': 'cookies', - 'multiple-automatic-downloads': 'multipleAutomaticDownloads', - 'images': 'images', - 'plugins': 'plugins', - 'popups': 'popups', - 'javascript': 'javascript', - 'battery': 'battery', - 'storage': 'storage' - }; - - ///////////////////////////////////////////////////////////////////////////// - // WebsiteSettingsManager class: - - /** - * Encapsulated handling of the website settings page. - * @constructor - * @extends {cr.ui.pageManager.Page} - */ - function WebsiteSettingsManager() { - Page.call(this, 'websiteSettings', - loadTimeData.getString('websitesOptionsPageTabTitle'), - 'website-settings-page'); - } - - cr.addSingletonGetter(WebsiteSettingsManager); - - WebsiteSettingsManager.prototype = { - __proto__: Page.prototype, - - /** - * The saved allowed origins list. - * @type {options.OriginList} - * @private - */ - allowedList_: null, - - /** - * The saved blocked origins list. - * @type {options.OriginList} - * @private - */ - blockedList_: null, - - /** @override */ - initializePage: function() { - Page.prototype.initializePage.call(this); - - $('website-settings-overlay-confirm').onclick = - PageManager.closeOverlay.bind(PageManager); - - $('global-setting').onchange = function(event) { - chrome.send('setDefaultContentSetting', [this.value]); - }; - - $('global-setting-toggle').onchange = function(event) { - var value = event.target.checked; - chrome.send('setGlobalEnabled', [value]); - }; - - var searchBox = $('website-settings-search-box'); - searchBox.addEventListener('search', - this.handleSearchQueryChange_.bind(this)); - - searchBox.onkeydown = function(e) { - if (e.keyIdentifier == 'Enter') - e.preventDefault(); - }; - - this.createOriginsList_(); - this.updatePage_('geolocation'); - }, - - /** - * Called after the page has been shown. Show the content settings or - * resource auditing for the location's hash. - */ - didShowPage: function() { - var hash = this.hash; - if (hash) - hash = hash.slice(1); - else - hash = 'geolocation'; - this.updatePage_(hash); - }, - - /** - * Creates, decorates and initializes the origin list. - * @private - */ - createOriginsList_: function() { - var allowedList = $('allowed-origin-list'); - options.OriginList.decorate(allowedList); - this.allowedList_ = assertInstanceof(allowedList, options.OriginList); - this.allowedList_.autoExpands = true; - - var blockedList = $('blocked-origin-list'); - options.OriginList.decorate(blockedList); - this.blockedList_ = assertInstanceof(blockedList, options.OriginList); - this.blockedList_.autoExpands = true; - }, - - /** - * Populate an origin list with all of the origins with a given permission - * or that are using a given resource. - * @param {options.OriginList} originList A list to populate. - * @param {!Object} originDict A dictionary of origins to their usage, which - will be used to sort the origins. - * @private - */ - populateOriginsHelper_: function(originList, originDict) { - var origins = Object.keys(originDict).map(function(origin) { - // |usage| means the time of last usage in seconds since epoch - // (Jan 1, 1970) for permissions and means the amount of local storage - // in bytes used for local storage. - return { - origin: origin, - usage: originDict[origin].usage, - usageString: originDict[origin].usageString, - readableName: originDict[origin].readableName, - }; - }); - origins.sort(function(first, second) { - return second.usage - first.usage; - }); - originList.dataModel = new ArrayDataModel(origins); - }, - - - /** - * Populate the origin lists with all of the origins with a given permission - * or that are using a given resource, potentially split by if allowed or - * denied. If no blocked dictionary is provided, only the allowed list is - * shown. - * @param {!Object} allowedDict A dictionary of origins to their usage, - which will be used to sort the origins in the main/allowed list. - * @param {!Object} blockedDict An optional dictionary of origins to their - usage, which will be used to sort the origins in the blocked list. - * @param {boolean} isGloballyEnabled If the content setting is turned on. - * @private - */ - populateOrigins: function(allowedDict, blockedDict, isGloballyEnabled) { - this.populateOriginsHelper_(this.allowedList_, allowedDict); - if (blockedDict) { - this.populateOriginsHelper_(this.blockedList_, blockedDict); - this.blockedList_.hidden = false; - $('blocked-origin-list-title').hidden = false; - this.allowedList_.classList.remove('nonsplit-origin-list'); - } else { - this.blockedList_.hidden = true; - $('blocked-origin-list-title').hidden = true; - $('allowed-origin-list-title').hidden = true; - this.allowedList_.classList.add('nonsplit-origin-list'); - } - $('global-setting-toggle').checked = isGloballyEnabled; - }, - - /** - * Update the table with the origins filtered by the value in the search - * box. - * @private - */ - searchOrigins: function() { - var filter = $('website-settings-search-box').value; - chrome.send('updateOriginsSearchResults', [filter]); - }, - - /** - * Handle and delay search query changes. - * @param {!Event} e The event object. - * @private - */ - handleSearchQueryChange_: function(e) { - if (this.queryDelayTimerId_) - window.clearTimeout(this.queryDelayTimerId_); - - this.queryDelayTimerId_ = window.setTimeout(this.searchOrigins.bind(this), - 160); - }, - - /** - * Sets the default content setting dropdown on the page to the current - * default. - * @param {!Object} dict A dictionary with the management and value of the - * default setting for the last selected content setting.. - */ - updateDefault: function(dict) { - // TODO(dhnishi): Remove duplicate default handling in the Content - // Settings page and here. - var managedBy = dict.managedBy; - var controlledBy = managedBy == 'policy' || managedBy == 'extension' ? - managedBy : null; - $('global-setting').disabled = (managedBy != 'default'); - - var options = $('global-setting').options; - for (var i = 0; i < options.length; i++) { - if (options[i].value == dict.value) { - options.selectedIndex = i; - } - } - }, - - /** - * Updates the page with the given content setting or resource name's - * information. - * @param {string} typeName The name of the content setting or resource. - */ - updatePage_: function(typeName) { - if (typeName == 'storage') - chrome.send('updateLocalStorage'); - else if (typeName == 'battery') - chrome.send('updateBatteryUsage'); - else - chrome.send('updateOrigins', [typeName]); - - var options = $('global-setting').options; - options.length = 0; - var permissionString = permissionsLookup[typeName]; - var permissions = ['Allow', 'Ask', 'Block']; - for (var i = 0; i < permissions.length; i++) { - var valueId = permissionString + permissions[i]; - if (loadTimeData.valueExists(valueId)) { - options.add(new Option(loadTimeData.getString(valueId), - permissions[i].toLowerCase())); - } - } - if (options.length == 0) { - $('website-settings-global-controls').hidden = true; - } else { - $('website-settings-global-controls').hidden = false; - chrome.send('updateDefaultSetting'); - } - - $('website-settings-title').textContent = - loadTimeData.getString(permissionString + 'TabLabel'); - } - }; - - WebsiteSettingsManager.populateOrigins = function(allowedDict, blockedDict, - isGloballyEnabled) { - WebsiteSettingsManager.getInstance().populateOrigins(allowedDict, - blockedDict, isGloballyEnabled); - }; - - WebsiteSettingsManager.updateDefault = function(dict) { - WebsiteSettingsManager.getInstance().updateDefault(dict); - }; - - WebsiteSettingsManager.showWebsiteSettings = function(hash) { - PageManager.showPageByName('websiteSettings', true, {hash: '#' + hash}); - }; - - // Export - return { - WebsiteSettingsManager: WebsiteSettingsManager - }; -}); diff --git a/chrome/browser/resources/options/website_settings_edit_page.js b/chrome/browser/resources/options/website_settings_edit_page.js deleted file mode 100644 index 63b3e9b..0000000 --- a/chrome/browser/resources/options/website_settings_edit_page.js +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -cr.define('options.WebsiteSettings', function() { - /** @const */ var Page = cr.ui.pageManager.Page; - - ///////////////////////////////////////////////////////////////////////////// - // WebsiteSettingsEditor class: - - /** - * Encapsulated handling of the website settings editor page. - * @constructor - * @extends {cr.ui.pageManager.Page} - */ - function WebsiteSettingsEditor() { - Page.call(this, 'websiteEdit', - loadTimeData.getString('websitesOptionsPageTabTitle'), - 'website-settings-edit-page'); - this.permissions = ['geolocation', 'notifications', 'media-stream', - 'cookies', 'multiple-automatic-downloads', 'images', - 'plugins', 'popups', 'javascript']; - this.permissionsLookup = { - 'geolocation': 'Location', - 'notifications': 'Notifications', - 'media-stream': 'MediaStream', - 'cookies': 'Cookies', - 'multiple-automatic-downloads': 'Downloads', - 'images': 'Images', - 'plugins': 'Plugins', - 'popups': 'Popups', - 'javascript': 'Javascript' - }; - } - - cr.addSingletonGetter(WebsiteSettingsEditor); - - WebsiteSettingsEditor.prototype = { - __proto__: Page.prototype, - - - /** @override */ - initializePage: function() { - Page.prototype.initializePage.call(this); - - $('website-settings-storage-delete-button').onclick = function(event) { - chrome.send('deleteLocalStorage'); - }; - - $('website-settings-battery-stop-button').onclick = function(event) { - chrome.send('stopOrigin'); - }; - - $('websiteSettingsEditorCancelButton').onclick = - PageManager.closeOverlay.bind(PageManager); - - $('websiteSettingsEditorDoneButton').onclick = function(event) { - WebsiteSettingsEditor.getInstance().updatePermissions(); - PageManager.closeOverlay.bind(PageManager)(); - }; - - var permissionList = - this.pageDiv.querySelector('.origin-permission-list'); - for (var key in this.permissions) { - permissionList.appendChild( - this.makePermissionOption_(this.permissions[key])); - } - }, - - /** - * Populates the page with the proper information for a given URL. - * @param {string} url The URL of the page. - * @private - */ - populatePage: function(url) { - this.url = url; - - var titleEl = $('website-title'); - titleEl.textContent = url; - titleEl.style.backgroundImage = getFaviconImageSet(url); - - chrome.send('getOriginInfo', [url]); - }, - - /** - * Populates and displays the page with given origin information. - * @param {string} localStorage A string describing the local storage use. - * @param {string} batteryUsage A string describing the battery use. - * @param {Object} permissions A dictionary of permissions to their - * available and current settings, and if it is editable. - * @param {boolean} showPage If the page should raised. - * @private - */ - populateOrigin_: function(localStorage, batteryUsage, permissions, - showPage) { - $('local-storage-title').textContent = localStorage; - $('battery-title').textContent = batteryUsage; - for (var key in permissions) { - var selector = $(key + '-select-option'); - - var options = permissions[key].options; - selector.options.length = 0; - for (var option in options) { - selector.options[selector.options.length] = - new Option(loadTimeData.getString(options[option] + 'Exception'), - options[option]); - } - - selector.value = permissions[key].setting; - selector.originalValue = permissions[key].setting; - selector.disabled = !permissions[key].editable; - } - if (showPage) - PageManager.showPageByName('websiteEdit', false); - }, - - updatePermissions: function() { - for (var key in this.permissions) { - var selection = $(this.permissions[key] + '-select-option'); - if (selection.value != selection.originalValue) { - chrome.send('setOriginPermission', - [this.permissions[key], selection.value]); - } - } - }, - - /** - * Populates the origin permission list with the different usable - * permissions. - * @param {string} permissionName A string with the permission name. - * @return {Element} The element with the usable permission setting. - */ - makePermissionOption_: function(permissionName) { - var permissionOption = cr.doc.createElement('div'); - permissionOption.className = 'permission-option'; - - var permissionNameSpan = cr.doc.createElement('span'); - permissionNameSpan.className = 'permission-name'; - permissionNameSpan.textContent = loadTimeData.getString('websites' + - this.permissionsLookup[permissionName] + 'Description'); - permissionOption.appendChild(permissionNameSpan); - - var permissionSelector = cr.doc.createElement('select'); - permissionSelector.setAttribute('id', permissionName + '-select-option'); - permissionSelector.className = 'weaktrl permission-selection-option'; - permissionOption.appendChild(permissionSelector); - return permissionOption; - }, - }; - - WebsiteSettingsEditor.populateOrigin = function(localStorage, batteryUsage, - permissions, showPage) { - WebsiteSettingsEditor.getInstance().populateOrigin_(localStorage, - batteryUsage, - permissions, - showPage); - }; - - WebsiteSettingsEditor.showEditPage = function(url) { - WebsiteSettingsEditor.getInstance().populatePage(url); - }; - - // Export - return { - WebsiteSettingsEditor: WebsiteSettingsEditor - }; - -}); diff --git a/chrome/browser/resources/options/website_settings_edit_site.html b/chrome/browser/resources/options/website_settings_edit_site.html deleted file mode 100644 index db1649b..0000000 --- a/chrome/browser/resources/options/website_settings_edit_site.html +++ /dev/null @@ -1,39 +0,0 @@ -<div id="website-settings-edit-page" class="page not-resizable" hidden> - <div class="close-button"></div> - <h1 i18n-content="websitesSettingsEditPage"></h1> - <div class="content-area"> - <div class="website-properties"> - <h3 id="website-title" class="title favicon-cell weaktrl"></h3> - <div class="website-property-area"> - <div id="local-storage-title" class="website-property"></div> - <div class="website-property-controls"> - <button id="website-settings-storage-delete-button" - class="website-property-button" - i18n-content="websitesButtonClear"> - </div> - </div> - <div class="website-property-area"> - <div id="battery-title" class="website-property"></div> - <div class="website-property-controls"> - <button id="website-settings-battery-stop-button" - class="website-property-button" - i18n-content="websitesButtonStop"> - </div> - </div> - </div> - <div class="website-column-headers"> - <div class="website-header-controls"> - <div id="website-settings-permission-column">Permissions</div> - </div> - </div> - <list class="origin-permission-list"></list> - </div> - <div class="action-area"> - <div class="button-strip"> - <button id="websiteSettingsEditorCancelButton" i18n-content="cancel"> - </button> - <button id="websiteSettingsEditorDoneButton" i18n-content="done"> - </button> - </div> - </div> -</div> diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc index 68df1d0..e0407af 100644 --- a/chrome/browser/ui/webui/options/browser_options_handler.cc +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc @@ -415,7 +415,6 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) { IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_VERY_LONG }, { "autoclickDelayVeryShort", IDS_OPTIONS_SETTINGS_ACCESSIBILITY_AUTOCLICK_DELAY_VERY_SHORT }, - { "batteryButton", IDS_OPTIONS_SETTINGS_BATTERY_DESCRIPTION}, { "changePicture", IDS_OPTIONS_CHANGE_PICTURE }, { "changePictureCaption", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, { "consumerManagementDescription", @@ -457,7 +456,6 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) { IDS_OPTIONS_RESOLVE_TIMEZONE_BY_GEOLOCATION_DESCRIPTION }, { "sectionTitleDevice", IDS_OPTIONS_DEVICE_GROUP_NAME }, { "sectionTitleInternet", IDS_OPTIONS_INTERNET_OPTIONS_GROUP_LABEL }, - { "storageButton", IDS_OPTIONS_SETTINGS_STORAGE_DESCRIPTION}, { "syncButtonTextStart", IDS_SYNC_SETUP_BUTTON_LABEL }, { "thirdPartyImeConfirmDisable", IDS_CANCEL }, { "thirdPartyImeConfirmEnable", IDS_OK }, @@ -665,10 +663,6 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) { values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings()); - values->SetBoolean("websiteSettingsManagerEnabled", - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableWebsiteSettingsManager)); - values->SetBoolean("usingNewProfilesUI", switches::IsNewAvatarMenu()); #if defined(OS_CHROMEOS) diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc index 9b576d7..5a5bc39 100644 --- a/chrome/browser/ui/webui/options/options_ui.cc +++ b/chrome/browser/ui/webui/options/options_ui.cc @@ -46,7 +46,6 @@ #include "chrome/browser/ui/webui/options/search_engine_manager_handler.h" #include "chrome/browser/ui/webui/options/startup_pages_handler.h" #include "chrome/browser/ui/webui/options/sync_setup_handler.h" -#include "chrome/browser/ui/webui/options/website_settings_handler.h" #include "chrome/browser/ui/webui/theme_source.h" #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" @@ -309,7 +308,6 @@ OptionsUI::OptionsUI(content::WebUI* web_ui) new SupervisedUserLearnMoreHandler()); #endif AddOptionsPageUIHandler(localized_strings, new SyncSetupHandler()); - AddOptionsPageUIHandler(localized_strings, new WebsiteSettingsHandler()); #if defined(OS_CHROMEOS) AddOptionsPageUIHandler(localized_strings, new chromeos::options::AccountsOptionsHandler()); diff --git a/chrome/browser/ui/webui/options/website_settings_browsertest.js b/chrome/browser/ui/webui/options/website_settings_browsertest.js deleted file mode 100644 index e08de1b..0000000 --- a/chrome/browser/ui/webui/options/website_settings_browsertest.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * TestFixture for website settings WebUI testing. - * @extends {testing.Test} - * @constructor - */ -function WebsiteSettingsWebUITest() {} - -WebsiteSettingsWebUITest.prototype = { - __proto__: testing.Test.prototype, - - /** - * Browse to the website settings. - */ - browsePreload: 'chrome://settings-frame/websiteSettings', -}; - -// Test opening the website settings manager has the correct location. -TEST_F('WebsiteSettingsWebUITest', 'testOpenWebsiteSettings', function() { - assertEquals(this.browsePreload, document.location.href); -}); diff --git a/chrome/browser/ui/webui/options/website_settings_handler.cc b/chrome/browser/ui/webui/options/website_settings_handler.cc deleted file mode 100644 index da57296..0000000 --- a/chrome/browser/ui/webui/options/website_settings_handler.cc +++ /dev/null @@ -1,833 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/options/website_settings_handler.h" - -#include "base/metrics/histogram.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_iterator.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/grit/generated_resources.h" -#include "components/content_settings/core/browser/content_settings_utils.h" -#include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/power/origin_power_map.h" -#include "components/power/origin_power_map_factory.h" -#include "content/public/browser/dom_storage_context.h" -#include "content/public/browser/storage_partition.h" -#include "content/public/browser/user_metrics.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_ui.h" -#include "extensions/browser/app_window/app_window_registry.h" -#include "extensions/browser/extension_registry.h" -#include "extensions/common/constants.h" -#include "extensions/common/extension.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/l10n/time_format.h" -#include "ui/base/text/bytes_formatting.h" - -#if defined(OS_CHROMEOS) -#include "components/user_manager/user_manager.h" -#endif - -using base::UserMetricsAction; -using power::OriginPowerMap; -using power::OriginPowerMapFactory; - -namespace { - -const char kBattery[] = "battery"; -const int kHttpPort = 80; -const int kHttpsPort = 443; -const char kPreferencesSource[] = "preference"; -const char kStorage[] = "storage"; -const ContentSettingsType kValidTypes[] = { - CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, - CONTENT_SETTINGS_TYPE_COOKIES, - CONTENT_SETTINGS_TYPE_GEOLOCATION, - CONTENT_SETTINGS_TYPE_IMAGES, - CONTENT_SETTINGS_TYPE_JAVASCRIPT, - CONTENT_SETTINGS_TYPE_NOTIFICATIONS, - CONTENT_SETTINGS_TYPE_MEDIASTREAM, - CONTENT_SETTINGS_TYPE_PLUGINS, - CONTENT_SETTINGS_TYPE_POPUPS}; -const size_t kValidTypesLength = arraysize(kValidTypes); - -// Enumeration used for UMA Histograms of parsing last_setting_. -// Do not insert, remove, or reorder. Add only to end. -// TODO: Remove histogram by 2015. crbug.com/433475 -enum LastSettingParsed { - UPDATE_EMPTY, - UPDATE_PARSED, - UPDATE_INVALID, - UPDATE_ORIGINS_EMPTY, - UPDATE_ORIGINS_PARSED, - UPDATE_ORIGINS_INVALID, - HANDLE_UPDATE_ORIGINS_EMPTY, - HANDLE_UPDATE_ORIGINS_PARSED, - HANDLE_UPDATE_ORIGINS_INVALID, - LAST_SETTING_MAX_ENUMERATION_VALUE -}; - -void RecordUmaHistogramOfLastSetting(LastSettingParsed parsed) { - UMA_HISTOGRAM_ENUMERATION("ContentSettings.LastSettingParsed", parsed, - LAST_SETTING_MAX_ENUMERATION_VALUE); -} - -} // namespace - -namespace options { - -WebsiteSettingsHandler::WebsiteSettingsHandler() - : observer_(this), - weak_ptr_factory_(this) { -} - -WebsiteSettingsHandler::~WebsiteSettingsHandler() { -} - -void WebsiteSettingsHandler::GetLocalizedValues( - base::DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - static OptionsStringResource resources[] = { - {"websitesOptionsPageTabTitle", IDS_WEBSITE_SETTINGS_TITLE}, - {"websitesSettingsEditPage", IDS_WEBSITE_SETTINGS_EDIT_TITLE}, - {"websitesManage", IDS_WEBSITE_SETTINGS_MANAGE}, - {"websitesSearch", IDS_WEBSITE_SETTINGS_SEARCH_ORIGINS}, - {"websitesLabelLocation", IDS_WEBSITE_SETTINGS_TYPE_LOCATION}, - {"websitesLabelMediaStream", IDS_WEBSITE_SETTINGS_TYPE_MEDIASTREAM}, - {"websitesLabelNotifications", IDS_WEBSITE_SETTINGS_TYPE_NOTIFICATIONS}, - {"websitesLabelOn", IDS_WEBSITE_SETTINGS_CONTENT_SETTING_ENABLED}, - {"websitesLabelStorage", IDS_WEBSITE_SETTINGS_TYPE_STORAGE}, - {"websitesLabelBattery", IDS_WEBSITE_SETTINGS_TYPE_BATTERY}, - {"websitesCookiesDescription", IDS_WEBSITE_SETTINGS_COOKIES_DESCRIPTION}, - {"websitesLocationDescription", - IDS_WEBSITE_SETTINGS_LOCATION_DESCRIPTION}, - {"websitesMediaStreamDescription", - IDS_WEBSITE_SETTINGS_MEDIASTREAM_DESCRIPTION}, - {"websitesNotificationsDescription", - IDS_WEBSITE_SETTINGS_NOTIFICATIONS_DESCRIPTION}, - {"websitesDownloadsDescription", - IDS_WEBSITE_SETTINGS_DOWNLOAD_DESCRIPTION}, - {"websitesPluginsDescription", IDS_WEBSITE_SETTINGS_PLUGINS_DESCRIPTION}, - {"websitesPopupsDescription", IDS_WEBSITE_SETTINGS_POPUPS_DESCRIPTION}, - {"websitesJavascriptDescription", - IDS_WEBSITE_SETTINGS_JAVASCRIPT_DESCRIPTION}, - {"websitesImagesDescription", IDS_WEBSITE_SETTINGS_IMAGES_DESCRIPTION}, - {"websitesButtonClear", IDS_WEBSITE_SETTINGS_STORAGE_CLEAR_BUTTON}, - {"websitesButtonStop", IDS_WEBSITE_SETTINGS_BATTERY_STOP_BUTTON}, - {"websitesAllowedListTitle", IDS_WEBSITE_SETTINGS_ALLOWED_LIST_TITLE}, - {"websitesBlockedListTitle", IDS_WEBSITE_SETTINGS_BLOCKED_LIST_TITLE}, - {"storageTabLabel", IDS_WEBSITE_SETTINGS_TYPE_STORAGE}, - {"batteryTabLabel", IDS_WEBSITE_SETTINGS_TYPE_BATTERY}, - }; - - RegisterStrings(localized_strings, resources, arraysize(resources)); - RegisterTitle( - localized_strings, "websiteSettingsPage", IDS_WEBSITE_SETTINGS_TITLE); -} - -void WebsiteSettingsHandler::InitializeHandler() { - Profile* profile = GetProfile(); - HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); - observer_.Add(settings); - - power::OriginPowerMap* origin_power_map = - power::OriginPowerMapFactory::GetForBrowserContext(profile); - // OriginPowerMap may not be available in tests. - if (origin_power_map) { - subscription_ = origin_power_map->AddPowerConsumptionUpdatedCallback( - base::Bind(&WebsiteSettingsHandler::Update, base::Unretained(this))); - } -} - -void WebsiteSettingsHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "updateOrigins", - base::Bind(&WebsiteSettingsHandler::HandleUpdateOrigins, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "updateOriginsSearchResults", - base::Bind(&WebsiteSettingsHandler::HandleUpdateSearchResults, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "updateLocalStorage", - base::Bind(&WebsiteSettingsHandler::HandleUpdateLocalStorage, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "updateBatteryUsage", - base::Bind(&WebsiteSettingsHandler::HandleUpdateBatteryUsage, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "getOriginInfo", - base::Bind(&WebsiteSettingsHandler::HandleGetOriginInfo, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "setOriginPermission", - base::Bind(&WebsiteSettingsHandler::HandleSetOriginPermission, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "maybeShowEditPage", - base::Bind(&WebsiteSettingsHandler::HandleMaybeShowEditPage, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "deleteLocalStorage", - base::Bind(&WebsiteSettingsHandler::HandleDeleteLocalStorage, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "stopOrigin", - base::Bind(&WebsiteSettingsHandler::HandleStopOrigin, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "updateDefaultSetting", - base::Bind(&WebsiteSettingsHandler::HandleUpdateDefaultSetting, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "setDefaultContentSetting", - base::Bind(&WebsiteSettingsHandler::HandleSetDefaultSetting, - base::Unretained(this))); - - web_ui()->RegisterMessageCallback( - "setGlobalEnabled", - base::Bind(&WebsiteSettingsHandler::HandleSetGlobalToggle, - base::Unretained(this))); -} - -// content_settings::Observer implementation. -void WebsiteSettingsHandler::OnContentSettingChanged( - const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - std::string resource_identifier) { - Update(); -} - -void WebsiteSettingsHandler::OnContentSettingUsed( - const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type) { - Update(); -} - -void WebsiteSettingsHandler::HandleUpdateOrigins(const base::ListValue* args) { - std::string content_setting_name; - bool rv = args->GetString(0, &content_setting_name); - DCHECK(rv); - - ContentSettingsType content_type; - if (!content_settings::GetTypeFromName(content_setting_name, &content_type)) - return; - DCHECK_NE( - kValidTypes + kValidTypesLength, - std::find(kValidTypes, kValidTypes + kValidTypesLength, content_type)); - - last_setting_ = content_setting_name; - - // Histogram to understand the source of parsing errors. crbug.com/432600. - // TODO: Remove histogram by 2015. crbug.com/433475 - ContentSettingsType last_setting; - if (!content_settings::GetTypeFromName(last_setting_, &last_setting)) { - if (last_setting_.empty()) - RecordUmaHistogramOfLastSetting(HANDLE_UPDATE_ORIGINS_EMPTY); - else - RecordUmaHistogramOfLastSetting(HANDLE_UPDATE_ORIGINS_INVALID); - } else { - RecordUmaHistogramOfLastSetting(HANDLE_UPDATE_ORIGINS_PARSED); - } - - UpdateOrigins(); -} - -void WebsiteSettingsHandler::HandleUpdateSearchResults( - const base::ListValue* args) { - bool rv = args->GetString(0, &last_filter_); - DCHECK(rv); - - Update(); -} - -void WebsiteSettingsHandler::HandleUpdateLocalStorage( - const base::ListValue* args) { - if (!local_storage_.get()) { - Profile* profile = GetProfile(); - local_storage_ = new BrowsingDataLocalStorageHelper(profile); - } - - last_setting_ = kStorage; - - local_storage_->StartFetching( - base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, - weak_ptr_factory_.GetWeakPtr())); -} - -void WebsiteSettingsHandler::HandleMaybeShowEditPage( - const base::ListValue* args) { - std::string site; - bool rv = args->GetString(0, &site); - DCHECK(rv); - - GURL last_site(site); - if (!last_site.is_valid()) - return; - - last_site_ = last_site; - base::StringValue site_value(site); - web_ui()->CallJavascriptFunction("WebsiteSettingsEditor.showEditPage", - site_value); -} - -void WebsiteSettingsHandler::OnLocalStorageFetched(const std::list< - BrowsingDataLocalStorageHelper::LocalStorageInfo>& storage) { - local_storage_list_ = storage; - Update(); - GetInfoForOrigin(last_site_, false); -} - -void WebsiteSettingsHandler::Update() { - DCHECK(!last_setting_.empty()); - - // Histogram to understand the source of parsing errors. crbug.com/432600. - // TODO: Remove histogram by 2015. crbug.com/433475 - ContentSettingsType last_setting; - if (!content_settings::GetTypeFromName(last_setting_, &last_setting)) { - if (last_setting_.empty()) - RecordUmaHistogramOfLastSetting(UPDATE_EMPTY); - else - RecordUmaHistogramOfLastSetting(UPDATE_INVALID); - } else { - RecordUmaHistogramOfLastSetting(UPDATE_PARSED); - } - - if (last_setting_ == kStorage) - UpdateLocalStorage(); - else if (last_setting_ == kBattery) - UpdateBatteryUsage(); - else - UpdateOrigins(); -} - -void WebsiteSettingsHandler::UpdateOrigins() { - Profile* profile = GetProfile(); - HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); - - ContentSettingsForOneType all_settings; - ContentSettingsType last_setting; - if (!content_settings::GetTypeFromName(last_setting_, &last_setting)) { - // TODO: Remove histogram by 2015. crbug.com/433475 - if (last_setting_.empty()) - RecordUmaHistogramOfLastSetting(UPDATE_ORIGINS_EMPTY); - else - RecordUmaHistogramOfLastSetting(UPDATE_ORIGINS_INVALID); - - return; - } - RecordUmaHistogramOfLastSetting(UPDATE_ORIGINS_PARSED); - - if (last_setting == CONTENT_SETTINGS_TYPE_MEDIASTREAM) - last_setting = CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; - - settings->GetSettingsForOneType(last_setting, std::string(), &all_settings); - - base::DictionaryValue allowed_origins; - base::DictionaryValue blocked_origins; - for (ContentSettingsForOneType::const_iterator it = all_settings.begin(); - it != all_settings.end(); - ++it) { - // Don't add default settings. - if (it->primary_pattern == ContentSettingsPattern::Wildcard() && - it->secondary_pattern == ContentSettingsPattern::Wildcard() && - it->source != kPreferencesSource) { - continue; - } - - GURL origin_url(it->primary_pattern.ToString()); - std::string origin = origin_url.spec(); - - // Hide the port if it is using a standard URL scheme. - if ((origin_url.SchemeIs(url::kHttpScheme) && - origin_url.IntPort() == kHttpPort) || - (origin_url.SchemeIs(url::kHttpsScheme) && - origin_url.IntPort() == kHttpsPort)) { - url::Replacements<char> replacements; - replacements.ClearPort(); - origin = origin_url.ReplaceComponents(replacements).spec(); - } - - // Mediastream isn't set unless both mic and camera are set to the same. - if (last_setting == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { - ContentSetting cam_setting = settings->GetContentSettingWithoutOverride( - origin_url, - origin_url, - CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, - std::string()); - if (it->setting != cam_setting) - continue; - } - - if (origin.find(last_filter_) == base::string16::npos) - continue; - - base::Time last_usage = settings->GetLastUsageByPattern( - it->primary_pattern, it->secondary_pattern, last_setting); - - scoped_ptr<base::DictionaryValue> origin_entry(new base::DictionaryValue()); - origin_entry->SetDoubleWithoutPathExpansion("usage", - last_usage.ToDoubleT()); - base::string16 usage_string; - if (last_usage.ToDoubleT()) { - usage_string = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, - ui::TimeFormat::LENGTH_SHORT, - base::Time::Now() - last_usage); - } - origin_entry->SetStringWithoutPathExpansion("usageString", usage_string); - origin_entry->SetStringWithoutPathExpansion("readableName", - GetReadableName(origin_url)); - - if (it->setting == CONTENT_SETTING_BLOCK) - blocked_origins.SetWithoutPathExpansion(origin, origin_entry.Pass()); - else - allowed_origins.SetWithoutPathExpansion(origin, origin_entry.Pass()); - } - - bool is_globally_allowed = settings->GetContentSettingOverride(last_setting); - web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins", - allowed_origins, - blocked_origins, - base::FundamentalValue(is_globally_allowed)); -} - -void WebsiteSettingsHandler::HandleGetOriginInfo(const base::ListValue* args) { - std::string url; - bool rv = args->GetString(0, &url); - DCHECK(rv); - GURL origin(url); - - if (!origin.is_valid()) - return; - - GetInfoForOrigin(origin, true); -} - -void WebsiteSettingsHandler::HandleSetOriginPermission( - const base::ListValue* args) { - std::string setting_name; - bool rv = args->GetString(0, &setting_name); - DCHECK(rv); - ContentSettingsType settings_type; - if (!content_settings::GetTypeFromName(setting_name, &settings_type)) - return; - - std::string value; - rv = args->GetString(1, &value); - DCHECK(rv); - - ContentSetting setting = content_settings::ContentSettingFromString(value); - Profile* profile = GetProfile(); - HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); - ContentSetting default_value = - map->GetDefaultContentSetting(settings_type, NULL); - - // Users are not allowed to be the source of the "ask" setting. It is an - // ephemeral setting which is removed once the question is asked. - if (setting == CONTENT_SETTING_ASK && setting == default_value) - setting = CONTENT_SETTING_DEFAULT; - - ContentSettingsPattern primary_pattern; - ContentSettingsPattern secondary_pattern; - switch (settings_type) { - case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: - primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); - secondary_pattern = ContentSettingsPattern::Wildcard(); - break; - case CONTENT_SETTINGS_TYPE_MEDIASTREAM: - primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); - secondary_pattern = ContentSettingsPattern::Wildcard(); - map->SetContentSetting(primary_pattern, - secondary_pattern, - CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, - std::string(), - setting); - map->SetContentSetting(primary_pattern, - secondary_pattern, - CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, - std::string(), - setting); - return; - case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS: - case CONTENT_SETTINGS_TYPE_COOKIES: - case CONTENT_SETTINGS_TYPE_GEOLOCATION: - case CONTENT_SETTINGS_TYPE_IMAGES: - case CONTENT_SETTINGS_TYPE_JAVASCRIPT: - case CONTENT_SETTINGS_TYPE_PLUGINS: - case CONTENT_SETTINGS_TYPE_POPUPS: - primary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); - secondary_pattern = ContentSettingsPattern::FromURLNoWildcard(last_site_); - break; - default: - NOTREACHED() << "Content settings type not yet supported."; - return; - } - - content_settings::SettingInfo info; - scoped_ptr<base::Value> v(map->GetWebsiteSettingWithoutOverride( - last_site_, last_site_, settings_type, std::string(), &info)); - map->SetNarrowestWebsiteSetting(primary_pattern, - secondary_pattern, - settings_type, - std::string(), - setting, - info); -} - -void WebsiteSettingsHandler::HandleUpdateBatteryUsage( - const base::ListValue* args) { - last_setting_ = kBattery; - UpdateBatteryUsage(); -} - -void WebsiteSettingsHandler::HandleDeleteLocalStorage( - const base::ListValue* args) { - DCHECK(!last_site_.is_empty()); - DeleteLocalStorage(last_site_); -} - -void WebsiteSettingsHandler::HandleStopOrigin(const base::ListValue* args) { - DCHECK(!last_site_.is_empty()); - StopOrigin(last_site_); -} - -void WebsiteSettingsHandler::HandleUpdateDefaultSetting( - const base::ListValue* args) { - ContentSettingsType type; - if (!content_settings::GetTypeFromName(last_setting_, &type)) - return; - - Profile* profile = GetProfile(); - std::string provider_id; - ContentSetting default_setting = - profile->GetHostContentSettingsMap()->GetDefaultContentSetting( - type, &provider_id); - - base::DictionaryValue filter_settings; - filter_settings.SetString( - "value", content_settings::ContentSettingToString(default_setting)); - filter_settings.SetString("managedBy", provider_id); - - web_ui()->CallJavascriptFunction("WebsiteSettingsManager.updateDefault", - filter_settings); -} - -void WebsiteSettingsHandler::HandleSetDefaultSetting( - const base::ListValue* args) { - DCHECK_EQ(1U, args->GetSize()); - std::string setting; - if (!args->GetString(0, &setting)) { - NOTREACHED(); - return; - } - ContentSetting new_default = - content_settings::ContentSettingFromString(setting); - - ContentSettingsType last_setting; - if (!content_settings::GetTypeFromName(last_setting_, &last_setting)) - return; - Profile* profile = GetProfile(); - - HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); - map->SetDefaultContentSetting(last_setting, new_default); - - switch (last_setting) { - case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS: - content::RecordAction( - UserMetricsAction("Options_DefaultMultipleAutomaticDLSettingChange")); - break; - case CONTENT_SETTINGS_TYPE_COOKIES: - content::RecordAction( - UserMetricsAction("Options_DefaultCookieSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_GEOLOCATION: - content::RecordAction( - UserMetricsAction("Options_DefaultGeolocationSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_IMAGES: - content::RecordAction( - UserMetricsAction("Options_DefaultImagesSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_JAVASCRIPT: - content::RecordAction( - UserMetricsAction("Options_DefaultJavaScriptSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_MEDIASTREAM: - content::RecordAction( - UserMetricsAction("Options_DefaultMediaStreamMicSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: - content::RecordAction( - UserMetricsAction("Options_DefaultNotificationsSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_PLUGINS: - content::RecordAction( - UserMetricsAction("Options_DefaultPluginsSettingChanged")); - break; - case CONTENT_SETTINGS_TYPE_POPUPS: - content::RecordAction( - UserMetricsAction("Options_DefaultPopupsSettingChanged")); - break; - default: - NOTREACHED(); - return; - } -} - -void WebsiteSettingsHandler::HandleSetGlobalToggle( - const base::ListValue* args) { - DCHECK_EQ(1U, args->GetSize()); - bool is_enabled; - bool rv = args->GetBoolean(0, &is_enabled); - DCHECK(rv); - - ContentSettingsType last_setting; - if (!content_settings::GetTypeFromName(last_setting_, &last_setting)) - return; - - Profile* profile = GetProfile(); - HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); - map->SetContentSettingOverride(last_setting, is_enabled); -} - -void WebsiteSettingsHandler::GetInfoForOrigin(const GURL& site_url, - bool show_page) { - Profile* profile = GetProfile(); - HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); - - double storage = 0.0; - for (LocalStorageList::const_iterator it = local_storage_list_.begin(); - it != local_storage_list_.end(); - it++) { - if (it->origin_url == site_url) { - storage = static_cast<double>(it->size); - break; - } - } - - int battery = 0; - battery = OriginPowerMapFactory::GetForBrowserContext( - GetProfile())->GetPowerForOrigin(site_url); - - base::DictionaryValue* permissions = new base::DictionaryValue; - for (size_t i = 0; i < arraysize(kValidTypes); ++i) { - ContentSettingsType permission_type = kValidTypes[i]; - - // Append the possible settings. - scoped_ptr<base::ListValue> options(new base::ListValue()); - ContentSetting default_value = - map->GetDefaultContentSetting(permission_type, NULL); - if (default_value != CONTENT_SETTING_ALLOW && - default_value != CONTENT_SETTING_BLOCK) { - options->AppendString( - content_settings::ContentSettingToString(default_value)); - } - options->AppendString( - content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW)); - options->AppendString( - content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK)); - if (permission_type == CONTENT_SETTINGS_TYPE_COOKIES) { - options->AppendString(content_settings::ContentSettingToString( - CONTENT_SETTING_SESSION_ONLY)); - } - - ContentSetting permission; - content_settings::SettingInfo info; - if (permission_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { - scoped_ptr<base::Value> mic_value(map->GetWebsiteSettingWithoutOverride( - site_url, - site_url, - CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, - std::string(), - &info)); - ContentSetting mic_setting = - content_settings::ValueToContentSetting(mic_value.get()); - ContentSetting cam_setting = map->GetContentSettingWithoutOverride( - site_url, - site_url, - CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, - std::string()); - - if (mic_setting != cam_setting) - permission = CONTENT_SETTING_ASK; - else - permission = mic_setting; - } else { - scoped_ptr<base::Value> v(map->GetWebsiteSettingWithoutOverride( - site_url, site_url, permission_type, std::string(), &info)); - permission = content_settings::ValueToContentSetting(v.get()); - } - - scoped_ptr<base::DictionaryValue> - permission_info(new base::DictionaryValue()); - permission_info->SetStringWithoutPathExpansion( - "setting", content_settings::ContentSettingToString(permission)); - permission_info->SetWithoutPathExpansion("options", options.Pass()); - permission_info->SetBooleanWithoutPathExpansion( - "editable", info.source == content_settings::SETTING_SOURCE_USER); - permissions->SetWithoutPathExpansion( - content_settings::GetTypeName(permission_type), permission_info.Pass()); - } - - base::Value* storage_used = new base::StringValue(l10n_util::GetStringFUTF16( - IDS_WEBSITE_SETTINGS_STORAGE_USED, ui::FormatBytes(storage))); - base::Value* battery_used = - new base::StringValue(l10n_util::GetStringFUTF16Int( - IDS_WEBSITE_SETTINGS_BATTERY_USED, battery)); - - web_ui()->CallJavascriptFunction("WebsiteSettingsEditor.populateOrigin", - *storage_used, - *battery_used, - *permissions, - base::FundamentalValue(show_page)); -} - -void WebsiteSettingsHandler::UpdateLocalStorage() { - base::DictionaryValue local_storage_map; - for (LocalStorageList::const_iterator it = local_storage_list_.begin(); - it != local_storage_list_.end(); - it++) { - std::string origin = it->origin_url.spec(); - - if (origin.find(last_filter_) == base::string16::npos) - continue; - - scoped_ptr<base::DictionaryValue> origin_entry(new base::DictionaryValue()); - origin_entry->SetDoubleWithoutPathExpansion( - "usage", static_cast<double>(it->size)); - origin_entry->SetStringWithoutPathExpansion( - "usageString", ui::FormatBytes(it->size)); - origin_entry->SetStringWithoutPathExpansion( - "readableName", GetReadableName(it->origin_url)); - local_storage_map.SetWithoutPathExpansion(origin, origin_entry.Pass()); - } - web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins", - local_storage_map); -} - -void WebsiteSettingsHandler::UpdateBatteryUsage() { - base::DictionaryValue power_map; - OriginPowerMap* origins = - OriginPowerMapFactory::GetForBrowserContext(GetProfile()); - OriginPowerMap::PercentOriginMap percent_map = origins->GetPercentOriginMap(); - for (std::map<GURL, int>::iterator it = percent_map.begin(); - it != percent_map.end(); - ++it) { - std::string origin = it->first.spec(); - - if (origin.find(last_filter_) == base::string16::npos) - continue; - - scoped_ptr<base::DictionaryValue> origin_entry(new base::DictionaryValue()); - origin_entry->SetInteger("usage", it->second); - if (it->second == 0) { - origin_entry->SetString( - "usageString", - l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_BATTERY_ZERO_PERCENT)); - } else { - origin_entry->SetString( - "usageString", - l10n_util::GetStringFUTF16Int(IDS_WEBSITE_SETTINGS_BATTERY_PERCENT, - it->second)); - } - origin_entry->SetStringWithoutPathExpansion("readableName", - GetReadableName(it->first)); - power_map.SetWithoutPathExpansion(origin, origin_entry.Pass()); - } - web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins", - power_map); -} - -void WebsiteSettingsHandler::StopOrigin(const GURL& site_url) { - Profile* profile = GetProfile(); - if (site_url.SchemeIs(extensions::kExtensionScheme)) { - const extensions::Extension* extension = - extensions::ExtensionRegistry::Get(profile) - ->enabled_extensions() - .GetHostedAppByURL(site_url); - if (extension) { - extensions::AppWindowRegistry::Get(profile) - ->CloseAllAppWindowsForApp(extension->id()); - } - } - - for (chrome::BrowserIterator it; !it.done(); it.Next()) { - Browser* browser = *it; - TabStripModel* model = browser->tab_strip_model(); - for (int idx = 0; idx < model->count(); idx++) { - content::WebContents* web_contents = model->GetWebContentsAt(idx); - // Can't discard tabs that are already discarded or active. - if (model->IsTabDiscarded(idx) || (model->active_index() == idx)) - continue; - - // Don't discard tabs that belong to other profiles or other origins. - if (web_contents->GetLastCommittedURL().GetOrigin() != site_url || - profile != - Profile::FromBrowserContext(web_contents->GetBrowserContext())) { - continue; - } - model->DiscardWebContentsAt(idx); - } - } -} - -void WebsiteSettingsHandler::DeleteLocalStorage(const GURL& site_url) { - Profile* profile = GetProfile(); - content::DOMStorageContext* dom_storage_context_ = - content::BrowserContext::GetDefaultStoragePartition(profile) - ->GetDOMStorageContext(); - dom_storage_context_->DeleteLocalStorage(site_url); - - // Load a new BrowsingDataLocalStorageHelper to update. - local_storage_ = new BrowsingDataLocalStorageHelper(profile); - - local_storage_->StartFetching( - base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, - weak_ptr_factory_.GetWeakPtr())); -} - -const std::string& WebsiteSettingsHandler::GetReadableName( - const GURL& site_url) { - if (site_url.SchemeIs(extensions::kExtensionScheme)) { - const extensions::ExtensionRegistry* registry = - extensions::ExtensionRegistry::Get(GetProfile()); - const extensions::Extension* extension = - registry->enabled_extensions().GetByID(site_url.host()); - // If extension is NULL, it was removed and we cannot look up its name. - if (!extension) - return site_url.spec(); - - return extension->name(); - } - return site_url.spec(); -} - -Profile* WebsiteSettingsHandler::GetProfile() { - Profile* profile = Profile::FromWebUI(web_ui()); -#if defined(OS_CHROMEOS) - // Chrome OS special case: in Guest mode settings are opened in Incognito - // mode, so we need original profile to actually modify settings. - if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) - profile = profile->GetOriginalProfile(); -#endif - return profile; -} - -} // namespace options diff --git a/chrome/browser/ui/webui/options/website_settings_handler.h b/chrome/browser/ui/webui/options/website_settings_handler.h deleted file mode 100644 index 2898a56..0000000 --- a/chrome/browser/ui/webui/options/website_settings_handler.h +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/macros.h" -#include "base/scoped_observer.h" -#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" -#include "chrome/browser/ui/webui/options/options_ui.h" -#include "components/content_settings/core/browser/content_settings_observer.h" -#include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/power/origin_power_map.h" - -namespace options { - -class WebsiteSettingsHandler : public content_settings::Observer, - public OptionsPageUIHandler { - public: - WebsiteSettingsHandler(); - ~WebsiteSettingsHandler() override; - - typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> - LocalStorageList; - - // OptionsPageUIHandler implementation. - void GetLocalizedValues(base::DictionaryValue* localized_strings) override; - void InitializeHandler() override; - void RegisterMessages() override; - - // content_settings::Observer implementation. - void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type, - std::string resource_identifier) override; - void OnContentSettingUsed(const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern, - ContentSettingsType content_type) override; - - private: - // Update the page with all origins for a given content setting. - // |args| is the string name of the content setting. - void HandleUpdateOrigins(const base::ListValue* args); - - // Update the page with all origins given a filter string. - // |args| is the filter string. - void HandleUpdateSearchResults(const base::ListValue* args); - - // Update the single site edit view with the permission values for a given - // url, if the url is valid. - // |args| is the URL. - void HandleGetOriginInfo(const base::ListValue* args); - - // Sets the content setting permissions for a given setting type for the last - // used origin. - // |args| is the name of the setting and the new value. - void HandleSetOriginPermission(const base::ListValue* args); - - // Update the page with all origins that are using local storage. - void HandleUpdateLocalStorage(const base::ListValue* args); - - // Show the single site edit view if the given URL is valid. - // |args| is the URL. - void HandleMaybeShowEditPage(const base::ListValue* args); - - // Get all origins that have used power, filter them by |last_filter_|, and - // update the page. - void HandleUpdateBatteryUsage(const base::ListValue* args); - - // Deletes the local storage and repopulates the page. - void HandleDeleteLocalStorage(const base::ListValue* args); - - // Populates the default setting drop down on the single site edit page. - void HandleUpdateDefaultSetting(const base::ListValue* args); - - // Sets the default setting for the last used content setting to |args|. - void HandleSetDefaultSetting(const base::ListValue* args); - - // Sets if a certain content setting enabled to |args|. - void HandleSetGlobalToggle(const base::ListValue* args); - - // Closes all tabs and app windows which have the same origin as the selected - // page. - void HandleStopOrigin(const base::ListValue* args); - - // Callback method to be invoked when fetching the data is complete. - void OnLocalStorageFetched(const LocalStorageList& storage); - - // Get all origins with Content Settings for the last given content setting, - // filter them by |last_filter_|, and update the page. - void UpdateOrigins(); - - // Get all origins with local storage usage, filter them by |last_filter_|, - // and update the page. - void UpdateLocalStorage(); - - // Get all origins with power consumption, filter them by |last_filter_|, - // and update the page. - void UpdateBatteryUsage(); - - // Kill all tabs and app windows which have the same origin as |site_url|. - void StopOrigin(const GURL& site_url); - - // Delete all of the local storage for the |site_url|. - void DeleteLocalStorage(const GURL& site_url); - - // Populates the single site edit view with the permissions and local storage - // usage for a given |site_url|. If |show_page| is true, it raises a new - // single site edit view. - void GetInfoForOrigin(const GURL& site_url, bool show_page); - - // Updates the page with the last settings used. - void Update(); - - // Returns the base URL for websites, or the app name for Chrome App URLs. - const std::string& GetReadableName(const GURL& site_url); - - Profile* GetProfile(); - - std::string last_setting_; - std::string last_filter_; - GURL last_site_; - scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_; - LocalStorageList local_storage_list_; - - // Observer to watch for content settings changes. - ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_; - - // Subscription to watch for power consumption updates. - scoped_ptr<power::OriginPowerMap::Subscription> subscription_; - - base::WeakPtrFactory<WebsiteSettingsHandler> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsHandler); -}; - -} // namespace options - -#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_WEBSITE_SETTINGS_HANDLER_H_ diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index f2508a4..3ae10b3 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -1898,8 +1898,6 @@ 'browser/ui/webui/options/supervised_user_learn_more_handler.h', 'browser/ui/webui/options/sync_setup_handler.cc', 'browser/ui/webui/options/sync_setup_handler.h', - 'browser/ui/webui/options/website_settings_handler.cc', - 'browser/ui/webui/options/website_settings_handler.h', 'browser/ui/webui/plugins_ui.cc', 'browser/ui/webui/plugins_ui.h', 'browser/ui/webui/profile_info_watcher.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 94ecb41..443eb8c 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -884,7 +884,6 @@ 'browser/ui/webui/options/settings_app_browsertest.js', 'browser/ui/webui/options/settings_format_browsertest.js', 'browser/ui/webui/options/startup_page_list_browsertest.js', - 'browser/ui/webui/options/website_settings_browsertest.js', 'browser/ui/webui/sync_internals_browsertest.js', 'browser/ui/webui/sync_setup_browsertest.js', 'test/data/chromeos/oobe_webui_browsertest.js', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 3bde90e..9883e20 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -559,9 +559,6 @@ const char kEnableUserAlternateProtocolPorts[] = // apps). extern const char kEnableWebAppFrame[] = "enable-web-app-frame"; -// Enables the Website Settings page on the Settings page. -const char kEnableWebsiteSettingsManager[] = "enable-website-settings-manager"; - // Enables synchronizing WiFi credentials across devices, using Chrome Sync. const char kEnableWifiCredentialSync[] = "enable-wifi-credential-sync"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 00051be..8730188 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -162,7 +162,6 @@ extern const char kEnableTabAudioMuting[]; extern const char kEnableThumbnailRetargeting[]; extern const char kEnableUserAlternateProtocolPorts[]; extern const char kEnableWebAppFrame[]; -extern const char kEnableWebsiteSettingsManager[]; extern const char kEnableWifiCredentialSync[]; extern const char kEnhancedBookmarksExperiment[]; extern const char kExtensionContentVerificationBootstrap[]; diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc index 2c774fb..a51f917 100644 --- a/components/content_settings/core/browser/content_settings_utils.cc +++ b/components/content_settings/core/browser/content_settings_utils.cc @@ -62,17 +62,6 @@ std::string GetTypeName(ContentSettingsType type) { return std::string(kTypeNames[type]); } -bool GetTypeFromName(const std::string& name, - ContentSettingsType* return_setting) { - for (size_t type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) { - if (name.compare(kTypeNames[type]) == 0) { - *return_setting = static_cast<ContentSettingsType>(type); - return true; - } - } - return false; -} - std::string ContentSettingToString(ContentSetting setting) { switch (setting) { case CONTENT_SETTING_ALLOW: diff --git a/components/content_settings/core/browser/content_settings_utils.h b/components/content_settings/core/browser/content_settings_utils.h index 26efe6b..bba1de5 100644 --- a/components/content_settings/core/browser/content_settings_utils.h +++ b/components/content_settings/core/browser/content_settings_utils.h @@ -30,9 +30,6 @@ typedef std::pair<ContentSettingsPattern, ContentSettingsPattern> PatternPair; std::string GetTypeName(ContentSettingsType type); -bool GetTypeFromName(const std::string& name, - ContentSettingsType* return_setting) WARN_UNUSED_RESULT; - std::string ContentSettingToString(ContentSetting setting); ContentSetting ContentSettingFromString(const std::string& name); |