diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-20 17:58:32 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-20 17:58:32 +0000 |
commit | 8c1ae5ec4d47638315096f54819793484383c91f (patch) | |
tree | c7749cae01663511be911c22e3928f7ef5aa8aab /chrome/browser/cookie_modal_dialog.cc | |
parent | e90eca1550812bb5694c9523ffc75963c845d46d (diff) | |
download | chromium_src-8c1ae5ec4d47638315096f54819793484383c91f.zip chromium_src-8c1ae5ec4d47638315096f54819793484383c91f.tar.gz chromium_src-8c1ae5ec4d47638315096f54819793484383c91f.tar.bz2 |
Pass in the HostContentSettingsMap to the CookieModalDialog so IsValid can make its decision. Before, it used the TabContents to get the profile to get the map, but this was incorrect because the current tab isn't necessarily from the same profile as the original request.
As long as we have the HostContentSettingsMap, we might as well handle "remember" in CookieModalDialog.
This bug exists in 4.1.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/651023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39558 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cookie_modal_dialog.cc')
-rw-r--r-- | chrome/browser/cookie_modal_dialog.cc | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/chrome/browser/cookie_modal_dialog.cc b/chrome/browser/cookie_modal_dialog.cc index 579698e..a744fdf 100644 --- a/chrome/browser/cookie_modal_dialog.cc +++ b/chrome/browser/cookie_modal_dialog.cc @@ -14,10 +14,12 @@ // Cookies CookiePromptModalDialog::CookiePromptModalDialog( TabContents* tab_contents, + HostContentSettingsMap* host_content_settings_map, const GURL& origin, const std::string& cookie_line, CookiePromptModalDialogDelegate* delegate) : AppModalDialog(tab_contents, std::wstring()), + host_content_settings_map_(host_content_settings_map), dialog_type_(DIALOG_TYPE_COOKIE), origin_(origin), cookie_line_(cookie_line), @@ -27,11 +29,13 @@ CookiePromptModalDialog::CookiePromptModalDialog( // LocalStorage CookiePromptModalDialog::CookiePromptModalDialog( TabContents* tab_contents, + HostContentSettingsMap* host_content_settings_map, const GURL& origin, const string16& key, const string16& value, CookiePromptModalDialogDelegate* delegate) : AppModalDialog(tab_contents, std::wstring()), + host_content_settings_map_(host_content_settings_map), dialog_type_(DIALOG_TYPE_LOCAL_STORAGE), origin_(origin), local_storage_key_(key), @@ -42,25 +46,28 @@ CookiePromptModalDialog::CookiePromptModalDialog( // Database CookiePromptModalDialog::CookiePromptModalDialog( TabContents* tab_contents, + HostContentSettingsMap* host_content_settings_map, const GURL& origin, const string16& database_name, CookiePromptModalDialogDelegate* delegate) : AppModalDialog(tab_contents, std::wstring()), + host_content_settings_map_(host_content_settings_map), dialog_type_(DIALOG_TYPE_DATABASE), origin_(origin), database_name_(database_name), delegate_(delegate) { } +CookiePromptModalDialog::~CookiePromptModalDialog() { +} + bool CookiePromptModalDialog::IsValid() { - HostContentSettingsMap* host_content_settings_map = - tab_contents()->profile()->GetHostContentSettingsMap(); ContentSetting content_setting = - host_content_settings_map->GetContentSetting( - origin(), - CONTENT_SETTINGS_TYPE_COOKIES); + host_content_settings_map_->GetContentSetting( + origin_, CONTENT_SETTINGS_TYPE_COOKIES); if (content_setting != CONTENT_SETTING_ASK) { if (content_setting == CONTENT_SETTING_ALLOW) { + // If it's remembered as allow, then we assume session_expire is false. AllowSiteData(false, false); } else { DCHECK(content_setting == CONTENT_SETTING_BLOCK); @@ -68,20 +75,30 @@ bool CookiePromptModalDialog::IsValid() { } return false; } - return true; + return !skip_this_dialog_; } void CookiePromptModalDialog::AllowSiteData(bool remember, bool session_expire) { + if (remember) { + host_content_settings_map_->SetContentSetting( + origin_.host(), CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_ALLOW); + } + if (delegate_) { - delegate_->AllowSiteData(remember, session_expire); + delegate_->AllowSiteData(session_expire); delegate_ = NULL; // It can be deleted at any point now. } } void CookiePromptModalDialog::BlockSiteData(bool remember) { + if (remember) { + host_content_settings_map_->SetContentSetting( + origin_.host(), CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); + } + if (delegate_) { - delegate_->BlockSiteData(remember); + delegate_->BlockSiteData(); delegate_ = NULL; // It can be deleted at any point now. } } |