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 "ios/chrome/browser/chrome_paths.h"
7 #include "base/base_paths.h"
8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
12 #include "base/threading/thread_restrictions.h"
17 #if defined(GOOGLE_CHROME_BUILD)
18 const base::FilePath::CharType kProductDirName[] =
19 FILE_PATH_LITERAL("Google/Chrome");
21 const base::FilePath::CharType kProductDirName[] =
22 FILE_PATH_LITERAL("Chromium");
25 bool GetDefaultUserDataDirectory(base::FilePath* result) {
26 if (!PathService::Get(base::DIR_APP_DATA, result)) {
30 *result = result->Append(kProductDirName);
34 bool PathProvider(int key, base::FilePath* result) {
35 // Assume that creation of the directory is not required if it does not exist.
36 // This flag is set to true for the case where it needs to be created.
37 bool create_dir = false;
42 if (!GetDefaultUserDataDirectory(&cur))
48 if (!GetDefaultUserDataDirectory(&cur))
50 cur = cur.Append(FILE_PATH_LITERAL("Crash Reports"));
55 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
57 cur = cur.Append(FILE_PATH_LITERAL("ios"));
58 cur = cur.Append(FILE_PATH_LITERAL("chrome"));
59 cur = cur.Append(FILE_PATH_LITERAL("test"));
60 cur = cur.Append(FILE_PATH_LITERAL("data"));
67 if (!base::PathExists(cur)) {
68 if (!create_dir || !base::CreateDirectory(cur))
78 void RegisterPathProvider() {
79 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);