Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: ios/chrome/browser/chrome_paths.mm

Issue 1415573009: Add missing accessor to ios PathProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment by blundell Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/chrome_paths.h ('k') | ios/chrome/browser/chrome_paths_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "ios/chrome/browser/chrome_paths.h" 5 #include "ios/chrome/browser/chrome_paths.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/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "components/gcm_driver/gcm_driver_constants.h"
14 #include "ios/chrome/browser/chrome_paths_internal.h"
13 15
14 namespace ios { 16 namespace ios {
15 namespace { 17 namespace {
16 18
17 #if defined(GOOGLE_CHROME_BUILD) 19 #if defined(GOOGLE_CHROME_BUILD)
18 const base::FilePath::CharType kProductDirName[] = 20 const base::FilePath::CharType kProductDirName[] =
19 FILE_PATH_LITERAL("Google/Chrome"); 21 FILE_PATH_LITERAL("Google/Chrome");
20 #else 22 #else
21 const base::FilePath::CharType kProductDirName[] = 23 const base::FilePath::CharType kProductDirName[] =
22 FILE_PATH_LITERAL("Chromium"); 24 FILE_PATH_LITERAL("Chromium");
(...skipping 30 matching lines...) Expand all
53 55
54 case DIR_TEST_DATA: 56 case DIR_TEST_DATA:
55 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) 57 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
56 return false; 58 return false;
57 cur = cur.Append(FILE_PATH_LITERAL("ios")); 59 cur = cur.Append(FILE_PATH_LITERAL("ios"));
58 cur = cur.Append(FILE_PATH_LITERAL("chrome")); 60 cur = cur.Append(FILE_PATH_LITERAL("chrome"));
59 cur = cur.Append(FILE_PATH_LITERAL("test")); 61 cur = cur.Append(FILE_PATH_LITERAL("test"));
60 cur = cur.Append(FILE_PATH_LITERAL("data")); 62 cur = cur.Append(FILE_PATH_LITERAL("data"));
61 break; 63 break;
62 64
65 case DIR_GLOBAL_GCM_STORE:
66 if (!PathService::Get(DIR_USER_DATA, &cur))
67 return false;
68 cur = cur.Append(gcm_driver::kGCMStoreDirname);
69 break;
70
63 case FILE_LOCAL_STATE: 71 case FILE_LOCAL_STATE:
64 if (!PathService::Get(ios::DIR_USER_DATA, &cur)) 72 if (!PathService::Get(DIR_USER_DATA, &cur))
65 return false; 73 return false;
66 cur = cur.Append(FILE_PATH_LITERAL("Local State")); 74 cur = cur.Append(FILE_PATH_LITERAL("Local State"));
67 break; 75 break;
68 76
77 case FILE_RESOURCES_PACK:
78 if (!base::PathService::Get(base::DIR_MODULE, &cur))
79 return false;
80 cur = cur.Append(FILE_PATH_LITERAL("resources.pak"));
81 break;
82
69 default: 83 default:
70 return false; 84 return false;
71 } 85 }
72 86
73 if (create_dir && !base::PathExists(cur) && !base::CreateDirectory(cur)) 87 if (create_dir && !base::PathExists(cur) && !base::CreateDirectory(cur))
74 return false; 88 return false;
75 89
76 *result = cur; 90 *result = cur;
77 return true; 91 return true;
78 } 92 }
79 93
80 } // namespace 94 } // namespace
81 95
82 void RegisterPathProvider() { 96 void RegisterPathProvider() {
83 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); 97 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
84 } 98 }
85 99
100 void GetUserCacheDirectory(const base::FilePath& browser_state_dir,
101 base::FilePath* result) {
102 // If the browser state directory is under ~/Library/Application Support,
103 // use a suitable cache directory under ~/Library/Caches.
104
105 // Default value in cases where any of the following fails.
106 *result = browser_state_dir;
107
108 base::FilePath app_data_dir;
109 if (!PathService::Get(base::DIR_APP_DATA, &app_data_dir))
110 return;
111 base::FilePath cache_dir;
112 if (!PathService::Get(base::DIR_CACHE, &cache_dir))
113 return;
114 if (!app_data_dir.AppendRelativePath(browser_state_dir, &cache_dir))
115 return;
116
117 *result = cache_dir;
118 }
119
86 } // namespace ios 120 } // namespace ios
OLDNEW
« no previous file with comments | « ios/chrome/browser/chrome_paths.h ('k') | ios/chrome/browser/chrome_paths_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698