Home | History | Annotate | Download | only in shell
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "mojo/shell/storage.h"
      6 
      7 #include "base/environment.h"
      8 #include "base/file_util.h"
      9 #include "base/logging.h"
     10 #include "base/path_service.h"
     11 
     12 #if defined(OS_WIN)
     13 #include "base/base_paths_win.h"
     14 #elif defined(OS_LINUX)
     15 #include "base/nix/xdg_util.h"
     16 #elif defined(OS_MACOSX)
     17 #include "base/base_paths_mac.h"
     18 #endif
     19 
     20 namespace mojo {
     21 namespace shell {
     22 
     23 Storage::Storage() {
     24 #if defined(OS_WIN)
     25   CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &profile_path_));
     26   profile_path_ = profile_path_.Append(FILE_PATH_LITERAL("mojo_shell"));
     27 #elif defined(OS_LINUX)
     28   scoped_ptr<base::Environment> env(base::Environment::Create());
     29   base::FilePath config_dir(
     30       base::nix::GetXDGDirectory(env.get(),
     31                                  base::nix::kXdgConfigHomeEnvVar,
     32                                  base::nix::kDotConfigDir));
     33   profile_path_ = config_dir.Append("mojo_shell");
     34 #elif defined(OS_MACOSX)
     35   CHECK(PathService::Get(base::DIR_APP_DATA, &profile_path_));
     36   profile_path_ = profile_path_.Append("Chromium Mojo Shell");
     37 #elif defined(OS_ANDROID)
     38   CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &profile_path_));
     39   profile_path_ = profile_path_.Append(FILE_PATH_LITERAL("mojo_shell"));
     40 #else
     41   NOTIMPLEMENTED();
     42 #endif
     43 
     44   if (!base::PathExists(profile_path_))
     45     base::CreateDirectory(profile_path_);
     46 }
     47 
     48 Storage::~Storage() {
     49 }
     50 
     51 }  // namespace shell
     52 }  // namespace mojo
     53