Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

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

Issue 2878075: Introduce a resource identifier for content settings. (Closed)
Patch Set: updates Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/content_setting_bubble_model.cc ('k') | chrome/browser/cookies_tree_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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...) Expand 10 before | Expand all | Expand 10 after
79 appcache_manifest_url_(appcache_manifest_url), 79 appcache_manifest_url_(appcache_manifest_url),
80 delegate_(delegate) { 80 delegate_(delegate) {
81 } 81 }
82 82
83 CookiePromptModalDialog::~CookiePromptModalDialog() { 83 CookiePromptModalDialog::~CookiePromptModalDialog() {
84 } 84 }
85 85
86 bool CookiePromptModalDialog::IsValid() { 86 bool CookiePromptModalDialog::IsValid() {
87 ContentSetting content_setting = 87 ContentSetting content_setting =
88 host_content_settings_map_->GetContentSetting( 88 host_content_settings_map_->GetContentSetting(
89 origin_, CONTENT_SETTINGS_TYPE_COOKIES); 89 origin_, CONTENT_SETTINGS_TYPE_COOKIES, "");
90 if (content_setting != CONTENT_SETTING_ASK) { 90 if (content_setting != CONTENT_SETTING_ASK) {
91 if (content_setting == CONTENT_SETTING_ALLOW) { 91 if (content_setting == CONTENT_SETTING_ALLOW) {
92 AllowSiteData(false, false); 92 AllowSiteData(false, false);
93 } else if (content_setting == CONTENT_SETTING_SESSION_ONLY) { 93 } else if (content_setting == CONTENT_SETTING_SESSION_ONLY) {
94 AllowSiteData(false, true); 94 AllowSiteData(false, true);
95 } else { 95 } else {
96 DCHECK(content_setting == CONTENT_SETTING_BLOCK); 96 DCHECK(content_setting == CONTENT_SETTING_BLOCK);
97 BlockSiteData(false); 97 BlockSiteData(false);
98 } 98 }
99 return false; 99 return false;
100 } 100 }
101 return !skip_this_dialog_; 101 return !skip_this_dialog_;
102 } 102 }
103 103
104 void CookiePromptModalDialog::AllowSiteData(bool remember, 104 void CookiePromptModalDialog::AllowSiteData(bool remember,
105 bool session_expire) { 105 bool session_expire) {
106 if (remember) { 106 if (remember) {
107 // Make sure there is no entry that would override the pattern we are about 107 // Make sure there is no entry that would override the pattern we are about
108 // to insert for exactly this URL. 108 // to insert for exactly this URL.
109 host_content_settings_map_->SetContentSetting( 109 host_content_settings_map_->SetContentSetting(
110 HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_), 110 HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_),
111 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_DEFAULT); 111 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_DEFAULT);
112 host_content_settings_map_->SetContentSetting( 112 host_content_settings_map_->SetContentSetting(
113 HostContentSettingsMap::Pattern::FromURL(origin_), 113 HostContentSettingsMap::Pattern::FromURL(origin_),
114 CONTENT_SETTINGS_TYPE_COOKIES, 114 CONTENT_SETTINGS_TYPE_COOKIES,
115 "",
115 session_expire ? CONTENT_SETTING_SESSION_ONLY : CONTENT_SETTING_ALLOW); 116 session_expire ? CONTENT_SETTING_SESSION_ONLY : CONTENT_SETTING_ALLOW);
116 } 117 }
117 118
118 if (delegate_) { 119 if (delegate_) {
119 delegate_->AllowSiteData(session_expire); 120 delegate_->AllowSiteData(session_expire);
120 delegate_ = NULL; // It can be deleted at any point now. 121 delegate_ = NULL; // It can be deleted at any point now.
121 } 122 }
122 } 123 }
123 124
124 void CookiePromptModalDialog::BlockSiteData(bool remember) { 125 void CookiePromptModalDialog::BlockSiteData(bool remember) {
125 if (remember) { 126 if (remember) {
126 // Make sure there is no entry that would override the pattern we are about 127 // Make sure there is no entry that would override the pattern we are about
127 // to insert for exactly this URL. 128 // to insert for exactly this URL.
128 host_content_settings_map_->SetContentSetting( 129 host_content_settings_map_->SetContentSetting(
129 HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_), 130 HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_),
130 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_DEFAULT); 131 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_DEFAULT);
131 host_content_settings_map_->SetContentSetting( 132 host_content_settings_map_->SetContentSetting(
132 HostContentSettingsMap::Pattern::FromURL(origin_), 133 HostContentSettingsMap::Pattern::FromURL(origin_),
133 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); 134 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK);
134 } 135 }
135 136
136 if (delegate_) { 137 if (delegate_) {
137 delegate_->BlockSiteData(); 138 delegate_->BlockSiteData();
138 delegate_ = NULL; // It can be deleted at any point now. 139 delegate_ = NULL; // It can be deleted at any point now.
139 } 140 }
140 } 141 }
141 142
142 // static 143 // static
143 void CookiePromptModalDialog::RegisterUserPrefs(PrefService* prefs) { 144 void CookiePromptModalDialog::RegisterUserPrefs(PrefService* prefs) {
144 prefs->RegisterBooleanPref(prefs::kCookiePromptExpanded, false); 145 prefs->RegisterBooleanPref(prefs::kCookiePromptExpanded, false);
145 } 146 }
146 147
147 int CookiePromptModalDialog::GetDialogButtons() { 148 int CookiePromptModalDialog::GetDialogButtons() {
148 // Enable the automation interface to accept/dismiss this dialog. 149 // Enable the automation interface to accept/dismiss this dialog.
149 return MessageBoxFlags::DIALOGBUTTON_OK | 150 return MessageBoxFlags::DIALOGBUTTON_OK |
150 MessageBoxFlags::DIALOGBUTTON_CANCEL; 151 MessageBoxFlags::DIALOGBUTTON_CANCEL;
151 } 152 }
OLDNEW
« no previous file with comments | « chrome/browser/content_setting_bubble_model.cc ('k') | chrome/browser/cookies_tree_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698