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

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

Issue 7977018: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix race condition in ExtensionSettingsUIWrapper::Core 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()->RunWithSettings(
20 BrowserThread::FILE, 20 base::Bind(&SettingsFunction::RunWithSettingsOnFileThread, this));
21 FROM_HERE,
22 base::Bind(&SettingsFunction::RunOnFileThread, this));
23 return true; 21 return true;
24 } 22 }
25 23
26 void SettingsFunction::RunOnFileThread() { 24 void SettingsFunction::RunWithSettingsOnFileThread(
25 ExtensionSettings* settings) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
28 ExtensionSettings* settings =
29 profile()->GetExtensionService()->extension_settings();
30 bool success = RunWithStorage(settings->GetStorage(extension_id())); 27 bool success = RunWithStorage(settings->GetStorage(extension_id()));
31 BrowserThread::PostTask( 28 BrowserThread::PostTask(
32 BrowserThread::UI, 29 BrowserThread::UI,
33 FROM_HERE, 30 FROM_HERE,
34 base::Bind(&SettingsFunction::SendResponse, this, success)); 31 base::Bind(&SettingsFunction::SendResponse, this, success));
35 } 32 }
36 33
37 bool SettingsFunction::UseResult( 34 bool SettingsFunction::UseResult(
38 const ExtensionSettingsStorage::Result& storage_result) { 35 const ExtensionSettingsStorage::Result& storage_result) {
39 if (storage_result.HasError()) { 36 if (storage_result.HasError()) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 AddAllStringValues(*as_list, &string_list); 94 AddAllStringValues(*as_list, &string_list);
98 return UseResult(storage->Remove(string_list)); 95 return UseResult(storage->Remove(string_list));
99 } 96 }
100 return UseResult(ExtensionSettingsStorage::Result(kUnsupportedArgumentType)); 97 return UseResult(ExtensionSettingsStorage::Result(kUnsupportedArgumentType));
101 } 98 }
102 99
103 bool ClearSettingsFunction::RunWithStorage( 100 bool ClearSettingsFunction::RunWithStorage(
104 ExtensionSettingsStorage* storage) { 101 ExtensionSettingsStorage* storage) {
105 return UseResult(storage->Clear()); 102 return UseResult(storage->Clear());
106 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698