OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/profile/profile_service_impl.h" | 5 #include "mojo/services/profile/profile_service_impl.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 int BaseKeyForMojoKey(mojo::ProfileService::PathKey key) { | 13 int BaseKeyForMojoKey(mojo::ProfileService::PathKey key) { |
14 switch(key) { | 14 switch(key) { |
15 case mojo::ProfileService::DIR_TEMP: | 15 case mojo::ProfileService::DIR_TEMP: |
16 return base::DIR_TEMP; | 16 return base::DIR_TEMP; |
17 default: | 17 default: |
18 return base::PATH_START; | 18 return base::PATH_START; |
19 } | 19 } |
20 } | 20 } |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 namespace mojo { | 24 namespace mojo { |
25 | 25 |
26 ProfileServiceImpl::ProfileServiceImpl(ApplicationConnection* connection) { | 26 ProfileServiceImpl::ProfileServiceImpl() { |
27 } | 27 } |
28 | 28 |
29 ProfileServiceImpl::~ProfileServiceImpl() { | 29 ProfileServiceImpl::~ProfileServiceImpl() { |
30 } | 30 } |
31 | 31 |
32 void ProfileServiceImpl::GetPath( | 32 void ProfileServiceImpl::GetPath( |
33 PathKey key, | 33 PathKey key, |
34 const mojo::Callback<void(mojo::String)>& callback) { | 34 const mojo::Callback<void(mojo::String)>& callback) { |
35 int base_key = BaseKeyForMojoKey(key); | 35 int base_key = BaseKeyForMojoKey(key); |
36 if (base_key == base::PATH_START) { | 36 if (base_key == base::PATH_START) { |
37 callback.Run(mojo::String()); | 37 callback.Run(mojo::String()); |
38 return; | 38 return; |
39 } | 39 } |
40 base::FilePath path; | 40 base::FilePath path; |
41 if (!PathService::Get(base_key, &path)) { | 41 if (!PathService::Get(base_key, &path)) { |
42 callback.Run(mojo::String()); | 42 callback.Run(mojo::String()); |
43 return; | 43 return; |
44 } | 44 } |
45 #if defined(OS_POSIX) | 45 #if defined(OS_POSIX) |
46 callback.Run(path.value()); | 46 callback.Run(path.value()); |
47 #elif defined(OS_WIN) | 47 #elif defined(OS_WIN) |
48 callback.Run(path.AsUTF8Unsafe()); | 48 callback.Run(path.AsUTF8Unsafe()); |
49 #else | 49 #else |
50 #error Not implemented | 50 #error Not implemented |
51 #endif | 51 #endif |
52 } | 52 } |
53 | 53 |
54 } // namespace mojo | 54 } // namespace mojo |
OLD | NEW |