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" |
| 11 #include "base/metrics/histogram.h" |
11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
14 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
16 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
17 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
18 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
19 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 20 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
20 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ClearCookieSpecificContentSettings(); | 96 ClearCookieSpecificContentSettings(); |
96 | 97 |
97 observer_.Add(profile_->GetHostContentSettingsMap()); | 98 observer_.Add(profile_->GetHostContentSettingsMap()); |
98 } | 99 } |
99 | 100 |
100 TabSpecificContentSettings::~TabSpecificContentSettings() { | 101 TabSpecificContentSettings::~TabSpecificContentSettings() { |
101 FOR_EACH_OBSERVER( | 102 FOR_EACH_OBSERVER( |
102 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); | 103 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); |
103 } | 104 } |
104 | 105 |
| 106 void TabSpecificContentSettings::RecordMixedScriptAction( |
| 107 MixedScriptAction action) { |
| 108 UMA_HISTOGRAM_ENUMERATION("ContentSettings.MixedScript", |
| 109 action, |
| 110 MIXED_SCRIPT_ACTION_COUNT); |
| 111 } |
| 112 |
105 TabSpecificContentSettings* TabSpecificContentSettings::Get( | 113 TabSpecificContentSettings* TabSpecificContentSettings::Get( |
106 int render_process_id, int render_view_id) { | 114 int render_process_id, int render_view_id) { |
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
108 | 116 |
109 RenderViewHost* view = RenderViewHost::FromID(render_process_id, | 117 RenderViewHost* view = RenderViewHost::FromID(render_process_id, |
110 render_view_id); | 118 render_view_id); |
111 if (!view) | 119 if (!view) |
112 return NULL; | 120 return NULL; |
113 | 121 |
114 WebContents* web_contents = WebContents::FromRenderViewHost(view); | 122 WebContents* web_contents = WebContents::FromRenderViewHost(view); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 325 } |
318 #endif | 326 #endif |
319 | 327 |
320 if (!content_blocked_[type]) { | 328 if (!content_blocked_[type]) { |
321 content_blocked_[type] = true; | 329 content_blocked_[type] = true; |
322 // TODO: it would be nice to have a way of mocking this in tests. | 330 // TODO: it would be nice to have a way of mocking this in tests. |
323 content::NotificationService::current()->Notify( | 331 content::NotificationService::current()->Notify( |
324 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 332 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
325 content::Source<WebContents>(web_contents()), | 333 content::Source<WebContents>(web_contents()), |
326 content::NotificationService::NoDetails()); | 334 content::NotificationService::NoDetails()); |
| 335 |
| 336 if (type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) |
| 337 RecordMixedScriptAction(MIXED_SCRIPT_ACTION_DISPLAYED_SHIELD); |
327 } | 338 } |
328 } | 339 } |
329 | 340 |
330 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { | 341 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { |
331 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 342 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
332 << "Geolocation settings handled by OnGeolocationPermissionSet"; | 343 << "Geolocation settings handled by OnGeolocationPermissionSet"; |
333 DCHECK(type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | 344 DCHECK(type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |
334 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) | 345 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) |
335 << "Media stream settings handled by OnMediaStreamPermissionSet"; | 346 << "Media stream settings handled by OnMediaStreamPermissionSet"; |
336 bool access_changed = false; | 347 bool access_changed = false; |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 } | 778 } |
768 | 779 |
769 void TabSpecificContentSettings::RemoveSiteDataObserver( | 780 void TabSpecificContentSettings::RemoveSiteDataObserver( |
770 SiteDataObserver* observer) { | 781 SiteDataObserver* observer) { |
771 observer_list_.RemoveObserver(observer); | 782 observer_list_.RemoveObserver(observer); |
772 } | 783 } |
773 | 784 |
774 void TabSpecificContentSettings::NotifySiteDataObservers() { | 785 void TabSpecificContentSettings::NotifySiteDataObservers() { |
775 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 786 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
776 } | 787 } |
OLD | NEW |