summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-16 20:40:14 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-16 20:40:14 +0000
commitf283d011db33e511152a2fd37fb882cf25751722 (patch)
tree1f91dd294c7bed8b872c2009d918ff681bfb2d50 /chrome
parent0bef215e2002757a7bca8d3ca7848204af230f9e (diff)
downloadchromium_src-f283d011db33e511152a2fd37fb882cf25751722.zip
chromium_src-f283d011db33e511152a2fd37fb882cf25751722.tar.gz
chromium_src-f283d011db33e511152a2fd37fb882cf25751722.tar.bz2
Content settings: support --enable-cookie-prompt flag
add Ask setting (default and exception) behind this flag. BUG=51375 TEST=manual Review URL: http://codereview.chromium.org/3137005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/dom_ui/content_settings_handler.cc16
-rw-r--r--chrome/browser/resources/options/content_settings.html6
-rw-r--r--chrome/browser/resources/options/content_settings.js12
-rw-r--r--chrome/browser/resources/options/content_settings_exceptions_area.js41
4 files changed, 65 insertions, 10 deletions
diff --git a/chrome/browser/dom_ui/content_settings_handler.cc b/chrome/browser/dom_ui/content_settings_handler.cc
index d42bac6..01c8c55 100644
--- a/chrome/browser/dom_ui/content_settings_handler.cc
+++ b/chrome/browser/dom_ui/content_settings_handler.cc
@@ -6,10 +6,12 @@
#include "app/l10n_util.h"
#include "base/callback.h"
+#include "base/command_line.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/profile.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
@@ -117,6 +119,8 @@ void ContentSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON));
localized_strings->SetString("sessionException",
l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON));
+ localized_strings->SetString("askException",
+ l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON));
localized_strings->SetString("addExceptionRow",
l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ADD_BUTTON));
localized_strings->SetString("removeExceptionRow",
@@ -131,6 +135,8 @@ void ContentSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_MODIFY_COOKIE_STORING_LABEL));
localized_strings->SetString("cookies_allow",
l10n_util::GetStringUTF16(IDS_COOKIES_ALLOW_RADIO));
+ localized_strings->SetString("cookies_ask",
+ l10n_util::GetStringUTF16(IDS_COOKIES_ASK_EVERY_TIME_RADIO));
localized_strings->SetString("cookies_block",
l10n_util::GetStringUTF16(IDS_COOKIES_BLOCK_RADIO));
localized_strings->SetString("cookies_block_3rd_party",
@@ -232,10 +238,16 @@ void ContentSettingsHandler::Initialize() {
dom_ui_->CallJavascriptFunction(
L"ContentSettings.setInitialContentFilterSettingsValue", filter_settings);
- scoped_ptr<Value> bool_value(Value::CreateBooleanValue(
+ scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue(
settings_map->BlockThirdPartyCookies()));
dom_ui_->CallJavascriptFunction(
- L"ContentSettings.setBlockThirdPartyCookies", *bool_value.get());
+ L"ContentSettings.setBlockThirdPartyCookies", *block_3rd_party.get());
+
+ scoped_ptr<Value> show_cookies_prompt(Value::CreateBooleanValue(
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableCookiePrompt)));
+ dom_ui_->CallJavascriptFunction(
+ L"ContentSettings.setCookiesPromptEnabled", *show_cookies_prompt.get());
UpdateAllExceptionsViewsFromModel();
notification_registrar_.Add(
diff --git a/chrome/browser/resources/options/content_settings.html b/chrome/browser/resources/options/content_settings.html
index 777262f2..8fdebb7 100644
--- a/chrome/browser/resources/options/content_settings.html
+++ b/chrome/browser/resources/options/content_settings.html
@@ -35,6 +35,12 @@
</label></td>
</tr>
<tr>
+ <td class="option-name" id='cookiesAskRadio'><label>
+ <input type="radio" name="cookies" value="ask">
+ <span i18n-content="cookies_ask"></span>
+ </label></td>
+ </tr>
+ <tr>
<td class="option-name"><label>
<input type="radio" name="cookies" value="block">
<span i18n-content="cookies_block"></span>
diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js
index f6a6873..5756ce9 100644
--- a/chrome/browser/resources/options/content_settings.js
+++ b/chrome/browser/resources/options/content_settings.js
@@ -73,6 +73,18 @@ cr.define('options', function() {
};
/**
+ * Called to set whether we show certain UI related to the cookies prompt.
+ * @param {boolean} enabled The value --enable-cookies-prompt.
+ * that group.
+ */
+ ContentSettings.setCookiesPromptEnabled = function(enabled) {
+ cookiesExceptionsList.enableAskOption = enabled;
+
+ if (!enabled)
+ $('cookiesAskRadio').classList.add('hidden');
+ }
+
+ /**
* Initializes an exceptions list.
* @param {string} type The content type that we are setting exceptions for.
* @param {Array} list An array of pairs, where the first element of each pair
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.js b/chrome/browser/resources/options/content_settings_exceptions_area.js
index a51a0ca..b280e4b 100644
--- a/chrome/browser/resources/options/content_settings_exceptions_area.js
+++ b/chrome/browser/resources/options/content_settings_exceptions_area.js
@@ -10,13 +10,16 @@ cr.define('options.contentSettings', function() {
/**
* Creates a new exceptions list item.
* @param {string} contentType The type of the list.
+ * @param {boolean} enableAskOption Whether to show an 'ask every time'
+ * option in the select.
* @param {Array} exception A pair of the form [filter, setting].
* @constructor
* @extends {cr.ui.ListItem}
*/
- function ExceptionsListItem(contentType, exception) {
+ function ExceptionsListItem(contentType, enableAskOption, exception) {
var el = cr.doc.createElement('li');
el.contentType = contentType;
+ el.enableAskOption = enableAskOption;
el.dataItem = exception;
el.__proto__ = ExceptionsListItem.prototype;
el.decorate();
@@ -53,9 +56,13 @@ cr.define('options.contentSettings', function() {
var optionAllow = cr.doc.createElement('option');
optionAllow.textContent = templateData.allowException;
select.appendChild(optionAllow);
- var optionBlock = cr.doc.createElement('option');
- optionBlock.textContent = templateData.blockException;
- select.appendChild(optionBlock);
+
+ if (this.enableAskOption) {
+ var optionAsk = cr.doc.createElement('option');
+ optionAsk.textContent = templateData.askException;
+ select.appendChild(optionAsk);
+ this.optionAsk = optionAsk;
+ }
if (this.contentType == 'cookies') {
var optionSession = cr.doc.createElement('option');
@@ -64,6 +71,10 @@ cr.define('options.contentSettings', function() {
this.optionSession = optionSession;
}
+ var optionBlock = cr.doc.createElement('option');
+ optionBlock.textContent = templateData.blockException;
+ select.appendChild(optionBlock);
+
this.appendChild(select);
select.className = 'exceptionSetting hidden';
@@ -171,6 +182,10 @@ cr.define('options.contentSettings', function() {
return templateData.allowException;
else if (setting == 'block')
return templateData.blockException;
+ else if (setting == 'ask')
+ return templateData.askException;
+ else if (setting == 'session')
+ return templateData.sessionException;
},
/**
@@ -208,8 +223,10 @@ cr.define('options.contentSettings', function() {
this.optionAllow.selected = true;
else if (this.setting == 'block')
this.optionBlock.selected = true;
- else if (this.setting == 'session')
+ else if (this.setting == 'session' && this.optionSession)
this.optionSession.selected = true;
+ else if (this.setting == 'ask' && this.optionAsk)
+ this.optionAsk.selected = true;
},
/**
@@ -234,6 +251,7 @@ cr.define('options.contentSettings', function() {
var optionAllow = this.optionAllow;
var optionBlock = this.optionBlock;
var optionSession = this.optionSession;
+ var optionAsk = this.optionAsk;
// Check that we have a valid pattern and if not we do not change the
// editing mode.
@@ -271,8 +289,10 @@ cr.define('options.contentSettings', function() {
newSetting = 'allow';
else if (optionBlock.selected)
newSetting = 'block';
- else if (optionSession.selected)
+ else if (optionSession && optionSession.selected)
newSetting = 'session';
+ else if (optionAsk && optionAsk.selected)
+ newSetting = 'ask';
// Empty edit - do nothing.
if (pattern == newPattern && newSetting == this.setting)
@@ -282,7 +302,7 @@ cr.define('options.contentSettings', function() {
this.setting = newSetting;
settingLabel.textContent = this.settingForDisplay();
- var contentType = this.parentNode.contentType;
+ var contentType = this.contentType;
if (pattern != this.pattern)
chrome.send('removeExceptions', [contentType, pattern]);
@@ -309,6 +329,9 @@ cr.define('options.contentSettings', function() {
List.prototype.decorate.call(this);
this.dataModel = new ArrayDataModel([]);
+
+ // Whether the exceptions in this list allow an 'Ask every time' option.
+ this.enableAskOption = false;
},
/**
@@ -316,7 +339,9 @@ cr.define('options.contentSettings', function() {
* @param {Object} entry The element from the data model for this row.
*/
createItem: function(entry) {
- return new ExceptionsListItem(this.contentType, entry);
+ return new ExceptionsListItem(this.contentType,
+ this.enableAskOption,
+ entry);
},
/**