blob: 2fe52ac8510afd7af5aea1aefafc857635f43ff7 (
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
53
54
|
// Copyright 2014 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/services/profile/profile_service_impl.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
namespace {
int BaseKeyForMojoKey(mojo::ProfileService::PathKey key) {
switch(key) {
case mojo::ProfileService::DIR_TEMP:
return base::DIR_TEMP;
default:
return base::PATH_START;
}
}
} // namespace
namespace mojo {
ProfileServiceImpl::ProfileServiceImpl(void* context) {
}
ProfileServiceImpl::~ProfileServiceImpl() {
}
void ProfileServiceImpl::GetPath(
PathKey key,
const mojo::Callback<void(mojo::String)>& callback) {
int base_key = BaseKeyForMojoKey(key);
if (base_key == base::PATH_START) {
callback.Run(mojo::String());
return;
}
base::FilePath path;
if (!PathService::Get(base_key, &path)) {
callback.Run(mojo::String());
return;
}
#if defined(OS_POSIX)
callback.Run(path.value());
#elif defined(OS_WIN)
callback.Run(path.AsUTF8Unsafe());
#else
#error Not implemented
#endif
}
} // namespace mojo
|