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

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

Issue 10241007: Linux: Use the same safe downloads logic as Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix autocompletion failure Created 8 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
« no previous file with comments | « chrome/common/chrome_paths_internal.h ('k') | no next file » | 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) 2011 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/path_service.h" 10 #include "base/path_service.h"
11 #include "base/nix/xdg_util.h" 11 #include "base/nix/xdg_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #endif 77 #endif
78 return true; 78 return true;
79 } 79 }
80 80
81 bool GetUserDocumentsDirectory(FilePath* result) { 81 bool GetUserDocumentsDirectory(FilePath* result) {
82 scoped_ptr<base::Environment> env(base::Environment::Create()); 82 scoped_ptr<base::Environment> env(base::Environment::Create());
83 *result = base::nix::GetXDGUserDirectory(env.get(), "DOCUMENTS", "Documents"); 83 *result = base::nix::GetXDGUserDirectory(env.get(), "DOCUMENTS", "Documents");
84 return true; 84 return true;
85 } 85 }
86 86
87 // We respect the user's preferred download location, unless it is 87 bool GetUserDownloadsDirectorySafe(FilePath* result) {
88 // ~ or their desktop directory, in which case we default to ~/Downloads. 88 FilePath home = file_util::GetHomeDir();
89 *result = home.Append(kDownloadsDir);
90 return true;
91 }
92
89 bool GetUserDownloadsDirectory(FilePath* result) { 93 bool GetUserDownloadsDirectory(FilePath* result) {
90 scoped_ptr<base::Environment> env(base::Environment::Create()); 94 scoped_ptr<base::Environment> env(base::Environment::Create());
91 *result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD", 95 *result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD",
92 kDownloadsDir); 96 kDownloadsDir);
93
94 FilePath home = file_util::GetHomeDir();
95 if (*result == home) {
96 *result = home.Append(kDownloadsDir);
97 return true;
98 }
99
100 FilePath desktop;
101 GetUserDesktop(&desktop);
102 if (*result == desktop) {
103 *result = home.Append(kDownloadsDir);
104 }
105
106 return true; 97 return true;
107 } 98 }
108 99
109 bool GetUserDesktop(FilePath* result) { 100 bool GetUserDesktop(FilePath* result) {
110 scoped_ptr<base::Environment> env(base::Environment::Create()); 101 scoped_ptr<base::Environment> env(base::Environment::Create());
111 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); 102 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop");
112 return true; 103 return true;
113 } 104 }
114 105
115 } // namespace chrome 106 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698