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

Side by Side Diff: trunk/src/chrome/common/chrome_paths_linux.cc

Issue 284333002: Revert 270872 "Move all callers of GetHomeDir() to PathService::..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/base_paths.h"
8 #include "base/environment.h" 7 #include "base/environment.h"
9 #include "base/file_util.h" 8 #include "base/file_util.h"
10 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
11 #include "base/nix/xdg_util.h" 10 #include "base/nix/xdg_util.h"
12 #include "base/path_service.h" 11 #include "base/path_service.h"
13 #include "chrome/common/chrome_paths.h"
14 12
15 namespace chrome { 13 namespace chrome {
16 14
17 using base::nix::GetXDGDirectory; 15 using base::nix::GetXDGDirectory;
18 using base::nix::GetXDGUserDirectory; 16 using base::nix::GetXDGUserDirectory;
19 using base::nix::kDotConfigDir; 17 using base::nix::kDotConfigDir;
20 using base::nix::kXdgConfigHomeEnvVar; 18 using base::nix::kXdgConfigHomeEnvVar;
21 19
22 namespace { 20 namespace {
23 21
24 const char kDownloadsDir[] = "Downloads"; 22 const char kDownloadsDir[] = "Downloads";
25 const char kMusicDir[] = "Music"; 23 const char kMusicDir[] = "Music";
26 const char kPicturesDir[] = "Pictures"; 24 const char kPicturesDir[] = "Pictures";
27 const char kVideosDir[] = "Videos"; 25 const char kVideosDir[] = "Videos";
28 26
29 // Generic function for GetUser{Music,Pictures,Video}Directory. 27 // Generic function for GetUser{Music,Pictures,Video}Directory.
30 bool GetUserMediaDirectory(const std::string& xdg_name, 28 bool GetUserMediaDirectory(const std::string& xdg_name,
31 const std::string& fallback_name, 29 const std::string& fallback_name,
32 base::FilePath* result) { 30 base::FilePath* result) {
33 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
34 // No local media directories on CrOS. 32 // No local media directories on CrOS.
35 return false; 33 return false;
36 #else 34 #else
37 *result = GetXDGUserDirectory(xdg_name.c_str(), fallback_name.c_str()); 35 *result = GetXDGUserDirectory(xdg_name.c_str(), fallback_name.c_str());
38 36
39 base::FilePath home; 37 base::FilePath home = base::GetHomeDir();
40 PathService::Get(base::DIR_HOME, &home);
41 if (*result != home) { 38 if (*result != home) {
42 base::FilePath desktop; 39 base::FilePath desktop;
43 if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop)) 40 if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop))
44 return false; 41 return false;
45 if (*result != desktop) { 42 if (*result != desktop) {
46 return true; 43 return true;
47 } 44 }
48 } 45 }
49 46
50 *result = home.Append(fallback_name); 47 *result = home.Append(fallback_name);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 96
100 *result = cache_dir; 97 *result = cache_dir;
101 } 98 }
102 99
103 bool GetUserDocumentsDirectory(base::FilePath* result) { 100 bool GetUserDocumentsDirectory(base::FilePath* result) {
104 *result = GetXDGUserDirectory("DOCUMENTS", "Documents"); 101 *result = GetXDGUserDirectory("DOCUMENTS", "Documents");
105 return true; 102 return true;
106 } 103 }
107 104
108 bool GetUserDownloadsDirectorySafe(base::FilePath* result) { 105 bool GetUserDownloadsDirectorySafe(base::FilePath* result) {
109 base::FilePath home; 106 base::FilePath home = base::GetHomeDir();
110 PathService::Get(base::DIR_HOME, &home);
111 *result = home.Append(kDownloadsDir); 107 *result = home.Append(kDownloadsDir);
112 return true; 108 return true;
113 } 109 }
114 110
115 bool GetUserDownloadsDirectory(base::FilePath* result) { 111 bool GetUserDownloadsDirectory(base::FilePath* result) {
116 *result = GetXDGUserDirectory("DOWNLOAD", kDownloadsDir); 112 *result = GetXDGUserDirectory("DOWNLOAD", kDownloadsDir);
117 return true; 113 return true;
118 } 114 }
119 115
120 // We respect the user's preferred pictures location, unless it is 116 // We respect the user's preferred pictures location, unless it is
(...skipping 15 matching lines...) Expand all
136 } 132 }
137 133
138 bool ProcessNeedsProfileDir(const std::string& process_type) { 134 bool ProcessNeedsProfileDir(const std::string& process_type) {
139 // For now we have no reason to forbid this on Linux as we don't 135 // For now we have no reason to forbid this on Linux as we don't
140 // have the roaming profile troubles there. Moreover the Linux breakpad needs 136 // have the roaming profile troubles there. Moreover the Linux breakpad needs
141 // profile dir access in all process if enabled on Linux. 137 // profile dir access in all process if enabled on Linux.
142 return true; 138 return true;
143 } 139 }
144 140
145 } // namespace chrome 141 } // namespace chrome
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/diagnostics/sqlite_diagnostics.cc ('k') | trunk/src/chrome/common/chrome_paths_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698