| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/content_settings/tab_specific_content_settings.h" | 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 199 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
| 200 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | 200 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) |
| 201 << "Notifications settings handled by " | 201 << "Notifications settings handled by " |
| 202 << "ContentSettingsNotificationsImageModel"; | 202 << "ContentSettingsNotificationsImageModel"; |
| 203 | 203 |
| 204 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 204 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 205 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 205 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 206 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || | 206 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || |
| 207 content_type == CONTENT_SETTINGS_TYPE_COOKIES || | 207 content_type == CONTENT_SETTINGS_TYPE_COOKIES || |
| 208 content_type == CONTENT_SETTINGS_TYPE_POPUPS || | 208 content_type == CONTENT_SETTINGS_TYPE_POPUPS || |
| 209 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || | 209 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) |
| 210 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) | |
| 211 return content_blocked_[content_type]; | 210 return content_blocked_[content_type]; |
| 212 | 211 |
| 213 return false; | 212 return false; |
| 214 } | 213 } |
| 215 | 214 |
| 216 bool TabSpecificContentSettings::IsBlockageIndicated( | 215 bool TabSpecificContentSettings::IsBlockageIndicated( |
| 217 ContentSettingsType content_type) const { | 216 ContentSettingsType content_type) const { |
| 218 return content_blockage_indicated_to_user_[content_type]; | 217 return content_blockage_indicated_to_user_[content_type]; |
| 219 } | 218 } |
| 220 | 219 |
| 221 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( | 220 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( |
| 222 ContentSettingsType content_type) { | 221 ContentSettingsType content_type) { |
| 223 content_blockage_indicated_to_user_[content_type] = true; | 222 content_blockage_indicated_to_user_[content_type] = true; |
| 224 } | 223 } |
| 225 | 224 |
| 226 bool TabSpecificContentSettings::IsContentAccessed( | 225 bool TabSpecificContentSettings::IsContentAccessed( |
| 227 ContentSettingsType content_type) const { | 226 ContentSettingsType content_type) const { |
| 228 // This method currently only returns meaningful values for the content type | 227 // This method currently only returns meaningful values for cookies. |
| 229 // cookies and mediastream. | 228 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES) |
| 230 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && | |
| 231 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) | |
| 232 return false; | 229 return false; |
| 233 | 230 |
| 234 return content_accessed_[content_type]; | 231 return content_accessed_[content_type]; |
| 235 } | 232 } |
| 236 | 233 |
| 237 const std::set<std::string>& | 234 const std::set<std::string>& |
| 238 TabSpecificContentSettings::BlockedResourcesForType( | 235 TabSpecificContentSettings::BlockedResourcesForType( |
| 239 ContentSettingsType content_type) const { | 236 ContentSettingsType content_type) const { |
| 240 if (blocked_resources_[content_type].get()) { | 237 if (blocked_resources_[content_type].get()) { |
| 241 return *blocked_resources_[content_type]; | 238 return *blocked_resources_[content_type]; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 const GURL& requesting_origin, | 415 const GURL& requesting_origin, |
| 419 bool allowed) { | 416 bool allowed) { |
| 420 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, | 417 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, |
| 421 allowed); | 418 allowed); |
| 422 content::NotificationService::current()->Notify( | 419 content::NotificationService::current()->Notify( |
| 423 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 420 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 424 content::Source<WebContents>(web_contents()), | 421 content::Source<WebContents>(web_contents()), |
| 425 content::NotificationService::NoDetails()); | 422 content::NotificationService::NoDetails()); |
| 426 } | 423 } |
| 427 | 424 |
| 428 void TabSpecificContentSettings::OnMediaStreamAccessed() { | |
| 429 OnContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM); | |
| 430 } | |
| 431 | |
| 432 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { | 425 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { |
| 433 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { | 426 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { |
| 434 if (i == CONTENT_SETTINGS_TYPE_COOKIES) | 427 if (i == CONTENT_SETTINGS_TYPE_COOKIES) |
| 435 continue; | 428 continue; |
| 436 blocked_resources_[i].reset(); | 429 blocked_resources_[i].reset(); |
| 437 content_blocked_[i] = false; | 430 content_blocked_[i] = false; |
| 438 content_accessed_[i] = false; | 431 content_accessed_[i] = false; |
| 439 content_blockage_indicated_to_user_[i] = false; | 432 content_blockage_indicated_to_user_[i] = false; |
| 440 } | 433 } |
| 441 load_plugins_link_enabled_ = true; | 434 load_plugins_link_enabled_ = true; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 556 } |
| 564 | 557 |
| 565 void TabSpecificContentSettings::RemoveSiteDataObserver( | 558 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 566 SiteDataObserver* observer) { | 559 SiteDataObserver* observer) { |
| 567 observer_list_.RemoveObserver(observer); | 560 observer_list_.RemoveObserver(observer); |
| 568 } | 561 } |
| 569 | 562 |
| 570 void TabSpecificContentSettings::NotifySiteDataObservers() { | 563 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 571 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 564 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 572 } | 565 } |
| OLD | NEW |