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