From 45c26e0e5ad8ca6c841bbb250e7790b23fb18d9f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 18 Jan 2015 17:11:27 -0800 Subject: [PATCH] Add app.setDataPath API --- atom/browser/api/atom_api_app.cc | 23 ++++++++--------------- atom/browser/api/atom_api_app.h | 1 + vendor/brightray | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 98d46f895a7e..9a9ce028fdff 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -16,6 +16,7 @@ #include "base/environment.h" #include "base/files/file_path.h" #include "base/path_service.h" +#include "brightray/browser/brightray_paths.h" #include "native_mate/callback.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" @@ -26,10 +27,6 @@ #include "atom/common/node_includes.h" -#if defined(OS_LINUX) -#include "base/nix/xdg_util.h" -#endif - using atom::Browser; namespace mate { @@ -142,19 +139,14 @@ void App::OnFinishLaunching() { Emit("ready"); } +void App::SetDataPath(const base::FilePath& path) { + PathService::Override(brightray::DIR_USER_DATA, path); +} + base::FilePath App::GetDataPath() { 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 - PathService::Get(base::DIR_APP_DATA, &path); -#endif - - return path.Append(base::FilePath::FromUTF8Unsafe( - Browser::Get()->GetName())); + PathService::Get(brightray::DIR_USER_DATA, &path); + return path; } void App::ResolveProxy(const GURL& url, ResolveProxyCallback callback) { @@ -187,6 +179,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( .SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser)) #endif + .SetMethod("setDataPath", &App::SetDataPath) .SetMethod("getDataPath", &App::GetDataPath) .SetMethod("resolveProxy", &App::ResolveProxy) .SetMethod("setDesktopName", &App::SetDesktopName); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index a9e2a17a13dd..61d061569dae 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -48,6 +48,7 @@ class App : public mate::EventEmitter, v8::Isolate* isolate) override; private: + void SetDataPath(const base::FilePath& path); base::FilePath GetDataPath(); void ResolveProxy(const GURL& url, ResolveProxyCallback callback); void SetDesktopName(const std::string& desktop_name); diff --git a/vendor/brightray b/vendor/brightray index 09dc5f11e9c8..395b3359cb5e 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 09dc5f11e9c83e6ff3c2b6b1b58ceb2b8eae35c4 +Subproject commit 395b3359cb5e8209fa740b9c678fd60709789106