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