summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/nibs/CookiePrompt.xib12
-rw-r--r--chrome/browser/cocoa/content_blocked_bubble_controller.mm3
-rw-r--r--chrome/browser/cocoa/content_blocked_bubble_controller_unittest.mm1
-rw-r--r--chrome/browser/cocoa/cookie_prompt_window_controller.h1
-rw-r--r--chrome/browser/cocoa/cookie_prompt_window_controller.mm4
-rw-r--r--chrome/browser/content_setting_bubble_model.cc2
-rw-r--r--chrome/browser/content_setting_bubble_model.h1
-rw-r--r--chrome/browser/cookie_modal_dialog.cc10
-rw-r--r--chrome/browser/cookie_modal_dialog.h3
-rw-r--r--chrome/browser/cookie_modal_dialog_gtk.cc5
-rw-r--r--chrome/browser/gtk/content_setting_bubble_gtk.cc1
-rw-r--r--chrome/browser/host_content_settings_map.cc145
-rw-r--r--chrome/browser/host_content_settings_map.h16
-rw-r--r--chrome/browser/host_content_settings_map_unittest.cc91
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/views/content_blocked_bubble_contents.cc1
-rw-r--r--chrome/browser/views/cookie_prompt_view.cc11
17 files changed, 201 insertions, 110 deletions
diff --git a/chrome/app/nibs/CookiePrompt.xib b/chrome/app/nibs/CookiePrompt.xib
index afb028f..233d8f2 100644
--- a/chrome/app/nibs/CookiePrompt.xib
+++ b/chrome/app/nibs/CookiePrompt.xib
@@ -562,14 +562,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">160</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">askChoiceCell_</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="969084885"/>
- </object>
- <int key="connectionID">161</int>
- </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -857,7 +849,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">161</int>
+ <int key="maxID">160</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -892,7 +884,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>askChoiceCell_</string>
<string>description_</string>
<string>disclosedViewPlaceholder_</string>
<string>disclosureButtonSuperView_</string>
@@ -902,7 +893,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>NSButtonCell</string>
<string>NSTextField</string>
<string>NSView</string>
<string>NSView</string>
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
index 9fa9d0e..e18370f 100644
--- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm
+++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm
@@ -178,10 +178,9 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
const ContentSettingBubbleModel::RadioGroup& radioGroup =
contentSettingBubbleModel_->bubble_content().radio_group;
- // Initialize radio group state.
+ // Select appropriate radio button.
[allowBlockRadioGroup_ selectCellWithTag:
radioGroup.default_item == 0 ? kAllowTag : kBlockTag];
- [allowBlockRadioGroup_ setEnabled:radioGroup.is_mutable];
// Copy |host_| into radio group label.
NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag:kAllowTag];
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller_unittest.mm b/chrome/browser/cocoa/content_blocked_bubble_controller_unittest.mm
index 57f91ff..a7b940e 100644
--- a/chrome/browser/cocoa/content_blocked_bubble_controller_unittest.mm
+++ b/chrome/browser/cocoa/content_blocked_bubble_controller_unittest.mm
@@ -21,7 +21,6 @@ class DummyContentSettingBubbleModel : public ContentSettingBubbleModel {
RadioGroup radio_group;
radio_group.default_item = 0;
radio_group.radio_items.resize(2);
- radio_group.is_mutable = true;
set_radio_group(radio_group);
}
};
diff --git a/chrome/browser/cocoa/cookie_prompt_window_controller.h b/chrome/browser/cocoa/cookie_prompt_window_controller.h
index 3f440db..6ae68b4 100644
--- a/chrome/browser/cocoa/cookie_prompt_window_controller.h
+++ b/chrome/browser/cocoa/cookie_prompt_window_controller.h
@@ -39,7 +39,6 @@ class CookieTreeNode;
IBOutlet NSView* disclosureButtonSuperView_;
IBOutlet NSMatrix* radioGroupMatrix_;
IBOutlet NSButtonCell* rememberChoiceCell_;
- IBOutlet NSButtonCell* askChoiceCell_;
}
// Designated initializer.
diff --git a/chrome/browser/cocoa/cookie_prompt_window_controller.mm b/chrome/browser/cocoa/cookie_prompt_window_controller.mm
index 1d53508b..84aa661 100644
--- a/chrome/browser/cocoa/cookie_prompt_window_controller.mm
+++ b/chrome/browser/cocoa/cookie_prompt_window_controller.mm
@@ -137,10 +137,6 @@ static const CGFloat kExtraMarginForDetailsView = 10;
[self doLayoutTweaks];
[self replaceCookieDetailsView];
- bool rememberEnabled = dialog_->DecisionPersistable();
- [radioGroupMatrix_ setEnabled:rememberEnabled];
- [radioGroupMatrix_ selectCell:(
- rememberEnabled ? rememberChoiceCell_ : askChoiceCell_)];
[[detailsViewController_ view] setHidden:YES];
}
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc
index 03dbe06..260e126 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/content_setting_bubble_model.cc
@@ -115,8 +115,6 @@ class ContentSettingSingleRadioGroup : public ContentSettingTitleAndLinkModel {
radio_group.default_item =
profile()->GetHostContentSettingsMap()->GetContentSetting(url,
content_type()) == CONTENT_SETTING_ALLOW ? 0 : 1;
- radio_group.is_mutable =
- !profile()->GetHostContentSettingsMap()->IsOffTheRecord();
set_radio_group(radio_group);
}
diff --git a/chrome/browser/content_setting_bubble_model.h b/chrome/browser/content_setting_bubble_model.h
index e760340..18cf6ac 100644
--- a/chrome/browser/content_setting_bubble_model.h
+++ b/chrome/browser/content_setting_bubble_model.h
@@ -45,7 +45,6 @@ class ContentSettingBubbleModel : public NotificationObserver {
std::string title;
RadioItems radio_items;
int default_item;
- bool is_mutable;
};
struct DomainList {
diff --git a/chrome/browser/cookie_modal_dialog.cc b/chrome/browser/cookie_modal_dialog.cc
index ed86178..575ace5 100644
--- a/chrome/browser/cookie_modal_dialog.cc
+++ b/chrome/browser/cookie_modal_dialog.cc
@@ -99,8 +99,7 @@ bool CookiePromptModalDialog::IsValid() {
void CookiePromptModalDialog::AllowSiteData(bool remember,
bool session_expire) {
- DCHECK(!remember || DecisionPersistable());
- if (remember && DecisionPersistable()) {
+ if (remember) {
// Make sure there is no entry that would override the pattern we are about
// to insert for exactly this URL.
host_content_settings_map_->SetContentSetting(
@@ -118,8 +117,7 @@ void CookiePromptModalDialog::AllowSiteData(bool remember,
}
void CookiePromptModalDialog::BlockSiteData(bool remember) {
- DCHECK(!remember || DecisionPersistable());
- if (remember && DecisionPersistable()) {
+ if (remember) {
// Make sure there is no entry that would override the pattern we are about
// to insert for exactly this URL.
host_content_settings_map_->SetContentSetting(
@@ -146,7 +144,3 @@ int CookiePromptModalDialog::GetDialogButtons() {
return MessageBoxFlags::DIALOGBUTTON_OK |
MessageBoxFlags::DIALOGBUTTON_CANCEL;
}
-
-bool CookiePromptModalDialog::DecisionPersistable() {
- return !host_content_settings_map_->IsOffTheRecord();
-}
diff --git a/chrome/browser/cookie_modal_dialog.h b/chrome/browser/cookie_modal_dialog.h
index b8891ea4..c91a420 100644
--- a/chrome/browser/cookie_modal_dialog.h
+++ b/chrome/browser/cookie_modal_dialog.h
@@ -72,9 +72,6 @@ class CookiePromptModalDialog : public AppModalDialog {
virtual void CancelWindow();
virtual bool IsValid();
- // Whether the user may choose to have the browser remember the decision.
- bool DecisionPersistable();
-
#if defined(OS_MACOSX)
virtual void CloseModalDialog();
#endif
diff --git a/chrome/browser/cookie_modal_dialog_gtk.cc b/chrome/browser/cookie_modal_dialog_gtk.cc
index e2add83..a5eef95 100644
--- a/chrome/browser/cookie_modal_dialog_gtk.cc
+++ b/chrome/browser/cookie_modal_dialog_gtk.cc
@@ -76,20 +76,15 @@ NativeDialog CookiePromptModalDialog::CreateNativeDialog() {
// Create a vbox for all the radio buttons so they aren't too far away from
// each other.
- bool remember_enabled = DecisionPersistable();
GtkWidget* radio_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
remember_radio_ = gtk_radio_button_new_with_label(NULL,
l10n_util::GetStringFUTF8(IDS_COOKIE_ALERT_REMEMBER_RADIO,
display_host).c_str());
- gtk_widget_set_sensitive(GTK_WIDGET(remember_radio_), remember_enabled);
gtk_box_pack_start(GTK_BOX(radio_box), remember_radio_, FALSE, FALSE, 0);
GtkWidget* ask_radio = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(remember_radio_),
l10n_util::GetStringUTF8(IDS_COOKIE_ALERT_ASK_RADIO).c_str());
- gtk_widget_set_sensitive(GTK_WIDGET(ask_radio), remember_enabled);
- if (!remember_enabled)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ask_radio), true);
gtk_box_pack_start(GTK_BOX(radio_box), ask_radio, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(content_area), radio_box, FALSE, FALSE, 0);
diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.cc b/chrome/browser/gtk/content_setting_bubble_gtk.cc
index 66d4a75..e4afdcd 100644
--- a/chrome/browser/gtk/content_setting_bubble_gtk.cc
+++ b/chrome/browser/gtk/content_setting_bubble_gtk.cc
@@ -131,7 +131,6 @@ void ContentSettingBubbleGtk::BuildBubble() {
gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(radio_group_gtk_[0]),
i->c_str());
- gtk_widget_set_sensitive(radio, radio_group.is_mutable);
gtk_box_pack_start(GTK_BOX(bubble_content), radio, FALSE, FALSE, 0);
if (i - radio_group.radio_items.begin() == radio_group.default_item) {
// We must set the default value before we attach the signal handlers
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc
index aaf11a1..f9e359d 100644
--- a/chrome/browser/host_content_settings_map.cc
+++ b/chrome/browser/host_content_settings_map.cc
@@ -231,35 +231,53 @@ ContentSettings HostContentSettingsMap::GetContentSettings(
AutoLock auto_lock(lock_);
const std::string host(net::GetHostOrSpecFromURL(url));
+ ContentSettings output;
+ for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j)
+ output.settings[j] = CONTENT_SETTING_DEFAULT;
// Check for exact matches first.
HostContentSettings::const_iterator i(host_content_settings_.find(host));
- if (i != host_content_settings_.end()) {
- ContentSettings output = i->second;
- for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) {
- if (output.settings[j] == CONTENT_SETTING_DEFAULT)
- output.settings[j] = default_content_settings_.settings[j];
- }
- return output;
+ if (i != host_content_settings_.end())
+ output = i->second;
+
+ // If this map is not for an off-the-record profile, these searches will never
+ // match. The additional off-the-record exceptions always overwrite the
+ // regular ones.
+ i = off_the_record_settings_.find(host);
+ if (i != off_the_record_settings_.end()) {
+ for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j)
+ if (i->second.settings[j] != CONTENT_SETTING_DEFAULT)
+ output.settings[j] = i->second.settings[j];
}
- // Find the most concrete pattern match.
+ // Match patterns starting with the most concrete pattern match.
for (std::string key = std::string(kDomainWildcard) + host; ; ) {
- HostContentSettings::const_iterator i(host_content_settings_.find(key));
+ HostContentSettings::const_iterator i(off_the_record_settings_.find(key));
+ if (i != off_the_record_settings_.end()) {
+ for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) {
+ if (output.settings[j] == CONTENT_SETTING_DEFAULT)
+ output.settings[j] = i->second.settings[j];
+ }
+ }
+ i = host_content_settings_.find(key);
if (i != host_content_settings_.end()) {
- ContentSettings output = i->second;
for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) {
if (output.settings[j] == CONTENT_SETTING_DEFAULT)
- output.settings[j] = default_content_settings_.settings[j];
+ output.settings[j] = i->second.settings[j];
}
- return output;
}
const size_t next_dot = key.find('.', kDomainWildcardLength);
if (next_dot == std::string::npos)
break;
key.erase(kDomainWildcardLength, next_dot - kDomainWildcardLength + 1);
}
- return default_content_settings_;
+
+ // Make the remaining defaults explicit.
+ for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j)
+ if (output.settings[j] == CONTENT_SETTING_DEFAULT)
+ output.settings[j] = default_content_settings_.settings[j];
+
+ return output;
}
void HostContentSettingsMap::GetSettingsForOneType(
@@ -268,9 +286,12 @@ void HostContentSettingsMap::GetSettingsForOneType(
DCHECK(settings);
settings->clear();
+ const HostContentSettings* map_to_return =
+ is_off_the_record_ ? &off_the_record_settings_ : &host_content_settings_;
+
AutoLock auto_lock(lock_);
- for (HostContentSettings::const_iterator i(host_content_settings_.begin());
- i != host_content_settings_.end(); ++i) {
+ for (HostContentSettings::const_iterator i(map_to_return->begin());
+ i != map_to_return->end(); ++i) {
ContentSetting setting = i->second.settings[content_type];
if (setting != CONTENT_SETTING_DEFAULT) {
// Use of push_back() relies on the map iterator traversing in order of
@@ -287,7 +308,8 @@ void HostContentSettingsMap::SetDefaultContentSetting(
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
PrefService* prefs = profile_->GetPrefs();
- // Settings may not be modified for OTR sessions.
+ // The default settings may not be directly modified for OTR sessions.
+ // Instead, they are synced to the main profile's setting.
if (is_off_the_record_) {
NOTREACHED();
return;
@@ -322,29 +344,31 @@ void HostContentSettingsMap::SetContentSetting(const Pattern& pattern,
ContentSetting setting) {
DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation.
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- PrefService* prefs = profile_->GetPrefs();
-
- // Settings may not be modified for OTR sessions.
- if (is_off_the_record_) {
- NOTREACHED();
- return;
- }
bool early_exit = false;
std::wstring wide_pattern(UTF8ToWide(pattern.AsString()));
- DictionaryValue* all_settings_dictionary =
+ PrefService* prefs = NULL;
+ DictionaryValue* all_settings_dictionary = NULL;
+ HostContentSettings* map_to_modify = &off_the_record_settings_;
+ if (!is_off_the_record_) {
+ prefs = profile_->GetPrefs();
+ all_settings_dictionary =
prefs->GetMutableDictionary(prefs::kContentSettingsPatterns);
+ map_to_modify = &host_content_settings_;
+ }
+
{
AutoLock auto_lock(lock_);
- if (!host_content_settings_.count(pattern.AsString()))
- host_content_settings_[pattern.AsString()] = ContentSettings();
+ if (!map_to_modify->count(pattern.AsString()))
+ (*map_to_modify)[pattern.AsString()] = ContentSettings();
HostContentSettings::iterator
- i(host_content_settings_.find(pattern.AsString()));
+ i(map_to_modify->find(pattern.AsString()));
ContentSettings& settings = i->second;
settings.settings[content_type] = setting;
if (AllDefault(settings)) {
- host_content_settings_.erase(i);
- all_settings_dictionary->RemoveWithoutPathExpansion(wide_pattern, NULL);
+ map_to_modify->erase(i);
+ if (all_settings_dictionary)
+ all_settings_dictionary->RemoveWithoutPathExpansion(wide_pattern, NULL);
// We can't just return because |NotifyObservers()| needs to be called,
// without |lock_| being held.
@@ -352,7 +376,7 @@ void HostContentSettingsMap::SetContentSetting(const Pattern& pattern,
}
}
- if (!early_exit) {
+ if (!early_exit && all_settings_dictionary) {
DictionaryValue* host_settings_dictionary;
bool found = all_settings_dictionary->GetDictionaryWithoutPathExpansion(
wide_pattern, &host_settings_dictionary);
@@ -373,9 +397,8 @@ void HostContentSettingsMap::SetContentSetting(const Pattern& pattern,
}
updating_preferences_ = true;
- {
+ if (!is_off_the_record_)
ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns);
- }
updating_preferences_ = false;
NotifyObservers(ContentSettingsDetails(pattern));
@@ -385,28 +408,30 @@ void HostContentSettingsMap::ClearSettingsForOneType(
ContentSettingsType content_type) {
DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation.
- // Settings may not be modified for OTR sessions.
- if (is_off_the_record_) {
- NOTREACHED();
- return;
+ PrefService* prefs = NULL;
+ DictionaryValue* all_settings_dictionary = NULL;
+ HostContentSettings* map_to_modify = &off_the_record_settings_;
+
+ if (!is_off_the_record_) {
+ prefs = profile_->GetPrefs();
+ all_settings_dictionary =
+ prefs->GetMutableDictionary(prefs::kContentSettingsPatterns);
+ map_to_modify = &host_content_settings_;
}
- PrefService* prefs = profile_->GetPrefs();
- updating_preferences_ = true;
{
AutoLock auto_lock(lock_);
- ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns);
- for (HostContentSettings::iterator i(host_content_settings_.begin());
- i != host_content_settings_.end(); ) {
+ for (HostContentSettings::iterator i(map_to_modify->begin());
+ i != map_to_modify->end(); ) {
if (i->second.settings[content_type] != CONTENT_SETTING_DEFAULT) {
i->second.settings[content_type] = CONTENT_SETTING_DEFAULT;
std::wstring wide_host(UTF8ToWide(i->first));
- DictionaryValue* all_settings_dictionary =
- prefs->GetMutableDictionary(prefs::kContentSettingsPatterns);
if (AllDefault(i->second)) {
- all_settings_dictionary->RemoveWithoutPathExpansion(wide_host, NULL);
- host_content_settings_.erase(i++);
- } else {
+ if (all_settings_dictionary)
+ all_settings_dictionary->
+ RemoveWithoutPathExpansion(wide_host, NULL);
+ map_to_modify->erase(i++);
+ } else if (all_settings_dictionary) {
DictionaryValue* host_settings_dictionary;
bool found =
all_settings_dictionary->GetDictionaryWithoutPathExpansion(
@@ -421,6 +446,10 @@ void HostContentSettingsMap::ClearSettingsForOneType(
}
}
}
+
+ updating_preferences_ = true;
+ if (!is_off_the_record_)
+ ScopedPrefUpdate update(prefs, prefs::kContentSettingsPatterns);
updating_preferences_ = false;
NotifyObservers(ContentSettingsDetails(true));
@@ -429,7 +458,8 @@ void HostContentSettingsMap::ClearSettingsForOneType(
void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- // Settings may not be modified for OTR sessions.
+ // This setting may not be directly modified for OTR sessions. Instead, it
+ // is synced to the main profile's setting.
if (is_off_the_record_) {
NOTREACHED();
return;
@@ -455,17 +485,19 @@ void HostContentSettingsMap::ResetToDefaults() {
default_content_settings_ = ContentSettings();
ForceDefaultsToBeExplicit();
host_content_settings_.clear();
+ off_the_record_settings_.clear();
block_third_party_cookies_ = false;
}
- PrefService* prefs = profile_->GetPrefs();
- updating_preferences_ = true;
- prefs->ClearPref(prefs::kDefaultContentSettings);
- prefs->ClearPref(prefs::kContentSettingsPatterns);
- prefs->ClearPref(prefs::kBlockThirdPartyCookies);
- updating_preferences_ = false;
-
- NotifyObservers(ContentSettingsDetails(true));
+ if (!is_off_the_record_) {
+ PrefService* prefs = profile_->GetPrefs();
+ updating_preferences_ = true;
+ prefs->ClearPref(prefs::kDefaultContentSettings);
+ prefs->ClearPref(prefs::kContentSettingsPatterns);
+ prefs->ClearPref(prefs::kBlockThirdPartyCookies);
+ updating_preferences_ = false;
+ NotifyObservers(ContentSettingsDetails(true));
+ }
}
bool HostContentSettingsMap::IsOffTheRecord() {
@@ -495,7 +527,8 @@ void HostContentSettingsMap::Observe(NotificationType type,
return;
}
- NotifyObservers(ContentSettingsDetails(true));
+ if (!is_off_the_record_)
+ NotifyObservers(ContentSettingsDetails(true));
} else if (NotificationType::PROFILE_DESTROYED == type) {
UnregisterObservers();
} else {
diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h
index 06f1270..876fa713 100644
--- a/chrome/browser/host_content_settings_map.h
+++ b/chrome/browser/host_content_settings_map.h
@@ -117,14 +117,17 @@ class HostContentSettingsMap
ContentSettings GetContentSettings(const GURL& url) const;
// For a given content type, returns all patterns with a non-default setting,
- // mapped to their actual settings, in lexicographical order. |settings| must
- // be a non-NULL outparam.
+ // mapped to their actual settings, in lexicographical order. |settings|
+ // must be a non-NULL outparam. If this map was created for the
+ // off-the-record profile, it will only return those settings differing from
+ // the main map.
//
// This may be called on any thread.
void GetSettingsForOneType(ContentSettingsType content_type,
SettingsForOneType* settings) const;
- // Sets the default setting for a particular content type.
+ // Sets the default setting for a particular content type. This method must
+ // not be invoked on an off-the-record map.
//
// This should only be called on the UI thread.
void SetDefaultContentSetting(ContentSettingsType content_type,
@@ -147,7 +150,8 @@ class HostContentSettingsMap
// This setting trumps any host-specific settings.
bool BlockThirdPartyCookies() const { return block_third_party_cookies_; }
- // Sets whether we block all third-party cookies.
+ // Sets whether we block all third-party cookies. This method must not be
+ // invoked on an off-the-record map.
//
// This should only be called on the UI thread.
void SetBlockThirdPartyCookies(bool block);
@@ -217,6 +221,10 @@ class HostContentSettingsMap
ContentSettings default_content_settings_;
HostContentSettings host_content_settings_;
+ // Differences to the preference-stored host content settings for
+ // off-the-record settings.
+ HostContentSettings off_the_record_settings_;
+
// Misc global settings.
bool block_third_party_cookies_;
diff --git a/chrome/browser/host_content_settings_map_unittest.cc b/chrome/browser/host_content_settings_map_unittest.cc
index 8c6de63..bc9fb37 100644
--- a/chrome/browser/host_content_settings_map_unittest.cc
+++ b/chrome/browser/host_content_settings_map_unittest.cc
@@ -420,4 +420,95 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) {
host_ending_with_dot, CONTENT_SETTINGS_TYPE_POPUPS));
}
+TEST_F(HostContentSettingsMapTest, NestedSettings) {
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ profile.GetHostContentSettingsMap();
+
+ GURL host("http://a.b.example.com/");
+ HostContentSettingsMap::Pattern pattern1("[*.]example.com");
+ HostContentSettingsMap::Pattern pattern2("[*.]b.example.com");
+ HostContentSettingsMap::Pattern pattern3("a.b.example.com");
+
+ host_content_settings_map->SetContentSetting(pattern1,
+ CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(pattern2,
+ CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetContentSetting(pattern3,
+ CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
+ host_content_settings_map->SetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
+
+ ContentSettings desired_settings;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES] =
+ CONTENT_SETTING_BLOCK;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] =
+ CONTENT_SETTING_BLOCK;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] =
+ CONTENT_SETTING_BLOCK;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
+ CONTENT_SETTING_BLOCK;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
+ CONTENT_SETTING_BLOCK;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION] =
+ CONTENT_SETTING_ASK;
+ ContentSettings settings =
+ host_content_settings_map->GetContentSettings(host);
+ EXPECT_TRUE(SettingsEqual(desired_settings, settings));
+ EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES],
+ settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]);
+ EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES],
+ settings.settings[CONTENT_SETTINGS_TYPE_IMAGES]);
+ EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS],
+ settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]);
+ EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS],
+ settings.settings[CONTENT_SETTINGS_TYPE_POPUPS]);
+ EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION],
+ settings.settings[CONTENT_SETTINGS_TYPE_GEOLOCATION]);
+ EXPECT_EQ(desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES],
+ settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]);
+}
+
+TEST_F(HostContentSettingsMapTest, OffTheRecord) {
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ profile.GetHostContentSettingsMap();
+ profile.set_off_the_record(true);
+ scoped_refptr<HostContentSettingsMap> otr_map =
+ new HostContentSettingsMap(&profile);
+ profile.set_off_the_record(false);
+
+ GURL host("http://example.com/");
+ HostContentSettingsMap::Pattern pattern("[*.]example.com");
+
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ host_content_settings_map->GetContentSetting(
+ host, CONTENT_SETTINGS_TYPE_IMAGES));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ otr_map->GetContentSetting(
+ host, CONTENT_SETTINGS_TYPE_IMAGES));
+
+ // Changing content settings on the main map should also affect the
+ // off-the-record map.
+ host_content_settings_map->SetContentSetting(pattern,
+ CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, CONTENT_SETTINGS_TYPE_IMAGES));
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ otr_map->GetContentSetting(
+ host, CONTENT_SETTINGS_TYPE_IMAGES));
+
+ // Changing content settings on the off-the-record map should NOT affect the
+ // main map.
+ otr_map->SetContentSetting(pattern,
+ CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_ALLOW);
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
+ host_content_settings_map->GetContentSetting(
+ host, CONTENT_SETTINGS_TYPE_IMAGES));
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ otr_map->GetContentSetting(
+ host, CONTENT_SETTINGS_TYPE_IMAGES));
+}
+
} // namespace
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 725db75..25afd700 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2974,11 +2974,11 @@ void TabContents::Observe(NotificationType type,
GURL entry_url;
if (entry)
entry_url = entry->url();
- Source<HostContentSettingsMap> content_settings(source);
if (settings_details.ptr()->update_all() ||
settings_details.ptr()->pattern().Matches(entry_url)) {
render_view_host()->SendContentSettings(entry_url,
- content_settings.ptr()->GetContentSettings(entry_url));
+ profile()->GetHostContentSettingsMap()->
+ GetContentSettings(entry_url));
}
break;
}
diff --git a/chrome/browser/views/content_blocked_bubble_contents.cc b/chrome/browser/views/content_blocked_bubble_contents.cc
index 1f43ec1..ab7675a 100644
--- a/chrome/browser/views/content_blocked_bubble_contents.cc
+++ b/chrome/browser/views/content_blocked_bubble_contents.cc
@@ -225,7 +225,6 @@ void ContentSettingBubbleContents::InitControlLayout() {
i != radio_group.radio_items.end(); ++i) {
views::RadioButton* radio = new views::RadioButton(UTF8ToWide(*i), 0);
radio->set_listener(this);
- radio->SetEnabled(radio_group.is_mutable);
radio_group_.push_back(radio);
layout->StartRow(0, single_column_set_id);
layout->AddView(radio);
diff --git a/chrome/browser/views/cookie_prompt_view.cc b/chrome/browser/views/cookie_prompt_view.cc
index 32cbccb..39240ee 100644
--- a/chrome/browser/views/cookie_prompt_view.cc
+++ b/chrome/browser/views/cookie_prompt_view.cc
@@ -148,15 +148,12 @@ void CookiePromptView::Init() {
IDS_COOKIE_ALERT_LABEL : IDS_DATA_ALERT_LABEL,
display_host));
int radio_group_id = 0;
- bool remember_enabled = parent_->DecisionPersistable();
remember_radio_ = new views::RadioButton(
l10n_util::GetStringF(IDS_COOKIE_ALERT_REMEMBER_RADIO, display_host),
radio_group_id);
remember_radio_->set_listener(this);
- remember_radio_->SetEnabled(remember_enabled);
ask_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_COOKIE_ALERT_ASK_RADIO), radio_group_id);
- ask_radio_->SetEnabled(remember_enabled);
ask_radio_->set_listener(this);
allow_button_ = new views::NativeButton(
this, l10n_util::GetString(IDS_COOKIE_ALERT_ALLOW_BUTTON));
@@ -230,7 +227,8 @@ void CookiePromptView::Init() {
layout->AddView(cookie_info_view, 1, 1, GridLayout::FILL,
GridLayout::CENTER);
- cookie_info_view->SetCookieString(parent_->origin(), parent_->cookie_line());
+ cookie_info_view->SetCookieString(parent_->origin(),
+ parent_->cookie_line());
info_view_ = cookie_info_view;
} else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) {
LocalStorageSetItemInfoView* view = new LocalStorageSetItemInfoView();
@@ -263,10 +261,7 @@ void CookiePromptView::Init() {
info_view_->SetVisible(expanded_view_);
// Set default values.
- if (remember_enabled)
- remember_radio_->SetChecked(true);
- else
- ask_radio_->SetChecked(true);
+ remember_radio_->SetChecked(true);
}
int CookiePromptView::GetExtendedViewHeight() {