Add preferences support for embedding applications
Applications can use brightray::BrowserContext::prefs to get access to preferences that are persisted between launches. brightray::BrowserContext::RegisterPrefs must be used to register preferences before they're accessed. Updated libchromiumcontent to pull in preferences support. * vendor/libchromiumcontent 3944c1c...b6a0d85 (2): > Actually compile the base/prefs code > Export symbols from base/prefs
This commit is contained in:
parent
5db043f7d4
commit
a2a2cd1936
3 changed files with 24 additions and 1 deletions
|
@ -8,6 +8,10 @@
|
|||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/prefs/json_pref_store.h"
|
||||
#include "base/prefs/pref_registry_simple.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/prefs/pref_service_builder.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/resource_context.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
|
@ -36,6 +40,15 @@ private:
|
|||
};
|
||||
|
||||
BrowserContext::BrowserContext() : resource_context_(new ResourceContext) {
|
||||
auto prefs_path = GetPath().Append("Preferences");
|
||||
PrefServiceBuilder builder;
|
||||
builder.WithUserFilePrefs(prefs_path,
|
||||
JsonPrefStore::GetTaskRunnerForFile(prefs_path, content::BrowserThread::GetBlockingPool()));
|
||||
|
||||
auto registry = make_scoped_refptr(new PrefRegistrySimple);
|
||||
RegisterPrefs(registry);
|
||||
|
||||
prefs_.reset(builder.Create(registry));
|
||||
}
|
||||
|
||||
BrowserContext::~BrowserContext() {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
|
||||
class PrefRegistrySimple;
|
||||
class PrefService;
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class URLRequestContextGetter;
|
||||
|
@ -19,6 +22,12 @@ public:
|
|||
|
||||
net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*);
|
||||
|
||||
PrefService* prefs() { return prefs_.get(); }
|
||||
|
||||
protected:
|
||||
// Subclasses should override this to register custom preferences.
|
||||
virtual void RegisterPrefs(PrefRegistrySimple*) {}
|
||||
|
||||
private:
|
||||
class ResourceContext;
|
||||
|
||||
|
@ -37,6 +46,7 @@ private:
|
|||
|
||||
scoped_ptr<ResourceContext> resource_context_;
|
||||
scoped_refptr<URLRequestContextGetter> url_request_getter_;
|
||||
scoped_ptr<PrefService> prefs_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserContext);
|
||||
};
|
||||
|
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 3944c1c0055d1de3d8f0647087acc0f6244113d6
|
||||
Subproject commit b6a0d851db2e4f1bf181e05d3e9c2d8fe6ef7f0c
|
Loading…
Reference in a new issue