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

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

Issue 1880143002: Convert chrome/common to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
« no previous file with comments | « chrome/common/chrome_content_client_unittest.cc ('k') | chrome/common/chrome_paths_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) 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.h"
6
7 #include <memory>
6 8
7 #include "base/base_paths.h" 9 #include "base/base_paths.h"
8 #include "base/environment.h" 10 #include "base/environment.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/nix/xdg_util.h" 12 #include "base/nix/xdg_util.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths_internal.h"
15 16
16 namespace chrome { 17 namespace chrome {
17 18
18 using base::nix::GetXDGDirectory; 19 using base::nix::GetXDGDirectory;
19 using base::nix::GetXDGUserDirectory; 20 using base::nix::GetXDGUserDirectory;
20 using base::nix::kDotConfigDir; 21 using base::nix::kDotConfigDir;
21 using base::nix::kXdgConfigHomeEnvVar; 22 using base::nix::kXdgConfigHomeEnvVar;
22 23
23 namespace { 24 namespace {
24 25
(...skipping 29 matching lines...) Expand all
54 } 55 }
55 56
56 } // namespace 57 } // namespace
57 58
58 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html 59 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
59 // for a spec on where config files go. The net effect for most 60 // for a spec on where config files go. The net effect for most
60 // systems is we use ~/.config/chromium/ for Chromium and 61 // systems is we use ~/.config/chromium/ for Chromium and
61 // ~/.config/google-chrome/ for official builds. 62 // ~/.config/google-chrome/ for official builds.
62 // (This also helps us sidestep issues with other apps grabbing ~/.chromium .) 63 // (This also helps us sidestep issues with other apps grabbing ~/.chromium .)
63 bool GetDefaultUserDataDirectory(base::FilePath* result) { 64 bool GetDefaultUserDataDirectory(base::FilePath* result) {
64 scoped_ptr<base::Environment> env(base::Environment::Create()); 65 std::unique_ptr<base::Environment> env(base::Environment::Create());
65 base::FilePath config_dir(GetXDGDirectory(env.get(), 66 base::FilePath config_dir(GetXDGDirectory(env.get(),
66 kXdgConfigHomeEnvVar, 67 kXdgConfigHomeEnvVar,
67 kDotConfigDir)); 68 kDotConfigDir));
68 #if defined(GOOGLE_CHROME_BUILD) 69 #if defined(GOOGLE_CHROME_BUILD)
69 *result = config_dir.Append("google-chrome"); 70 *result = config_dir.Append("google-chrome");
70 #else 71 #else
71 *result = config_dir.Append("chromium"); 72 *result = config_dir.Append("chromium");
72 #endif 73 #endif
73 return true; 74 return true;
74 } 75 }
75 76
76 void GetUserCacheDirectory(const base::FilePath& profile_dir, 77 void GetUserCacheDirectory(const base::FilePath& profile_dir,
77 base::FilePath* result) { 78 base::FilePath* result) {
78 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html 79 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
79 // for a spec on where cache files go. Our rule is: 80 // for a spec on where cache files go. Our rule is:
80 // - if the user-data-dir in the standard place, 81 // - if the user-data-dir in the standard place,
81 // use same subdirectory of the cache directory. 82 // use same subdirectory of the cache directory.
82 // (this maps ~/.config/google-chrome to ~/.cache/google-chrome as well 83 // (this maps ~/.config/google-chrome to ~/.cache/google-chrome as well
83 // as the same thing for ~/.config/chromium) 84 // as the same thing for ~/.config/chromium)
84 // - otherwise, use the profile dir directly. 85 // - otherwise, use the profile dir directly.
85 86
86 // Default value in cases where any of the following fails. 87 // Default value in cases where any of the following fails.
87 *result = profile_dir; 88 *result = profile_dir;
88 89
89 scoped_ptr<base::Environment> env(base::Environment::Create()); 90 std::unique_ptr<base::Environment> env(base::Environment::Create());
90 91
91 base::FilePath cache_dir; 92 base::FilePath cache_dir;
92 if (!PathService::Get(base::DIR_CACHE, &cache_dir)) 93 if (!PathService::Get(base::DIR_CACHE, &cache_dir))
93 return; 94 return;
94 base::FilePath config_dir(GetXDGDirectory(env.get(), 95 base::FilePath config_dir(GetXDGDirectory(env.get(),
95 kXdgConfigHomeEnvVar, 96 kXdgConfigHomeEnvVar,
96 kDotConfigDir)); 97 kDotConfigDir));
97 98
98 if (!config_dir.AppendRelativePath(profile_dir, &cache_dir)) 99 if (!config_dir.AppendRelativePath(profile_dir, &cache_dir))
99 return; 100 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 138 }
138 139
139 bool ProcessNeedsProfileDir(const std::string& process_type) { 140 bool ProcessNeedsProfileDir(const std::string& process_type) {
140 // For now we have no reason to forbid this on Linux as we don't 141 // For now we have no reason to forbid this on Linux as we don't
141 // have the roaming profile troubles there. Moreover the Linux breakpad needs 142 // have the roaming profile troubles there. Moreover the Linux breakpad needs
142 // profile dir access in all process if enabled on Linux. 143 // profile dir access in all process if enabled on Linux.
143 return true; 144 return true;
144 } 145 }
145 146
146 } // namespace chrome 147 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client_unittest.cc ('k') | chrome/common/chrome_paths_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698