summaryrefslogtreecommitdiffstats
path: root/mojo/shell/storage.cc
blob: 0dc04174ea442c7cf38bdc3afcac6f406d17a893 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/shell/storage.h"

#include "base/environment.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"

#if defined(OS_WIN)
#include "base/base_paths_win.h"
#elif defined(OS_LINUX)
#include "base/nix/xdg_util.h"
#elif defined(OS_MACOSX)
#include "base/base_paths_mac.h"
#endif

namespace mojo {
namespace shell {

Storage::Storage() {
#if defined(OS_WIN)
  CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &profile_path_));
  profile_path_ = profile_path_.Append(FILE_PATH_LITERAL("mojo_shell"));
#elif defined(OS_LINUX)
  scoped_ptr<base::Environment> env(base::Environment::Create());
  base::FilePath config_dir(
      base::nix::GetXDGDirectory(env.get(),
                                 base::nix::kXdgConfigHomeEnvVar,
                                 base::nix::kDotConfigDir));
  profile_path_ = config_dir.Append("mojo_shell");
#elif defined(OS_MACOSX)
  CHECK(PathService::Get(base::DIR_APP_DATA, &profile_path_));
  profile_path_ = profile_path_.Append("Chromium Mojo Shell");
#elif defined(OS_ANDROID)
  CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &profile_path_));
  profile_path_ = profile_path_.Append(FILE_PATH_LITERAL("mojo_shell"));
#else
  NOTIMPLEMENTED();
#endif

  if (!base::PathExists(profile_path_))
    base::CreateDirectory(profile_path_);
}

Storage::~Storage() {
}

}  // namespace shell
}  // namespace mojo