diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 3ade3b1c51a8..38aecce7b77a 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -51,6 +51,18 @@ BrowserContext::BrowserContext() : resource_context_(new ResourceContext) { } void BrowserContext::Initialize() { + base::FilePath path; +#if defined(OS_LINUX) + scoped_ptr env(base::Environment::Create()); + path = base::nix::GetXDGDirectory(env.get(), + base::nix::kXdgConfigHomeEnvVar, + base::nix::kDotConfigDir); +#else + CHECK(PathService::Get(base::DIR_APP_DATA, &path)); +#endif + + path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); PrefServiceBuilder builder; builder.WithUserFilePrefs(prefs_path, @@ -86,21 +98,7 @@ scoped_ptr BrowserContext::CreateNetworkDelegate() { return make_scoped_ptr(new NetworkDelegate).Pass(); } -base::FilePath BrowserContext::GetPath() { - if (!path_.empty()) - return path_; - - base::FilePath path; -#if defined(OS_LINUX) - scoped_ptr env(base::Environment::Create()); - path = base::nix::GetXDGDirectory(env.get(), - base::nix::kXdgConfigHomeEnvVar, - base::nix::kDotConfigDir); -#else - CHECK(PathService::Get(base::DIR_APP_DATA, &path)); -#endif - - path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); +base::FilePath BrowserContext::GetPath() const { return path_; } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index ec3f1f6e5a2f..7067aab53139 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -35,7 +35,7 @@ protected: // Subclasses should override this to provide a custom NetworkDelegate implementation. virtual scoped_ptr CreateNetworkDelegate(); - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; private: class ResourceContext;