OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/settings/settings_api.h" | 5 #include "chrome/browser/extensions/settings/settings_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/settings/settings_frontend.h" | 10 #include "chrome/browser/extensions/settings/settings_frontend.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 SettingsStorage::ReadResult(kUnsupportedArgumentType)); | 141 SettingsStorage::ReadResult(kUnsupportedArgumentType)); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 bool SetSettingsFunction::RunWithStorage( | 145 bool SetSettingsFunction::RunWithStorage( |
146 scoped_refptr<SettingsObserverList> observers, | 146 scoped_refptr<SettingsObserverList> observers, |
147 SettingsStorage* storage) { | 147 SettingsStorage* storage) { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
149 DictionaryValue *input; | 149 DictionaryValue *input; |
150 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input)); | 150 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input)); |
151 return UseWriteResult(observers, storage->Set(*input)); | 151 return UseWriteResult( |
| 152 observers, storage->Set(SettingsStorage::DEFAULTS, *input)); |
152 } | 153 } |
153 | 154 |
154 bool RemoveSettingsFunction::RunWithStorage( | 155 bool RemoveSettingsFunction::RunWithStorage( |
155 scoped_refptr<SettingsObserverList> observers, | 156 scoped_refptr<SettingsObserverList> observers, |
156 SettingsStorage* storage) { | 157 SettingsStorage* storage) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
158 Value *input; | 159 Value *input; |
159 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); | 160 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &input)); |
160 | 161 |
161 switch (input->GetType()) { | 162 switch (input->GetType()) { |
162 case Value::TYPE_STRING: { | 163 case Value::TYPE_STRING: { |
163 std::string as_string; | 164 std::string as_string; |
164 input->GetAsString(&as_string); | 165 input->GetAsString(&as_string); |
165 return UseWriteResult(observers, storage->Remove(as_string)); | 166 return UseWriteResult( |
| 167 observers, storage->Remove(SettingsStorage::DEFAULTS, as_string)); |
166 } | 168 } |
167 | 169 |
168 case Value::TYPE_LIST: { | 170 case Value::TYPE_LIST: { |
169 std::vector<std::string> as_string_list; | 171 std::vector<std::string> as_string_list; |
170 AddAllStringValues(*static_cast<ListValue*>(input), &as_string_list); | 172 AddAllStringValues(*static_cast<ListValue*>(input), &as_string_list); |
171 return UseWriteResult(observers, storage->Remove(as_string_list)); | 173 return UseWriteResult( |
| 174 observers, |
| 175 storage->Remove(SettingsStorage::DEFAULTS, as_string_list)); |
172 } | 176 } |
173 | 177 |
174 default: | 178 default: |
175 return UseWriteResult( | 179 return UseWriteResult( |
176 observers, | 180 observers, |
177 SettingsStorage::WriteResult(kUnsupportedArgumentType)); | 181 SettingsStorage::WriteResult(kUnsupportedArgumentType)); |
178 }; | 182 }; |
179 } | 183 } |
180 | 184 |
181 bool ClearSettingsFunction::RunWithStorage( | 185 bool ClearSettingsFunction::RunWithStorage( |
182 scoped_refptr<SettingsObserverList> observers, | 186 scoped_refptr<SettingsObserverList> observers, |
183 SettingsStorage* storage) { | 187 SettingsStorage* storage) { |
184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
185 return UseWriteResult(observers, storage->Clear()); | 189 return UseWriteResult(observers, storage->Clear(SettingsStorage::DEFAULTS)); |
186 } | 190 } |
187 | 191 |
188 } // namespace extensions | 192 } // namespace extensions |
OLD | NEW |