| 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/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 : settings_private::PrefType::PREF_TYPE_STRING; | 285 : settings_private::PrefType::PREF_TYPE_STRING; |
| 286 case base::Value::Type::TYPE_LIST: | 286 case base::Value::Type::TYPE_LIST: |
| 287 return settings_private::PrefType::PREF_TYPE_LIST; | 287 return settings_private::PrefType::PREF_TYPE_LIST; |
| 288 case base::Value::Type::TYPE_DICTIONARY: | 288 case base::Value::Type::TYPE_DICTIONARY: |
| 289 return settings_private::PrefType::PREF_TYPE_DICTIONARY; | 289 return settings_private::PrefType::PREF_TYPE_DICTIONARY; |
| 290 default: | 290 default: |
| 291 return settings_private::PrefType::PREF_TYPE_NONE; | 291 return settings_private::PrefType::PREF_TYPE_NONE; |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 scoped_ptr<settings_private::PrefObject> PrefsUtil::GetCrosSettingsPref( | 295 std::unique_ptr<settings_private::PrefObject> PrefsUtil::GetCrosSettingsPref( |
| 296 const std::string& name) { | 296 const std::string& name) { |
| 297 scoped_ptr<settings_private::PrefObject> pref_object( | 297 std::unique_ptr<settings_private::PrefObject> pref_object( |
| 298 new settings_private::PrefObject()); | 298 new settings_private::PrefObject()); |
| 299 | 299 |
| 300 #if defined(OS_CHROMEOS) | 300 #if defined(OS_CHROMEOS) |
| 301 const base::Value* value = CrosSettings::Get()->GetPref(name); | 301 const base::Value* value = CrosSettings::Get()->GetPref(name); |
| 302 DCHECK(value); | 302 DCHECK(value); |
| 303 pref_object->key = name; | 303 pref_object->key = name; |
| 304 pref_object->type = GetType(name, value->GetType()); | 304 pref_object->type = GetType(name, value->GetType()); |
| 305 pref_object->value.reset(value->DeepCopy()); | 305 pref_object->value.reset(value->DeepCopy()); |
| 306 #endif | 306 #endif |
| 307 | 307 |
| 308 return pref_object; | 308 return pref_object; |
| 309 } | 309 } |
| 310 | 310 |
| 311 scoped_ptr<settings_private::PrefObject> PrefsUtil::GetPref( | 311 std::unique_ptr<settings_private::PrefObject> PrefsUtil::GetPref( |
| 312 const std::string& name) { | 312 const std::string& name) { |
| 313 const PrefService::Preference* pref = nullptr; | 313 const PrefService::Preference* pref = nullptr; |
| 314 scoped_ptr<settings_private::PrefObject> pref_object; | 314 std::unique_ptr<settings_private::PrefObject> pref_object; |
| 315 if (IsCrosSetting(name)) { | 315 if (IsCrosSetting(name)) { |
| 316 pref_object = GetCrosSettingsPref(name); | 316 pref_object = GetCrosSettingsPref(name); |
| 317 } else { | 317 } else { |
| 318 PrefService* pref_service = FindServiceForPref(name); | 318 PrefService* pref_service = FindServiceForPref(name); |
| 319 pref = pref_service->FindPreference(name); | 319 pref = pref_service->FindPreference(name); |
| 320 if (!pref) | 320 if (!pref) |
| 321 return nullptr; | 321 return nullptr; |
| 322 pref_object.reset(new settings_private::PrefObject()); | 322 pref_object.reset(new settings_private::PrefObject()); |
| 323 pref_object->key = pref->name(); | 323 pref_object->key = pref->name(); |
| 324 pref_object->type = GetType(name, pref->GetType()); | 324 pref_object->type = GetType(name, pref->GetType()); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { | 616 bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { |
| 617 #if defined(OS_CHROMEOS) | 617 #if defined(OS_CHROMEOS) |
| 618 return CrosSettings::Get()->IsCrosSettings(pref_name); | 618 return CrosSettings::Get()->IsCrosSettings(pref_name); |
| 619 #else | 619 #else |
| 620 return false; | 620 return false; |
| 621 #endif | 621 #endif |
| 622 } | 622 } |
| 623 | 623 |
| 624 } // namespace extensions | 624 } // namespace extensions |
| OLD | NEW |