OLD | NEW |
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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/content_settings/cookie_settings.h" |
8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
10 #include "chrome/browser/favicon/favicon_tab_helper.h" | 11 #include "chrome/browser/favicon/favicon_tab_helper.h" |
11 #include "chrome/browser/infobars/infobar_tab_helper.h" | 12 #include "chrome/browser/infobars/infobar_tab_helper.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 15 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
15 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" | 16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" |
16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 18 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, | 247 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, |
247 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, | 248 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, |
248 }; | 249 }; |
249 std::string radio_block_label; | 250 std::string radio_block_label; |
250 radio_block_label = l10n_util::GetStringUTF8( | 251 radio_block_label = l10n_util::GetStringUTF8( |
251 GetIdForContentType(kBlockIDs, arraysize(kBlockIDs), content_type())); | 252 GetIdForContentType(kBlockIDs, arraysize(kBlockIDs), content_type())); |
252 | 253 |
253 radio_group.radio_items.push_back(radio_allow_label); | 254 radio_group.radio_items.push_back(radio_allow_label); |
254 radio_group.radio_items.push_back(radio_block_label); | 255 radio_group.radio_items.push_back(radio_block_label); |
255 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); | 256 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); |
256 ContentSetting mostRestrictiveSetting; | 257 CookieSettings* cookie_settings = CookieSettings::GetForProfile(profile()); |
| 258 ContentSetting most_restrictive_setting; |
257 if (resources.empty()) { | 259 if (resources.empty()) { |
258 mostRestrictiveSetting = | 260 most_restrictive_setting = |
259 content_type() == CONTENT_SETTINGS_TYPE_COOKIES ? | 261 content_type() == CONTENT_SETTINGS_TYPE_COOKIES ? |
260 map->GetCookieContentSetting(url, url, true) : | 262 cookie_settings->GetCookieSetting(url, url, true) : |
261 map->GetContentSetting(url, url, content_type(), std::string()); | 263 map->GetContentSetting(url, url, content_type(), std::string()); |
262 } else { | 264 } else { |
263 mostRestrictiveSetting = CONTENT_SETTING_ALLOW; | 265 most_restrictive_setting = CONTENT_SETTING_ALLOW; |
264 for (std::set<std::string>::const_iterator it = resources.begin(); | 266 for (std::set<std::string>::const_iterator it = resources.begin(); |
265 it != resources.end(); ++it) { | 267 it != resources.end(); ++it) { |
266 ContentSetting setting = map->GetContentSetting(url, | 268 ContentSetting setting = map->GetContentSetting(url, |
267 url, | 269 url, |
268 content_type(), | 270 content_type(), |
269 *it); | 271 *it); |
270 if (setting == CONTENT_SETTING_BLOCK) { | 272 if (setting == CONTENT_SETTING_BLOCK) { |
271 mostRestrictiveSetting = CONTENT_SETTING_BLOCK; | 273 most_restrictive_setting = CONTENT_SETTING_BLOCK; |
272 break; | 274 break; |
273 } | 275 } |
274 if (setting == CONTENT_SETTING_ASK) | 276 if (setting == CONTENT_SETTING_ASK) |
275 mostRestrictiveSetting = CONTENT_SETTING_ASK; | 277 most_restrictive_setting = CONTENT_SETTING_ASK; |
276 } | 278 } |
277 } | 279 } |
278 if (mostRestrictiveSetting == CONTENT_SETTING_ALLOW) { | 280 if (most_restrictive_setting == CONTENT_SETTING_ALLOW) { |
279 radio_group.default_item = 0; | 281 radio_group.default_item = 0; |
280 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. | 282 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. |
281 } else { | 283 } else { |
282 radio_group.default_item = 1; | 284 radio_group.default_item = 1; |
283 block_setting_ = mostRestrictiveSetting; | 285 block_setting_ = most_restrictive_setting; |
284 } | 286 } |
285 selected_item_ = radio_group.default_item; | 287 selected_item_ = radio_group.default_item; |
286 set_radio_group(radio_group); | 288 set_radio_group(radio_group); |
287 } | 289 } |
288 | 290 |
289 void AddException(ContentSetting setting, | 291 void AddException(ContentSetting setting, |
290 const std::string& resource_identifier) { | 292 const std::string& resource_identifier) { |
291 if (profile()) { | 293 if (profile()) { |
292 profile()->GetHostContentSettingsMap()->AddExceptionForURL( | 294 profile()->GetHostContentSettingsMap()->AddExceptionForURL( |
293 bubble_content().radio_group.url, | 295 bubble_content().radio_group.url, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 tab_contents_ = NULL; | 555 tab_contents_ = NULL; |
554 break; | 556 break; |
555 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 557 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
556 DCHECK(source == content::Source<Profile>(profile_)); | 558 DCHECK(source == content::Source<Profile>(profile_)); |
557 profile_ = NULL; | 559 profile_ = NULL; |
558 break; | 560 break; |
559 default: | 561 default: |
560 NOTREACHED(); | 562 NOTREACHED(); |
561 } | 563 } |
562 } | 564 } |
OLD | NEW |