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_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "chrome/browser/content_settings/content_settings_rule.h" | 15 #include "chrome/browser/content_settings/content_settings_rule.h" |
16 #include "chrome/browser/content_settings/content_settings_utils.h" | 16 #include "chrome/browser/content_settings/content_settings_utils.h" |
17 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
17 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/content_settings.h" | 22 #include "chrome/common/content_settings.h" |
22 #include "chrome/common/content_settings_pattern.h" | 23 #include "chrome/common/content_settings_pattern.h" |
23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 resource_identifier, &setting); | 355 resource_identifier, &setting); |
355 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); | 356 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); |
356 value_map_.SetValue(pattern_pair.first, | 357 value_map_.SetValue(pattern_pair.first, |
357 pattern_pair.second, | 358 pattern_pair.second, |
358 content_type, | 359 content_type, |
359 resource_identifier, | 360 resource_identifier, |
360 Value::CreateIntegerValue(setting)); | 361 Value::CreateIntegerValue(setting)); |
361 } | 362 } |
362 } | 363 } |
363 } | 364 } |
364 int setting = CONTENT_SETTING_DEFAULT; | 365 Value* value = NULL; |
365 if (settings_dictionary->GetIntegerWithoutPathExpansion( | 366 if (HostContentSettingsMap::ContentTypeHasCompoundValue(content_type)) { |
366 GetTypeName(ContentSettingsType(i)), &setting)) { | 367 DictionaryValue* setting = NULL; |
no longer working on chromium
2012/06/20 17:24:38
To joaodasilva: Thanks for pointing out, I was not
| |
367 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); | 368 // TODO(xians): Handle the non-dictionary types. |
368 setting = FixObsoleteCookiePromptMode(content_type, | 369 if (settings_dictionary->GetDictionaryWithoutPathExpansion( |
369 ContentSetting(setting)); | 370 GetTypeName(ContentSettingsType(i)), &setting)) { |
371 DCHECK(!setting->empty()); | |
no longer working on chromium
2012/06/20 17:24:38
To bauerb: I am a bit not sure if we should allow
Bernhard Bauer
2012/06/20 18:33:27
That's fine with me, my point was that we should d
| |
372 value = setting->DeepCopy(); | |
373 } | |
374 } else { | |
375 int setting = CONTENT_SETTING_DEFAULT; | |
376 if (settings_dictionary->GetIntegerWithoutPathExpansion( | |
377 GetTypeName(ContentSettingsType(i)), &setting)) { | |
378 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting); | |
379 setting = FixObsoleteCookiePromptMode(content_type, | |
380 ContentSetting(setting)); | |
381 value = Value::CreateIntegerValue(setting); | |
382 } | |
383 } | |
384 | |
385 // |value_map_| will take the ownership of |value|. | |
386 if (value != NULL) { | |
370 value_map_.SetValue(pattern_pair.first, | 387 value_map_.SetValue(pattern_pair.first, |
371 pattern_pair.second, | 388 pattern_pair.second, |
372 content_type, | 389 content_type, |
373 ResourceIdentifier(""), | 390 ResourceIdentifier(""), |
374 Value::CreateIntegerValue(setting)); | 391 value); |
375 } | 392 } |
376 } | 393 } |
377 } | 394 } |
378 } | 395 } |
379 | 396 |
380 void PrefProvider::UpdatePatternPairsSettings( | 397 void PrefProvider::UpdatePatternPairsSettings( |
381 const ContentSettingsPattern& primary_pattern, | 398 const ContentSettingsPattern& primary_pattern, |
382 const ContentSettingsPattern& secondary_pattern, | 399 const ContentSettingsPattern& secondary_pattern, |
383 ContentSettingsType content_type, | 400 ContentSettingsType content_type, |
384 const ResourceIdentifier& resource_identifier, | 401 const ResourceIdentifier& resource_identifier, |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 | 700 |
684 void PrefProvider::AssertLockNotHeld() const { | 701 void PrefProvider::AssertLockNotHeld() const { |
685 #if !defined(NDEBUG) | 702 #if !defined(NDEBUG) |
686 // |Lock::Acquire()| will assert if the lock is held by this thread. | 703 // |Lock::Acquire()| will assert if the lock is held by this thread. |
687 lock_.Acquire(); | 704 lock_.Acquire(); |
688 lock_.Release(); | 705 lock_.Release(); |
689 #endif | 706 #endif |
690 } | 707 } |
691 | 708 |
692 } // namespace content_settings | 709 } // namespace content_settings |
OLD | NEW |