]> khamidou — GitHub mirrors - electron.git/commitdiff
Add app.setDataPath API
authorCheng Zhao <zcbenz@gmail.com>
Mon, 19 Jan 2015 01:11:27 +0000 (17:11 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 19 Jan 2015 05:43:18 +0000 (21:43 -0800)
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
vendor/brightray

index 98d46f895a7e9e2c3bf7e79179fcee4fb60ecf40..9a9ce028fdff0bc12806491e6f43b9771d4e3f0a 100644 (file)
@@ -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"
 
 #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<base::Environment> 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);
index a9e2a17a13dd2c363c9264b4b6305bee9b7018f6..61d061569daecc2313012dd6cfb30d5b1adc062d 100644 (file)
@@ -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);
index 09dc5f11e9c83e6ff3c2b6b1b58ceb2b8eae35c4..395b3359cb5e8209fa740b9c678fd60709789106 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 09dc5f11e9c83e6ff3c2b6b1b58ceb2b8eae35c4
+Subproject commit 395b3359cb5e8209fa740b9c678fd60709789106