| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 198 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
| 199 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | 199 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) |
| 200 << "Notifications settings handled by " | 200 << "Notifications settings handled by " |
| 201 << "ContentSettingsNotificationsImageModel"; | 201 << "ContentSettingsNotificationsImageModel"; |
| 202 | 202 |
| 203 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 203 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 204 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 204 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 205 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || | 205 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || |
| 206 content_type == CONTENT_SETTINGS_TYPE_COOKIES || | 206 content_type == CONTENT_SETTINGS_TYPE_COOKIES || |
| 207 content_type == CONTENT_SETTINGS_TYPE_POPUPS || | 207 content_type == CONTENT_SETTINGS_TYPE_POPUPS || |
| 208 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) | 208 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || |
| 209 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER) |
| 209 return content_blocked_[content_type]; | 210 return content_blocked_[content_type]; |
| 210 | 211 |
| 211 return false; | 212 return false; |
| 212 } | 213 } |
| 213 | 214 |
| 214 bool TabSpecificContentSettings::IsBlockageIndicated( | 215 bool TabSpecificContentSettings::IsBlockageIndicated( |
| 215 ContentSettingsType content_type) const { | 216 ContentSettingsType content_type) const { |
| 216 return content_blockage_indicated_to_user_[content_type]; | 217 return content_blockage_indicated_to_user_[content_type]; |
| 217 } | 218 } |
| 218 | 219 |
| 219 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( | 220 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( |
| 220 ContentSettingsType content_type) { | 221 ContentSettingsType content_type) { |
| 221 content_blockage_indicated_to_user_[content_type] = true; | 222 content_blockage_indicated_to_user_[content_type] = true; |
| 222 } | 223 } |
| 223 | 224 |
| 224 bool TabSpecificContentSettings::IsContentAccessed( | 225 bool TabSpecificContentSettings::IsContentAccessed( |
| 225 ContentSettingsType content_type) const { | 226 ContentSettingsType content_type) const { |
| 226 // This method currently only returns meaningful values for cookies. | 227 // This method currently only returns meaningful values for cookies |
| 227 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES) | 228 /// and PPAPI broker. |
| 229 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && |
| 230 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER) { |
| 228 return false; | 231 return false; |
| 232 } |
| 229 | 233 |
| 230 return content_accessed_[content_type]; | 234 return content_accessed_[content_type]; |
| 231 } | 235 } |
| 232 | 236 |
| 233 const std::set<std::string>& | 237 const std::set<std::string>& |
| 234 TabSpecificContentSettings::BlockedResourcesForType( | 238 TabSpecificContentSettings::BlockedResourcesForType( |
| 235 ContentSettingsType content_type) const { | 239 ContentSettingsType content_type) const { |
| 236 if (blocked_resources_[content_type].get()) { | 240 if (blocked_resources_[content_type].get()) { |
| 237 return *blocked_resources_[content_type]; | 241 return *blocked_resources_[content_type]; |
| 238 } else { | 242 } else { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 462 |
| 459 void TabSpecificContentSettings::GeolocationDidNavigate( | 463 void TabSpecificContentSettings::GeolocationDidNavigate( |
| 460 const content::LoadCommittedDetails& details) { | 464 const content::LoadCommittedDetails& details) { |
| 461 geolocation_settings_state_.DidNavigate(details); | 465 geolocation_settings_state_.DidNavigate(details); |
| 462 } | 466 } |
| 463 | 467 |
| 464 void TabSpecificContentSettings::ClearGeolocationContentSettings() { | 468 void TabSpecificContentSettings::ClearGeolocationContentSettings() { |
| 465 geolocation_settings_state_.ClearStateMap(); | 469 geolocation_settings_state_.ClearStateMap(); |
| 466 } | 470 } |
| 467 | 471 |
| 472 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { |
| 473 if (allowed) { |
| 474 OnContentAccessed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |
| 475 } else { |
| 476 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string()); |
| 477 } |
| 478 } |
| 479 |
| 468 void TabSpecificContentSettings::RenderViewForInterstitialPageCreated( | 480 void TabSpecificContentSettings::RenderViewForInterstitialPageCreated( |
| 469 RenderViewHost* render_view_host) { | 481 RenderViewHost* render_view_host) { |
| 470 // We want to tell the renderer-side code to ignore content settings for this | 482 // We want to tell the renderer-side code to ignore content settings for this |
| 471 // page but we must wait until the RenderView is created. | 483 // page but we must wait until the RenderView is created. |
| 472 new InterstitialHostObserver(render_view_host); | 484 new InterstitialHostObserver(render_view_host); |
| 473 } | 485 } |
| 474 | 486 |
| 475 bool TabSpecificContentSettings::OnMessageReceived( | 487 bool TabSpecificContentSettings::OnMessageReceived( |
| 476 const IPC::Message& message) { | 488 const IPC::Message& message) { |
| 477 bool handled = true; | 489 bool handled = true; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 564 } |
| 553 | 565 |
| 554 void TabSpecificContentSettings::RemoveSiteDataObserver( | 566 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 555 SiteDataObserver* observer) { | 567 SiteDataObserver* observer) { |
| 556 observer_list_.RemoveObserver(observer); | 568 observer_list_.RemoveObserver(observer); |
| 557 } | 569 } |
| 558 | 570 |
| 559 void TabSpecificContentSettings::NotifySiteDataObservers() { | 571 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 560 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 572 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 561 } | 573 } |
| OLD | NEW |