Chromium Code Reviews

Side by Side Diff: chrome/browser/cookie_modal_dialog.cc

Issue 2858018: Add a "session only" policy to the content settings. (Closed)
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/cookie_modal_dialog.h" 5 #include "chrome/browser/cookie_modal_dialog.h"
6 6
7 #include "app/message_box_flags.h" 7 #include "app/message_box_flags.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/host_content_settings_map.h" 9 #include "chrome/browser/host_content_settings_map.h"
10 #include "chrome/browser/pref_service.h" 10 #include "chrome/browser/pref_service.h"
(...skipping 68 matching lines...)
79 79
80 CookiePromptModalDialog::~CookiePromptModalDialog() { 80 CookiePromptModalDialog::~CookiePromptModalDialog() {
81 } 81 }
82 82
83 bool CookiePromptModalDialog::IsValid() { 83 bool CookiePromptModalDialog::IsValid() {
84 ContentSetting content_setting = 84 ContentSetting content_setting =
85 host_content_settings_map_->GetContentSetting( 85 host_content_settings_map_->GetContentSetting(
86 origin_, CONTENT_SETTINGS_TYPE_COOKIES); 86 origin_, CONTENT_SETTINGS_TYPE_COOKIES);
87 if (content_setting != CONTENT_SETTING_ASK) { 87 if (content_setting != CONTENT_SETTING_ASK) {
88 if (content_setting == CONTENT_SETTING_ALLOW) { 88 if (content_setting == CONTENT_SETTING_ALLOW) {
89 // If it's remembered as allow, then we assume session_expire is false.
90 AllowSiteData(false, false); 89 AllowSiteData(false, false);
90 } else if (content_setting == CONTENT_SETTING_SESSION_ONLY) {
91 AllowSiteData(false, true);
91 } else { 92 } else {
92 DCHECK(content_setting == CONTENT_SETTING_BLOCK); 93 DCHECK(content_setting == CONTENT_SETTING_BLOCK);
93 BlockSiteData(false); 94 BlockSiteData(false);
94 } 95 }
95 return false; 96 return false;
96 } 97 }
97 return !skip_this_dialog_; 98 return !skip_this_dialog_;
98 } 99 }
99 100
100 void CookiePromptModalDialog::AllowSiteData(bool remember, 101 void CookiePromptModalDialog::AllowSiteData(bool remember,
101 bool session_expire) { 102 bool session_expire) {
102 DCHECK(!remember || DecisionPersistable()); 103 DCHECK(!remember || DecisionPersistable());
103 if (remember && DecisionPersistable()) { 104 if (remember && DecisionPersistable()) {
104 // Make sure there is no entry that would override the pattern we are about 105 // Make sure there is no entry that would override the pattern we are about
105 // to insert for exactly this URL. 106 // to insert for exactly this URL.
106 host_content_settings_map_->SetContentSetting( 107 host_content_settings_map_->SetContentSetting(
107 HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_), 108 HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_),
108 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_DEFAULT); 109 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_DEFAULT);
109 host_content_settings_map_->SetContentSetting( 110 host_content_settings_map_->SetContentSetting(
110 HostContentSettingsMap::Pattern::FromURL(origin_), 111 HostContentSettingsMap::Pattern::FromURL(origin_),
111 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_ALLOW); 112 CONTENT_SETTINGS_TYPE_COOKIES,
113 session_expire ? CONTENT_SETTING_SESSION_ONLY : CONTENT_SETTING_ALLOW);
112 } 114 }
113 115
114 if (delegate_) { 116 if (delegate_) {
115 delegate_->AllowSiteData(session_expire); 117 delegate_->AllowSiteData(session_expire);
116 delegate_ = NULL; // It can be deleted at any point now. 118 delegate_ = NULL; // It can be deleted at any point now.
117 } 119 }
118 } 120 }
119 121
120 void CookiePromptModalDialog::BlockSiteData(bool remember) { 122 void CookiePromptModalDialog::BlockSiteData(bool remember) {
121 DCHECK(!remember || DecisionPersistable()); 123 DCHECK(!remember || DecisionPersistable());
(...skipping 21 matching lines...)
143 145
144 int CookiePromptModalDialog::GetDialogButtons() { 146 int CookiePromptModalDialog::GetDialogButtons() {
145 // Enable the automation interface to accept/dismiss this dialog. 147 // Enable the automation interface to accept/dismiss this dialog.
146 return MessageBoxFlags::DIALOGBUTTON_OK | 148 return MessageBoxFlags::DIALOGBUTTON_OK |
147 MessageBoxFlags::DIALOGBUTTON_CANCEL; 149 MessageBoxFlags::DIALOGBUTTON_CANCEL;
148 } 150 }
149 151
150 bool CookiePromptModalDialog::DecisionPersistable() { 152 bool CookiePromptModalDialog::DecisionPersistable() {
151 return !host_content_settings_map_->IsOffTheRecord(); 153 return !host_content_settings_map_->IsOffTheRecord();
152 } 154 }
OLDNEW
« no previous file with comments | « chrome/browser/content_setting_combo_model.cc ('k') | chrome/browser/in_process_webkit/dom_storage_area.cc » ('j') | no next file with comments »

Powered by Google App Engine