diff options
author | byungchul <byungchul@chromium.org> | 2015-03-30 18:28:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-31 01:29:05 +0000 |
commit | 28df2edecff964361abbee663d8cd9d85f06be8c (patch) | |
tree | ece4e664b63e41b4d488535a1748e2f0957bde7f /chromecast/base | |
parent | 1fdebe773b72c0780953dd3c74dfcc7fcf45dd3a (diff) | |
download | chromium_src-28df2edecff964361abbee663d8cd9d85f06be8c.zip chromium_src-28df2edecff964361abbee663d8cd9d85f06be8c.tar.gz chromium_src-28df2edecff964361abbee663d8cd9d85f06be8c.tar.bz2 |
Move cast_paths into chromecast/base.
BUG=
Review URL: https://codereview.chromium.org/1044033002
Cr-Commit-Position: refs/heads/master@{#322939}
Diffstat (limited to 'chromecast/base')
-rw-r--r-- | chromecast/base/cast_paths.cc | 69 | ||||
-rw-r--r-- | chromecast/base/cast_paths.h | 34 |
2 files changed, 103 insertions, 0 deletions
diff --git a/chromecast/base/cast_paths.cc b/chromecast/base/cast_paths.cc new file mode 100644 index 0000000..ce72684 --- /dev/null +++ b/chromecast/base/cast_paths.cc @@ -0,0 +1,69 @@ +// 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 "chromecast/base/cast_paths.h" + +#include "base/base_paths.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "build/build_config.h" + +namespace chromecast { + +bool PathProvider(int key, base::FilePath* result) { + switch (key) { + case DIR_CAST_HOME: { + base::FilePath home = base::GetHomeDir(); +#if defined(ARCH_CPU_ARMEL) + // When running on the actual device, $HOME is set to the user's + // directory under the data partition. + *result = home; +#else + // When running a development instance as a regular user, use + // a data directory under $HOME (similar to Chrome). + *result = home.Append(".config/cast_shell"); +#endif + return true; + } +#if defined(OS_ANDROID) + case FILE_CAST_ANDROID_LOG: { + base::FilePath base_dir; + CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &base_dir)); + *result = base_dir.AppendASCII("cast_shell.log"); + return true; + } +#endif // defined(OS_ANDROID) + case FILE_CAST_CONFIG: { + base::FilePath data_dir; +#if defined(OS_ANDROID) + CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &data_dir)); + *result = data_dir.Append("cast_shell.conf"); +#else + CHECK(PathService::Get(DIR_CAST_HOME, &data_dir)); + *result = data_dir.Append(".eureka.conf"); +#endif // defined(OS_ANDROID) + return true; + } + case FILE_CAST_PAK: { + base::FilePath base_dir; +#if defined(OS_ANDROID) + CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &base_dir)); + *result = base_dir.Append("paks/cast_shell.pak"); +#else + CHECK(PathService::Get(base::DIR_MODULE, &base_dir)); + *result = base_dir.Append("assets/cast_shell.pak"); +#endif // defined(OS_ANDROID) + return true; + } + } + return false; +} + +void RegisterPathProvider() { + PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); +} + +} // namespace chromecast diff --git a/chromecast/base/cast_paths.h b/chromecast/base/cast_paths.h new file mode 100644 index 0000000..11433a4 --- /dev/null +++ b/chromecast/base/cast_paths.h @@ -0,0 +1,34 @@ +// 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. + +#ifndef CHROMECAST_BASE_CAST_PATHS_H_ +#define CHROMECAST_BASE_CAST_PATHS_H_ + +#include "build/build_config.h" + +// This file declares path keys for the chromecast module. These can be used +// with the PathService to access various special directories and files. + +namespace chromecast { + +enum { + PATH_START = 8000, + + DIR_CAST_HOME, // Return a modified $HOME which works for both + // development use and the actual device. + +#if defined(OS_ANDROID) + FILE_CAST_ANDROID_LOG, // Log file location for Android. +#endif // defined(OS_ANDROID) + FILE_CAST_CONFIG, // Config/preferences file path. + FILE_CAST_PAK, // cast_shell.pak file path. + PATH_END +}; + +// Call once to register the provider for the path keys defined above. +void RegisterPathProvider(); + +} // namespace chromecast + +#endif // CHROMECAST_BASE_CAST_PATHS_H_ |