#include "base/values.h"
#include "base/command_line.h"
+#include "base/environment.h"
+#include "base/files/file_path.h"
+#include "base/path_service.h"
#include "atom/browser/browser.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 atom {
Emit("ready");
}
+std::string 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
+ CHECK(PathService::Get(base::DIR_APP_DATA, &path));
+#endif
+
+ base::FilePath dataPath = path.Append(base::FilePath::FromUTF8Unsafe(Browser::Get()->GetName()));
+
+ return dataPath.value();
+}
+
mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
Browser* browser = Browser::Get();
.SetMethod("getName", base::Bind(&Browser::GetName,
base::Unretained(browser)))
.SetMethod("setName", base::Bind(&Browser::SetName,
- base::Unretained(browser)));
+ base::Unretained(browser)))
+ .SetMethod("getDataPath", &App::GetDataPath);
}
// static
virtual void OnActivateWithNoOpenWindows() OVERRIDE;
virtual void OnWillFinishLaunching() OVERRIDE;
virtual void OnFinishLaunching() OVERRIDE;
+ virtual std::string GetDataPath();
// mate::Wrappable implementations:
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(