Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / auth / mount_manager.cc
1 // Copyright 2014 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 "chrome/browser/chromeos/login/auth/mount_manager.h"
6
7 #include "chrome/browser/chromeos/profiles/profile_helper.h"
8
9 namespace chromeos {
10
11 MountManager* MountManager::Get() {
12   if (!instance_)
13     instance_ = new MountManager();
14   return instance_;
15 }
16
17 // static
18 MountManager* MountManager::instance_ = NULL;
19
20 base::FilePath MountManager::GetHomeDir(std::string& user_hash) {
21   return ProfileHelper::GetProfilePathByUserIdHash(user_hash);
22 }
23
24 MountManager::MountManager() {}
25
26 MountManager::~MountManager() {}
27
28 bool MountManager::IsMounted(const std::string& user_id) {
29   UserToPathMap::iterator i(additional_mounts_.find(user_id));
30   return i != additional_mounts_.end();
31 }
32
33 base::FilePath MountManager::GetPath(const std::string& user_id) {
34   UserToPathMap::iterator i(additional_mounts_.find(user_id));
35   DCHECK(i != additional_mounts_.end());
36   return (i == additional_mounts_.end()) ? base::FilePath() : i->second;
37 }
38
39 void MountManager::SetPath(const std::string& user_id,
40                            const base::FilePath& path) {
41   additional_mounts_[user_id] = path;
42 }
43
44 void MountManager::DeletePath(const std::string& user_id) {
45   additional_mounts_.erase(user_id);
46 }
47
48 }  // namespace chromeos