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) |
210 return content_blocked_[content_type]; | 211 return content_blocked_[content_type]; |
211 | 212 |
212 return false; | 213 return false; |
213 } | 214 } |
214 | 215 |
215 bool TabSpecificContentSettings::IsBlockageIndicated( | 216 bool TabSpecificContentSettings::IsBlockageIndicated( |
216 ContentSettingsType content_type) const { | 217 ContentSettingsType content_type) const { |
217 return content_blockage_indicated_to_user_[content_type]; | 218 return content_blockage_indicated_to_user_[content_type]; |
218 } | 219 } |
219 | 220 |
220 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( | 221 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( |
221 ContentSettingsType content_type) { | 222 ContentSettingsType content_type) { |
222 content_blockage_indicated_to_user_[content_type] = true; | 223 content_blockage_indicated_to_user_[content_type] = true; |
223 } | 224 } |
224 | 225 |
225 bool TabSpecificContentSettings::IsContentAccessed( | 226 bool TabSpecificContentSettings::IsContentAccessed( |
226 ContentSettingsType content_type) const { | 227 ContentSettingsType content_type) const { |
227 // This method currently only returns meaningful values for cookies. | 228 // This method currently only returns meaningful values for the content type |
228 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES) | 229 // cookies and mediastream. |
| 230 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && |
| 231 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM) |
229 return false; | 232 return false; |
230 | 233 |
231 return content_accessed_[content_type]; | 234 return content_accessed_[content_type]; |
232 } | 235 } |
233 | 236 |
234 const std::set<std::string>& | 237 const std::set<std::string>& |
235 TabSpecificContentSettings::BlockedResourcesForType( | 238 TabSpecificContentSettings::BlockedResourcesForType( |
236 ContentSettingsType content_type) const { | 239 ContentSettingsType content_type) const { |
237 if (blocked_resources_[content_type].get()) { | 240 if (blocked_resources_[content_type].get()) { |
238 return *blocked_resources_[content_type]; | 241 return *blocked_resources_[content_type]; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 const GURL& requesting_origin, | 418 const GURL& requesting_origin, |
416 bool allowed) { | 419 bool allowed) { |
417 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, | 420 geolocation_settings_state_.OnGeolocationPermissionSet(requesting_origin, |
418 allowed); | 421 allowed); |
419 content::NotificationService::current()->Notify( | 422 content::NotificationService::current()->Notify( |
420 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 423 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
421 content::Source<WebContents>(web_contents()), | 424 content::Source<WebContents>(web_contents()), |
422 content::NotificationService::NoDetails()); | 425 content::NotificationService::NoDetails()); |
423 } | 426 } |
424 | 427 |
| 428 void TabSpecificContentSettings::OnMediaStreamAccessed() { |
| 429 OnContentAccessed(CONTENT_SETTINGS_TYPE_MEDIASTREAM); |
| 430 } |
| 431 |
425 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { | 432 void TabSpecificContentSettings::ClearBlockedContentSettingsExceptForCookies() { |
426 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { | 433 for (size_t i = 0; i < arraysize(content_blocked_); ++i) { |
427 if (i == CONTENT_SETTINGS_TYPE_COOKIES) | 434 if (i == CONTENT_SETTINGS_TYPE_COOKIES) |
428 continue; | 435 continue; |
429 blocked_resources_[i].reset(); | 436 blocked_resources_[i].reset(); |
430 content_blocked_[i] = false; | 437 content_blocked_[i] = false; |
431 content_accessed_[i] = false; | 438 content_accessed_[i] = false; |
432 content_blockage_indicated_to_user_[i] = false; | 439 content_blockage_indicated_to_user_[i] = false; |
433 } | 440 } |
434 load_plugins_link_enabled_ = true; | 441 load_plugins_link_enabled_ = true; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } | 563 } |
557 | 564 |
558 void TabSpecificContentSettings::RemoveSiteDataObserver( | 565 void TabSpecificContentSettings::RemoveSiteDataObserver( |
559 SiteDataObserver* observer) { | 566 SiteDataObserver* observer) { |
560 observer_list_.RemoveObserver(observer); | 567 observer_list_.RemoveObserver(observer); |
561 } | 568 } |
562 | 569 |
563 void TabSpecificContentSettings::NotifySiteDataObservers() { | 570 void TabSpecificContentSettings::NotifySiteDataObservers() { |
564 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 571 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
565 } | 572 } |
OLD | NEW |