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/settings_private_api.h" | 5 #include "chrome/browser/extensions/api/settings_private/settings_private_api.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/api/settings_private/settings_private_delega
te.h" | 8 #include "chrome/browser/extensions/api/settings_private/settings_private_delega
te.h" |
9 #include "chrome/browser/extensions/api/settings_private/settings_private_delega
te_factory.h" | 9 #include "chrome/browser/extensions/api/settings_private/settings_private_delega
te_factory.h" |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
24 // SettingsPrivateSetPrefFunction | 24 // SettingsPrivateSetPrefFunction |
25 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
26 | 26 |
27 SettingsPrivateSetPrefFunction::~SettingsPrivateSetPrefFunction() { | 27 SettingsPrivateSetPrefFunction::~SettingsPrivateSetPrefFunction() { |
28 } | 28 } |
29 | 29 |
30 ExtensionFunction::ResponseAction SettingsPrivateSetPrefFunction::Run() { | 30 ExtensionFunction::ResponseAction SettingsPrivateSetPrefFunction::Run() { |
31 scoped_ptr<api::settings_private::SetPref::Params> parameters = | 31 std::unique_ptr<api::settings_private::SetPref::Params> parameters = |
32 api::settings_private::SetPref::Params::Create(*args_); | 32 api::settings_private::SetPref::Params::Create(*args_); |
33 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 33 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
34 | 34 |
35 SettingsPrivateDelegate* delegate = | 35 SettingsPrivateDelegate* delegate = |
36 SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 36 SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context()); |
37 if (delegate == nullptr) | 37 if (delegate == nullptr) |
38 return RespondNow(Error(kDelegateIsNull)); | 38 return RespondNow(Error(kDelegateIsNull)); |
39 | 39 |
40 PrefsUtil::SetPrefResult result = | 40 PrefsUtil::SetPrefResult result = |
41 delegate->SetPref(parameters->name, parameters->value.get()); | 41 delegate->SetPref(parameters->name, parameters->value.get()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
79 // SettingsPrivateGetPrefFunction | 79 // SettingsPrivateGetPrefFunction |
80 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
81 | 81 |
82 SettingsPrivateGetPrefFunction::~SettingsPrivateGetPrefFunction() { | 82 SettingsPrivateGetPrefFunction::~SettingsPrivateGetPrefFunction() { |
83 } | 83 } |
84 | 84 |
85 ExtensionFunction::ResponseAction SettingsPrivateGetPrefFunction::Run() { | 85 ExtensionFunction::ResponseAction SettingsPrivateGetPrefFunction::Run() { |
86 scoped_ptr<api::settings_private::GetPref::Params> parameters = | 86 std::unique_ptr<api::settings_private::GetPref::Params> parameters = |
87 api::settings_private::GetPref::Params::Create(*args_); | 87 api::settings_private::GetPref::Params::Create(*args_); |
88 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 88 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
89 | 89 |
90 SettingsPrivateDelegate* delegate = | 90 SettingsPrivateDelegate* delegate = |
91 SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 91 SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context()); |
92 if (delegate == nullptr) | 92 if (delegate == nullptr) |
93 return RespondNow(Error(kDelegateIsNull)); | 93 return RespondNow(Error(kDelegateIsNull)); |
94 | 94 |
95 scoped_ptr<base::Value> value = delegate->GetPref(parameters->name); | 95 std::unique_ptr<base::Value> value = delegate->GetPref(parameters->name); |
96 if (value->IsType(base::Value::TYPE_NULL)) | 96 if (value->IsType(base::Value::TYPE_NULL)) |
97 return RespondNow(Error("Pref * does not exist", parameters->name)); | 97 return RespondNow(Error("Pref * does not exist", parameters->name)); |
98 else | 98 else |
99 return RespondNow(OneArgument(value.release())); | 99 return RespondNow(OneArgument(value.release())); |
100 } | 100 } |
101 | 101 |
102 //////////////////////////////////////////////////////////////////////////////// | 102 //////////////////////////////////////////////////////////////////////////////// |
103 // SettingsPrivateGetDefaultZoomPercentFunction | 103 // SettingsPrivateGetDefaultZoomPercentFunction |
104 //////////////////////////////////////////////////////////////////////////////// | 104 //////////////////////////////////////////////////////////////////////////////// |
105 | 105 |
(...skipping 15 matching lines...) Expand all Loading... |
121 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
122 // SettingsPrivateSetDefaultZoomPercentFunction | 122 // SettingsPrivateSetDefaultZoomPercentFunction |
123 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
124 | 124 |
125 SettingsPrivateSetDefaultZoomPercentFunction:: | 125 SettingsPrivateSetDefaultZoomPercentFunction:: |
126 ~SettingsPrivateSetDefaultZoomPercentFunction() { | 126 ~SettingsPrivateSetDefaultZoomPercentFunction() { |
127 } | 127 } |
128 | 128 |
129 ExtensionFunction::ResponseAction | 129 ExtensionFunction::ResponseAction |
130 SettingsPrivateSetDefaultZoomPercentFunction::Run() { | 130 SettingsPrivateSetDefaultZoomPercentFunction::Run() { |
131 scoped_ptr<api::settings_private::SetDefaultZoomPercent::Params> parameters = | 131 std::unique_ptr<api::settings_private::SetDefaultZoomPercent::Params> |
132 api::settings_private::SetDefaultZoomPercent::Params::Create(*args_); | 132 parameters = |
| 133 api::settings_private::SetDefaultZoomPercent::Params::Create(*args_); |
133 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 134 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
134 | 135 |
135 SettingsPrivateDelegate* delegate = | 136 SettingsPrivateDelegate* delegate = |
136 SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 137 SettingsPrivateDelegateFactory::GetForBrowserContext(browser_context()); |
137 if (delegate == nullptr) | 138 if (delegate == nullptr) |
138 return RespondNow(Error(kDelegateIsNull)); | 139 return RespondNow(Error(kDelegateIsNull)); |
139 | 140 |
140 delegate->SetDefaultZoomPercent(parameters->percent); | 141 delegate->SetDefaultZoomPercent(parameters->percent); |
141 return RespondNow(OneArgument(new base::FundamentalValue(true))); | 142 return RespondNow(OneArgument(new base::FundamentalValue(true))); |
142 } | 143 } |
143 | 144 |
144 } // namespace extensions | 145 } // namespace extensions |
OLD | NEW |