Index: chrome/browser/cookie_modal_dialog.cc |
=================================================================== |
--- chrome/browser/cookie_modal_dialog.cc (revision 39556) |
+++ chrome/browser/cookie_modal_dialog.cc (working copy) |
@@ -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 @@ |
// 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 @@ |
// 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 @@ |
} |
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. |
} |
} |