Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1104)

Side by Side Diff: chrome/browser/extensions/extension_settings_api.cc

Issue 7775008: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Comments, GCC compile fix Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_settings_api.h" 8 #include "chrome/browser/extensions/extension_settings_api.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
11 11
12 namespace { 12 namespace {
13 const char* kUnsupportedArgumentType = "Unsupported argument type"; 13 const char* kUnsupportedArgumentType = "Unsupported argument type";
14 } // namespace 14 } // namespace
15 15
16 // SettingsFunction 16 // SettingsFunction
17 17
18 bool SettingsFunction::RunImpl() { 18 bool SettingsFunction::RunImpl() {
19 BrowserThread::PostTask( 19 profile()->GetExtensionService()->extension_settings()->RunWithStorage(
20 BrowserThread::FILE, 20 extension_id(),
21 FROM_HERE, 21 base::Bind(&SettingsFunction::RunWithStorageOnFileThread, this));
22 base::Bind(&SettingsFunction::RunOnFileThread, this));
23 return true; 22 return true;
24 } 23 }
25 24
26 void SettingsFunction::RunOnFileThread() { 25 void SettingsFunction::RunWithStorageOnFileThread(
26 ExtensionSettingsStorage* storage) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
28 ExtensionSettings* settings = 28 bool success = RunWithStorage(storage);
29 profile()->GetExtensionService()->extension_settings();
30 bool success = RunWithStorage(settings->GetStorage(extension_id()));
31 BrowserThread::PostTask( 29 BrowserThread::PostTask(
32 BrowserThread::UI, 30 BrowserThread::UI,
33 FROM_HERE, 31 FROM_HERE,
34 base::Bind(&SettingsFunction::SendResponse, this, success)); 32 base::Bind(&SettingsFunction::SendResponse, this, success));
35 } 33 }
36 34
37 bool SettingsFunction::UseResult( 35 bool SettingsFunction::UseResult(
38 const ExtensionSettingsStorage::Result& storage_result) { 36 const ExtensionSettingsStorage::Result& storage_result) {
39 if (storage_result.HasError()) { 37 if (storage_result.HasError()) {
40 error_ = storage_result.GetError(); 38 error_ = storage_result.GetError();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 AddAllStringValues(*as_list, &string_list); 95 AddAllStringValues(*as_list, &string_list);
98 return UseResult(storage->Remove(string_list)); 96 return UseResult(storage->Remove(string_list));
99 } 97 }
100 return UseResult(ExtensionSettingsStorage::Result(kUnsupportedArgumentType)); 98 return UseResult(ExtensionSettingsStorage::Result(kUnsupportedArgumentType));
101 } 99 }
102 100
103 bool ClearSettingsFunction::RunWithStorage( 101 bool ClearSettingsFunction::RunWithStorage(
104 ExtensionSettingsStorage* storage) { 102 ExtensionSettingsStorage* storage) {
105 return UseResult(storage->Clear()); 103 return UseResult(storage->Clear());
106 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698