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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 7713034: HostContentSettingsMap refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Keeping up to date with trunk. Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/content_settings/cookie_settings.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
11 #include "chrome/browser/favicon/favicon_tab_helper.h" 12 #include "chrome/browser/favicon/favicon_tab_helper.h"
12 #include "chrome/browser/infobars/infobar_tab_helper.h" 13 #include "chrome/browser/infobars/infobar_tab_helper.h"
13 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h" 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate. h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 19 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, 248 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION},
248 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, 249 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION},
249 }; 250 };
250 std::string radio_block_label; 251 std::string radio_block_label;
251 radio_block_label = l10n_util::GetStringUTF8( 252 radio_block_label = l10n_util::GetStringUTF8(
252 GetIdForContentType(kBlockIDs, arraysize(kBlockIDs), content_type())); 253 GetIdForContentType(kBlockIDs, arraysize(kBlockIDs), content_type()));
253 254
254 radio_group.radio_items.push_back(radio_allow_label); 255 radio_group.radio_items.push_back(radio_allow_label);
255 radio_group.radio_items.push_back(radio_block_label); 256 radio_group.radio_items.push_back(radio_block_label);
256 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); 257 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap();
257 ContentSetting mostRestrictiveSetting; 258 CookieSettings* cookie_settings =
259 CookieSettings::GetForProfile(profile());
260 ContentSetting most_restrictive_setting;
258 if (resources.empty()) { 261 if (resources.empty()) {
259 mostRestrictiveSetting = 262 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) {
260 content_type() == CONTENT_SETTINGS_TYPE_COOKIES ? 263 if (cookie_settings->IsSettingCookieAllowed(url, url)) {
Bernhard Bauer 2011/09/14 16:01:36 I think you could get this setting via |cookie_set
261 map->GetCookieContentSetting(url, url, true) : 264 if (cookie_settings->IsCookieSessionOnly(url))
262 map->GetContentSetting(url, url, content_type(), std::string()); 265 most_restrictive_setting = CONTENT_SETTING_SESSION_ONLY;
266 else
267 most_restrictive_setting = CONTENT_SETTING_ALLOW;
268 } else {
269 most_restrictive_setting = CONTENT_SETTING_BLOCK;
270 }
271 } else {
272 most_restrictive_setting =
273 map->GetContentSetting(url, url, content_type(), std::string());
274 }
263 } else { 275 } else {
264 mostRestrictiveSetting = CONTENT_SETTING_ALLOW; 276 most_restrictive_setting = CONTENT_SETTING_ALLOW;
265 for (std::set<std::string>::const_iterator it = resources.begin(); 277 for (std::set<std::string>::const_iterator it = resources.begin();
266 it != resources.end(); ++it) { 278 it != resources.end(); ++it) {
267 ContentSetting setting = map->GetContentSetting(url, 279 ContentSetting setting = map->GetContentSetting(url,
268 url, 280 url,
269 content_type(), 281 content_type(),
270 *it); 282 *it);
271 if (setting == CONTENT_SETTING_BLOCK) { 283 if (setting == CONTENT_SETTING_BLOCK) {
272 mostRestrictiveSetting = CONTENT_SETTING_BLOCK; 284 most_restrictive_setting = CONTENT_SETTING_BLOCK;
273 break; 285 break;
274 } 286 }
275 if (setting == CONTENT_SETTING_ASK) 287 if (setting == CONTENT_SETTING_ASK)
276 mostRestrictiveSetting = CONTENT_SETTING_ASK; 288 most_restrictive_setting = CONTENT_SETTING_ASK;
277 } 289 }
278 } 290 }
279 if (mostRestrictiveSetting == CONTENT_SETTING_ALLOW) { 291 if (most_restrictive_setting == CONTENT_SETTING_ALLOW) {
280 radio_group.default_item = 0; 292 radio_group.default_item = 0;
281 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. 293 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|.
282 } else { 294 } else {
283 radio_group.default_item = 1; 295 radio_group.default_item = 1;
284 block_setting_ = mostRestrictiveSetting; 296 block_setting_ = most_restrictive_setting;
285 } 297 }
286 selected_item_ = radio_group.default_item; 298 selected_item_ = radio_group.default_item;
287 set_radio_group(radio_group); 299 set_radio_group(radio_group);
288 } 300 }
289 301
290 void AddException(ContentSetting setting, 302 void AddException(ContentSetting setting,
291 const std::string& resource_identifier) { 303 const std::string& resource_identifier) {
292 if (profile()) { 304 if (profile()) {
293 profile()->GetHostContentSettingsMap()->AddExceptionForURL( 305 profile()->GetHostContentSettingsMap()->AddExceptionForURL(
294 bubble_content().radio_group.url, 306 bubble_content().radio_group.url,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 tab_contents_ = NULL; 562 tab_contents_ = NULL;
551 break; 563 break;
552 case chrome::NOTIFICATION_PROFILE_DESTROYED: 564 case chrome::NOTIFICATION_PROFILE_DESTROYED:
553 DCHECK(source == Source<Profile>(profile_)); 565 DCHECK(source == Source<Profile>(profile_));
554 profile_ = NULL; 566 profile_ = NULL;
555 break; 567 break;
556 default: 568 default:
557 NOTREACHED(); 569 NOTREACHED();
558 } 570 }
559 } 571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698