OLD | NEW |
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/environment.h" | 7 #include "base/environment.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/nix/xdg_util.h" |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "base/nix/xdg_util.h" | |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 const char kDotConfigDir[] = ".config"; | 15 const char kDotConfigDir[] = ".config"; |
16 const char kDownloadsDir[] = "Downloads"; | 16 const char kDownloadsDir[] = "Downloads"; |
| 17 const char kPicturesDir[] = "Pictures"; |
17 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; | 18 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; |
18 | 19 |
19 } // namespace | 20 } // namespace |
20 | 21 |
21 namespace chrome { | 22 namespace chrome { |
22 | 23 |
23 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html | 24 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html |
24 // for a spec on where config files go. The net effect for most | 25 // for a spec on where config files go. The net effect for most |
25 // systems is we use ~/.config/chromium/ for Chromium and | 26 // systems is we use ~/.config/chromium/ for Chromium and |
26 // ~/.config/google-chrome/ for official builds. | 27 // ~/.config/google-chrome/ for official builds. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return true; | 91 return true; |
91 } | 92 } |
92 | 93 |
93 bool GetUserDownloadsDirectory(FilePath* result) { | 94 bool GetUserDownloadsDirectory(FilePath* result) { |
94 scoped_ptr<base::Environment> env(base::Environment::Create()); | 95 scoped_ptr<base::Environment> env(base::Environment::Create()); |
95 *result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD", | 96 *result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD", |
96 kDownloadsDir); | 97 kDownloadsDir); |
97 return true; | 98 return true; |
98 } | 99 } |
99 | 100 |
| 101 // We respect the user's preferred pictures location, unless it is |
| 102 // ~ or their desktop directory, in which case we default to ~/Pictures. |
| 103 bool GetUserPicturesDirectory(FilePath* result) { |
| 104 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 105 *result = base::nix::GetXDGUserDirectory(env.get(), "PICTURES", kPicturesDir); |
| 106 |
| 107 FilePath home = file_util::GetHomeDir(); |
| 108 if (*result != home) { |
| 109 FilePath desktop; |
| 110 GetUserDesktop(&desktop); |
| 111 if (*result != desktop) { |
| 112 return true; |
| 113 } |
| 114 } |
| 115 |
| 116 *result = home.Append(kPicturesDir); |
| 117 return true; |
| 118 } |
| 119 |
100 bool GetUserDesktop(FilePath* result) { | 120 bool GetUserDesktop(FilePath* result) { |
101 scoped_ptr<base::Environment> env(base::Environment::Create()); | 121 scoped_ptr<base::Environment> env(base::Environment::Create()); |
102 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); | 122 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); |
103 return true; | 123 return true; |
104 } | 124 } |
105 | 125 |
106 bool ProcessNeedsProfileDir(const std::string& process_type) { | 126 bool ProcessNeedsProfileDir(const std::string& process_type) { |
107 // For now we have no reason to forbid this on Linux as we don't | 127 // For now we have no reason to forbid this on Linux as we don't |
108 // have the roaming profile troubles there. Moreover the Linux breakpad needs | 128 // have the roaming profile troubles there. Moreover the Linux breakpad needs |
109 // profile dir access in all process if enabled on Linux. | 129 // profile dir access in all process if enabled on Linux. |
110 return true; | 130 return true; |
111 } | 131 } |
112 | 132 |
113 } // namespace chrome | 133 } // namespace chrome |
OLD | NEW |