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" |
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/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" |
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #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}, | 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 = |
| 258 profile()->GetHostContentSettingsMap()->GetCookieSettings(); |
| 259 ContentSetting most_restrictive_setting; |
257 if (resources.empty()) { | 260 if (resources.empty()) { |
258 mostRestrictiveSetting = | 261 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) { |
259 content_type() == CONTENT_SETTINGS_TYPE_COOKIES ? | 262 if (cookie_settings->IsCookieAllowed(url, url, true)) { |
260 map->GetCookieContentSetting(url, url, true) : | 263 if (cookie_settings->IsCookieSessionOnly(url)) |
261 map->GetContentSetting(url, url, content_type(), std::string()); | 264 most_restrictive_setting = CONTENT_SETTING_SESSION_ONLY; |
| 265 else |
| 266 most_restrictive_setting = CONTENT_SETTING_ALLOW; |
| 267 } else { |
| 268 most_restrictive_setting = CONTENT_SETTING_BLOCK; |
| 269 } |
| 270 } else { |
| 271 most_restrictive_setting = |
| 272 map->GetContentSetting(url, url, content_type(), std::string()); |
| 273 } |
262 } else { | 274 } else { |
263 mostRestrictiveSetting = CONTENT_SETTING_ALLOW; | 275 most_restrictive_setting = CONTENT_SETTING_ALLOW; |
264 for (std::set<std::string>::const_iterator it = resources.begin(); | 276 for (std::set<std::string>::const_iterator it = resources.begin(); |
265 it != resources.end(); ++it) { | 277 it != resources.end(); ++it) { |
266 ContentSetting setting = map->GetContentSetting(url, | 278 ContentSetting setting = map->GetContentSetting(url, |
267 url, | 279 url, |
268 content_type(), | 280 content_type(), |
269 *it); | 281 *it); |
270 if (setting == CONTENT_SETTING_BLOCK) { | 282 if (setting == CONTENT_SETTING_BLOCK) { |
271 mostRestrictiveSetting = CONTENT_SETTING_BLOCK; | 283 most_restrictive_setting = CONTENT_SETTING_BLOCK; |
272 break; | 284 break; |
273 } | 285 } |
274 if (setting == CONTENT_SETTING_ASK) | 286 if (setting == CONTENT_SETTING_ASK) |
275 mostRestrictiveSetting = CONTENT_SETTING_ASK; | 287 most_restrictive_setting = CONTENT_SETTING_ASK; |
276 } | 288 } |
277 } | 289 } |
278 if (mostRestrictiveSetting == CONTENT_SETTING_ALLOW) { | 290 if (most_restrictive_setting == CONTENT_SETTING_ALLOW) { |
279 radio_group.default_item = 0; | 291 radio_group.default_item = 0; |
280 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. | 292 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. |
281 } else { | 293 } else { |
282 radio_group.default_item = 1; | 294 radio_group.default_item = 1; |
283 block_setting_ = mostRestrictiveSetting; | 295 block_setting_ = most_restrictive_setting; |
284 } | 296 } |
285 selected_item_ = radio_group.default_item; | 297 selected_item_ = radio_group.default_item; |
286 set_radio_group(radio_group); | 298 set_radio_group(radio_group); |
287 } | 299 } |
288 | 300 |
289 void AddException(ContentSetting setting, | 301 void AddException(ContentSetting setting, |
290 const std::string& resource_identifier) { | 302 const std::string& resource_identifier) { |
291 if (profile()) { | 303 if (profile()) { |
292 profile()->GetHostContentSettingsMap()->AddExceptionForURL( | 304 profile()->GetHostContentSettingsMap()->AddExceptionForURL( |
293 bubble_content().radio_group.url, | 305 bubble_content().radio_group.url, |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 tab_contents_ = NULL; | 561 tab_contents_ = NULL; |
550 break; | 562 break; |
551 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 563 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
552 DCHECK(source == Source<Profile>(profile_)); | 564 DCHECK(source == Source<Profile>(profile_)); |
553 profile_ = NULL; | 565 profile_ = NULL; |
554 break; | 566 break; |
555 default: | 567 default: |
556 NOTREACHED(); | 568 NOTREACHED(); |
557 } | 569 } |
558 } | 570 } |
OLD | NEW |