OLD | NEW |
| (Empty) |
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 "mojo/services/profile/profile_service_impl.h" | |
6 | |
7 #include "base/base_paths.h" | |
8 #include "base/files/file_path.h" | |
9 #include "base/path_service.h" | |
10 | |
11 namespace { | |
12 | |
13 int BaseKeyForMojoKey(mojo::ProfileService::PathKey key) { | |
14 switch(key) { | |
15 case mojo::ProfileService::PATH_KEY_DIR_TEMP: | |
16 return base::DIR_TEMP; | |
17 default: | |
18 return base::PATH_START; | |
19 } | |
20 } | |
21 | |
22 } // namespace | |
23 | |
24 namespace mojo { | |
25 | |
26 ProfileServiceImpl::ProfileServiceImpl(ApplicationConnection* connection) { | |
27 } | |
28 | |
29 ProfileServiceImpl::~ProfileServiceImpl() { | |
30 } | |
31 | |
32 void ProfileServiceImpl::GetPath( | |
33 PathKey key, | |
34 const mojo::Callback<void(mojo::String)>& callback) { | |
35 int base_key = BaseKeyForMojoKey(key); | |
36 if (base_key == base::PATH_START) { | |
37 callback.Run(mojo::String()); | |
38 return; | |
39 } | |
40 base::FilePath path; | |
41 if (!PathService::Get(base_key, &path)) { | |
42 callback.Run(mojo::String()); | |
43 return; | |
44 } | |
45 #if defined(OS_POSIX) | |
46 callback.Run(path.value()); | |
47 #elif defined(OS_WIN) | |
48 callback.Run(path.AsUTF8Unsafe()); | |
49 #else | |
50 #error Not implemented | |
51 #endif | |
52 } | |
53 | |
54 } // namespace mojo | |
OLD | NEW |