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/content_settings_default_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_default_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | |
vabr (Chromium)
2014/09/23 07:51:00
Why did you include this?
(Also in other files.)
Jun Mukai
2014/09/23 20:48:44
Bind is used below (line 173 in this file). It wa
vabr (Chromium)
2014/09/24 09:56:39
Thanks for explanation, makes sense.
| |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
14 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
15 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
16 #include "chrome/browser/chrome_notification_types.h" | |
17 #include "chrome/browser/content_settings/content_settings_utils.h" | 17 #include "chrome/browser/content_settings/content_settings_utils.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "components/content_settings/core/browser/content_settings_rule.h" | 19 #include "components/content_settings/core/browser/content_settings_rule.h" |
20 #include "components/content_settings/core/common/content_settings.h" | 20 #include "components/content_settings/core/common/content_settings.h" |
21 #include "components/content_settings/core/common/content_settings_pattern.h" | 21 #include "components/content_settings/core/common/content_settings_pattern.h" |
22 #include "components/pref_registry/pref_registry_syncable.h" | 22 #include "components/pref_registry/pref_registry_syncable.h" |
23 #include "content/public/browser/browser_thread.h" | |
24 #include "content/public/browser/notification_details.h" | |
25 #include "content/public/browser/notification_source.h" | |
26 #include "content/public/browser/user_metrics.h" | |
27 #include "url/gurl.h" | 23 #include "url/gurl.h" |
28 | 24 |
29 using base::UserMetricsAction; | |
30 using content::BrowserThread; | |
31 | |
32 namespace { | 25 namespace { |
33 | 26 |
34 // The default setting for each content type. | 27 // The default setting for each content type. |
35 const ContentSetting kDefaultSettings[] = { | 28 const ContentSetting kDefaultSettings[] = { |
36 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES | 29 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES |
37 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES | 30 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES |
38 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT | 31 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT |
39 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS | 32 CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS |
40 CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS | 33 CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS |
41 CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_GEOLOCATION | 34 CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_GEOLOCATION |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 177 |
185 DefaultProvider::~DefaultProvider() { | 178 DefaultProvider::~DefaultProvider() { |
186 } | 179 } |
187 | 180 |
188 bool DefaultProvider::SetWebsiteSetting( | 181 bool DefaultProvider::SetWebsiteSetting( |
189 const ContentSettingsPattern& primary_pattern, | 182 const ContentSettingsPattern& primary_pattern, |
190 const ContentSettingsPattern& secondary_pattern, | 183 const ContentSettingsPattern& secondary_pattern, |
191 ContentSettingsType content_type, | 184 ContentSettingsType content_type, |
192 const ResourceIdentifier& resource_identifier, | 185 const ResourceIdentifier& resource_identifier, |
193 base::Value* in_value) { | 186 base::Value* in_value) { |
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 187 DCHECK(CalledOnValidThread()); |
195 DCHECK(prefs_); | 188 DCHECK(prefs_); |
196 | 189 |
197 // Ignore non default settings | 190 // Ignore non default settings |
198 if (primary_pattern != ContentSettingsPattern::Wildcard() || | 191 if (primary_pattern != ContentSettingsPattern::Wildcard() || |
199 secondary_pattern != ContentSettingsPattern::Wildcard()) { | 192 secondary_pattern != ContentSettingsPattern::Wildcard()) { |
200 return false; | 193 return false; |
201 } | 194 } |
202 | 195 |
203 // The default settings may not be directly modified for OTR sessions. | 196 // The default settings may not be directly modified for OTR sessions. |
204 // Instead, they are synced to the main profile's setting. | 197 // Instead, they are synced to the main profile's setting. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 | 256 |
264 void DefaultProvider::ClearAllContentSettingsRules( | 257 void DefaultProvider::ClearAllContentSettingsRules( |
265 ContentSettingsType content_type) { | 258 ContentSettingsType content_type) { |
266 // TODO(markusheintz): This method is only called when the | 259 // TODO(markusheintz): This method is only called when the |
267 // |DesktopNotificationService| calls |ClearAllSettingsForType| method on the | 260 // |DesktopNotificationService| calls |ClearAllSettingsForType| method on the |
268 // |HostContentSettingsMap|. Don't implement this method yet, otherwise the | 261 // |HostContentSettingsMap|. Don't implement this method yet, otherwise the |
269 // default notification settings will be cleared as well. | 262 // default notification settings will be cleared as well. |
270 } | 263 } |
271 | 264 |
272 void DefaultProvider::ShutdownOnUIThread() { | 265 void DefaultProvider::ShutdownOnUIThread() { |
273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 266 DCHECK(CalledOnValidThread()); |
274 DCHECK(prefs_); | 267 DCHECK(prefs_); |
275 RemoveAllObservers(); | 268 RemoveAllObservers(); |
276 pref_change_registrar_.RemoveAll(); | 269 pref_change_registrar_.RemoveAll(); |
277 prefs_ = NULL; | 270 prefs_ = NULL; |
278 } | 271 } |
279 | 272 |
280 void DefaultProvider::OnPreferenceChanged(const std::string& name) { | 273 void DefaultProvider::OnPreferenceChanged(const std::string& name) { |
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 274 DCHECK(CalledOnValidThread()); |
282 if (updating_preferences_) | 275 if (updating_preferences_) |
283 return; | 276 return; |
284 | 277 |
285 if (name == prefs::kDefaultContentSettings) { | 278 if (name == prefs::kDefaultContentSettings) { |
286 ReadDefaultSettings(true); | 279 ReadDefaultSettings(true); |
287 } else { | 280 } else { |
288 NOTREACHED() << "Unexpected preference observed"; | 281 NOTREACHED() << "Unexpected preference observed"; |
289 return; | 282 return; |
290 } | 283 } |
291 | 284 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 // Migrate obsolete cookie prompt mode. | 333 // Migrate obsolete cookie prompt mode. |
341 if (ValueToContentSetting( | 334 if (ValueToContentSetting( |
342 default_settings_[CONTENT_SETTINGS_TYPE_COOKIES].get()) == | 335 default_settings_[CONTENT_SETTINGS_TYPE_COOKIES].get()) == |
343 CONTENT_SETTING_ASK) { | 336 CONTENT_SETTING_ASK) { |
344 default_settings_[CONTENT_SETTINGS_TYPE_COOKIES].reset( | 337 default_settings_[CONTENT_SETTINGS_TYPE_COOKIES].reset( |
345 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); | 338 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); |
346 } | 339 } |
347 } | 340 } |
348 | 341 |
349 } // namespace content_settings | 342 } // namespace content_settings |
OLD | NEW |