| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/preference/chrome_direct_setting.h" | 5 #include "chrome/browser/extensions/api/preference/chrome_direct_setting.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key)); | 32 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key)); |
| 33 EXTENSION_FUNCTION_VALIDATE(ChromeDirectSettingAPI::Get(browser_context()) | 33 EXTENSION_FUNCTION_VALIDATE(ChromeDirectSettingAPI::Get(browser_context()) |
| 34 ->IsPreferenceOnWhitelist(pref_key)); | 34 ->IsPreferenceOnWhitelist(pref_key)); |
| 35 | 35 |
| 36 const PrefService::Preference* preference = | 36 const PrefService::Preference* preference = |
| 37 GetPrefService()->FindPreference(pref_key.c_str()); | 37 GetPrefService()->FindPreference(pref_key.c_str()); |
| 38 EXTENSION_FUNCTION_VALIDATE(preference); | 38 EXTENSION_FUNCTION_VALIDATE(preference); |
| 39 const base::Value* value = preference->GetValue(); | 39 const base::Value* value = preference->GetValue(); |
| 40 | 40 |
| 41 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 41 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
| 42 result->Set(preference_api_constants::kValue, value->DeepCopy()); | 42 result->Set(preference_api_constants::kValue, value->CreateDeepCopy()); |
| 43 return RespondNow(OneArgument(std::move(result))); | 43 return RespondNow(OneArgument(std::move(result))); |
| 44 } | 44 } |
| 45 | 45 |
| 46 GetDirectSettingFunction::~GetDirectSettingFunction() {} | 46 GetDirectSettingFunction::~GetDirectSettingFunction() {} |
| 47 | 47 |
| 48 SetDirectSettingFunction::SetDirectSettingFunction() {} | 48 SetDirectSettingFunction::SetDirectSettingFunction() {} |
| 49 | 49 |
| 50 ExtensionFunction::ResponseAction SetDirectSettingFunction::Run() { | 50 ExtensionFunction::ResponseAction SetDirectSettingFunction::Run() { |
| 51 std::string pref_key; | 51 std::string pref_key; |
| 52 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key)); | 52 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &pref_key)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 GetPrefService()->ClearPref(pref_key.c_str()); | 84 GetPrefService()->ClearPref(pref_key.c_str()); |
| 85 | 85 |
| 86 return RespondNow(NoArguments()); | 86 return RespondNow(NoArguments()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 ClearDirectSettingFunction::~ClearDirectSettingFunction() {} | 89 ClearDirectSettingFunction::~ClearDirectSettingFunction() {} |
| 90 | 90 |
| 91 } // namespace chromedirectsetting | 91 } // namespace chromedirectsetting |
| 92 } // namespace extensions | 92 } // namespace extensions |
| 93 | 93 |
| OLD | NEW |