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

Side by Side Diff: chrome/common/chrome_paths_mac.mm

Issue 6046009: Move base/mac_util.h to base/mac and use the base::mac namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_paths.cc ('k') | chrome/common/font_loader_mac.mm » ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/common/chrome_paths_internal.h" 5 #include "chrome/common/chrome_paths_internal.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "chrome/common/chrome_constants.h" 13 #include "chrome/common/chrome_constants.h"
14 14
15 namespace { 15 namespace {
16 const FilePath* g_override_versioned_directory = NULL; 16 const FilePath* g_override_versioned_directory = NULL;
17 } // namespace 17 } // namespace
18 18
19 namespace chrome { 19 namespace chrome {
20 20
21 bool GetDefaultUserDataDirectory(FilePath* result) { 21 bool GetDefaultUserDataDirectory(FilePath* result) {
(...skipping 16 matching lines...) Expand all
38 *result = result->Append("Google").Append("Chrome Frame"); 38 *result = result->Append("Google").Append("Chrome Frame");
39 #else 39 #else
40 *result = result->Append("Chrome Frame"); 40 *result = result->Append("Chrome Frame");
41 #endif 41 #endif
42 success = true; 42 success = true;
43 } 43 }
44 return success; 44 return success;
45 } 45 }
46 46
47 bool GetUserDocumentsDirectory(FilePath* result) { 47 bool GetUserDocumentsDirectory(FilePath* result) {
48 return mac_util::GetUserDirectory(NSDocumentDirectory, result); 48 return base::mac::GetUserDirectory(NSDocumentDirectory, result);
49 } 49 }
50 50
51 void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { 51 void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
52 // If the profile directory is under ~/Library/Application Support, 52 // If the profile directory is under ~/Library/Application Support,
53 // use a suitable cache directory under ~/Library/Caches. For 53 // use a suitable cache directory under ~/Library/Caches. For
54 // example, a profile directory of ~/Library/Application 54 // example, a profile directory of ~/Library/Application
55 // Support/Google/Chrome/MyProfileName would use the cache directory 55 // Support/Google/Chrome/MyProfileName would use the cache directory
56 // ~/Library/Caches/Google/Chrome/MyProfileName. 56 // ~/Library/Caches/Google/Chrome/MyProfileName.
57 57
58 // Default value in cases where any of the following fails. 58 // Default value in cases where any of the following fails.
59 *result = profile_dir; 59 *result = profile_dir;
60 60
61 FilePath app_data_dir; 61 FilePath app_data_dir;
62 if (!PathService::Get(base::DIR_APP_DATA, &app_data_dir)) 62 if (!PathService::Get(base::DIR_APP_DATA, &app_data_dir))
63 return; 63 return;
64 FilePath cache_dir; 64 FilePath cache_dir;
65 if (!PathService::Get(base::DIR_CACHE, &cache_dir)) 65 if (!PathService::Get(base::DIR_CACHE, &cache_dir))
66 return; 66 return;
67 if (!app_data_dir.AppendRelativePath(profile_dir, &cache_dir)) 67 if (!app_data_dir.AppendRelativePath(profile_dir, &cache_dir))
68 return; 68 return;
69 69
70 *result = cache_dir; 70 *result = cache_dir;
71 } 71 }
72 72
73 bool GetUserDownloadsDirectory(FilePath* result) { 73 bool GetUserDownloadsDirectory(FilePath* result) {
74 return mac_util::GetUserDirectory(NSDownloadsDirectory, result); 74 return base::mac::GetUserDirectory(NSDownloadsDirectory, result);
75 } 75 }
76 76
77 bool GetUserDesktop(FilePath* result) { 77 bool GetUserDesktop(FilePath* result) {
78 return mac_util::GetUserDirectory(NSDesktopDirectory, result); 78 return base::mac::GetUserDirectory(NSDesktopDirectory, result);
79 } 79 }
80 80
81 FilePath GetVersionedDirectory() { 81 FilePath GetVersionedDirectory() {
82 if (g_override_versioned_directory) 82 if (g_override_versioned_directory)
83 return *g_override_versioned_directory; 83 return *g_override_versioned_directory;
84 84
85 // Start out with the path to the running executable. 85 // Start out with the path to the running executable.
86 FilePath path; 86 FilePath path;
87 PathService::Get(base::FILE_EXE, &path); 87 PathService::Get(base::FILE_EXE, &path);
88 88
89 // One step up to MacOS, another to Contents. 89 // One step up to MacOS, another to Contents.
90 path = path.DirName().DirName(); 90 path = path.DirName().DirName();
91 DCHECK_EQ(path.BaseName().value(), "Contents"); 91 DCHECK_EQ(path.BaseName().value(), "Contents");
92 92
93 if (mac_util::IsBackgroundOnlyProcess()) { 93 if (base::mac::IsBackgroundOnlyProcess()) {
94 // path identifies the helper .app's Contents directory in the browser 94 // path identifies the helper .app's Contents directory in the browser
95 // .app's versioned directory. Go up two steps to get to the browser 95 // .app's versioned directory. Go up two steps to get to the browser
96 // .app's versioned directory. 96 // .app's versioned directory.
97 path = path.DirName().DirName(); 97 path = path.DirName().DirName();
98 DCHECK_EQ(path.BaseName().value(), kChromeVersion); 98 DCHECK_EQ(path.BaseName().value(), kChromeVersion);
99 } else { 99 } else {
100 // Go into the versioned directory. 100 // Go into the versioned directory.
101 path = path.Append("Versions").Append(kChromeVersion); 101 path = path.Append("Versions").Append(kChromeVersion);
102 } 102 }
103 103
(...skipping 17 matching lines...) Expand all
121 // needed to compute the framework's path are also effectively free, so that 121 // needed to compute the framework's path are also effectively free, so that
122 // is the approach that is used here. NSBundle is also documented as being 122 // is the approach that is used here. NSBundle is also documented as being
123 // not thread-safe, and thread safety may be a concern here. 123 // not thread-safe, and thread safety may be a concern here.
124 124
125 // The framework bundle is at a known path and name from the browser .app's 125 // The framework bundle is at a known path and name from the browser .app's
126 // versioned directory. 126 // versioned directory.
127 return GetVersionedDirectory().Append(kFrameworkName); 127 return GetVersionedDirectory().Append(kFrameworkName);
128 } 128 }
129 129
130 bool GetLocalLibraryDirectory(FilePath* result) { 130 bool GetLocalLibraryDirectory(FilePath* result) {
131 return mac_util::GetLocalDirectory(NSLibraryDirectory, result); 131 return base::mac::GetLocalDirectory(NSLibraryDirectory, result);
132 } 132 }
133 133
134 } // namespace chrome 134 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths.cc ('k') | chrome/common/font_loader_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698