Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/settings_private/prefs_util.h" | 5 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/extensions/chrome_extension_function.h" | 9 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 10 #include "chrome/browser/extensions/settings_api_helpers.h" | 10 #include "chrome/browser/extensions/settings_api_helpers.h" |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 | 536 |
| 537 PrefService* pref_service = FindServiceForPref(pref_name); | 537 PrefService* pref_service = FindServiceForPref(pref_name); |
| 538 | 538 |
| 539 if (!IsPrefUserModifiable(pref_name)) | 539 if (!IsPrefUserModifiable(pref_name)) |
| 540 return PREF_NOT_MODIFIABLE; | 540 return PREF_NOT_MODIFIABLE; |
| 541 | 541 |
| 542 const PrefService::Preference* pref = pref_service->FindPreference(pref_name); | 542 const PrefService::Preference* pref = pref_service->FindPreference(pref_name); |
| 543 if (!pref) | 543 if (!pref) |
| 544 return PREF_NOT_FOUND; | 544 return PREF_NOT_FOUND; |
| 545 | 545 |
| 546 DCHECK_EQ(pref->GetType(), value->GetType()); | |
|
stevenjb
2017/05/12 18:49:32
I ran into this when testing. This DCHECK is bogus
afakhry
2017/05/12 19:12:13
Yes, that's the DCHECK that was causing me grief.
| |
| 547 | |
| 548 switch (pref->GetType()) { | 546 switch (pref->GetType()) { |
| 549 case base::Value::Type::BOOLEAN: | 547 case base::Value::Type::BOOLEAN: |
| 550 case base::Value::Type::DOUBLE: | 548 case base::Value::Type::DOUBLE: |
| 551 case base::Value::Type::LIST: | 549 case base::Value::Type::LIST: |
| 552 case base::Value::Type::DICTIONARY: | 550 case base::Value::Type::DICTIONARY: |
| 553 pref_service->Set(pref_name, *value); | 551 pref_service->Set(pref_name, *value); |
| 554 break; | 552 break; |
| 555 case base::Value::Type::INTEGER: { | 553 case base::Value::Type::INTEGER: { |
| 556 // In JS all numbers are doubles. | 554 // In JS all numbers are doubles. |
| 557 double double_value; | 555 double double_value; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) | 769 ExtensionPrefValueMapFactory::GetForBrowserContext(profile_) |
| 772 ->GetExtensionControllingPref(pref_object.key); | 770 ->GetExtensionControllingPref(pref_object.key); |
| 773 if (extension_id.empty()) | 771 if (extension_id.empty()) |
| 774 return nullptr; | 772 return nullptr; |
| 775 | 773 |
| 776 return ExtensionRegistry::Get(profile_)->GetExtensionById( | 774 return ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 777 extension_id, ExtensionRegistry::ENABLED); | 775 extension_id, ExtensionRegistry::ENABLED); |
| 778 } | 776 } |
| 779 | 777 |
| 780 } // namespace extensions | 778 } // namespace extensions |
| OLD | NEW |