Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromecast / base / path_utils.cc
blob4f5b27b7e02fc7411cd80c4408246dd162d0c599
1 // Copyright 2015 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.
5 #include "chromecast/base/path_utils.h"
7 #include "base/logging.h"
8 #include "base/path_service.h"
10 namespace chromecast {
12 namespace {
14 base::FilePath GetPath(base::BasePathKey default_dir_key,
15 const base::FilePath& path) {
16 if (path.IsAbsolute())
17 return path;
19 base::FilePath default_dir;
20 if (!PathService::Get(default_dir_key, &default_dir))
21 LOG(DFATAL) << "Cannot get default dir: " << default_dir_key;
23 base::FilePath adjusted_path(default_dir.Append(path));
24 VLOG(1) << "Path adjusted from " << path.value() << " to "
25 << adjusted_path.value();
26 return adjusted_path;
29 } // namespace
31 base::FilePath GetHomePath(const base::FilePath& path) {
32 return GetPath(base::DIR_HOME, path);
35 base::FilePath GetHomePathASCII(const std::string& path) {
36 return GetHomePath(base::FilePath(path));
39 base::FilePath GetBinPath(const base::FilePath& path) {
40 return GetPath(base::DIR_EXE, path);
43 base::FilePath GetBinPathASCII(const std::string& path) {
44 return GetBinPath(base::FilePath(path));
47 base::FilePath GetTmpPath(const base::FilePath& path) {
48 return GetPath(base::DIR_TEMP, path);
51 base::FilePath GetTmpPathASCII(const std::string& path) {
52 return GetTmpPath(base::FilePath(path));
55 } // namespace chromecast