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/browser/download/download_prefs.h" | 5 #include "chrome/browser/download/download_prefs.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/base_paths.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
(...skipping 20 matching lines...) Expand all Loading... |
40 using content::BrowserContext; | 41 using content::BrowserContext; |
41 using content::BrowserThread; | 42 using content::BrowserThread; |
42 using content::DownloadManager; | 43 using content::DownloadManager; |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 // Consider downloads 'dangerous' if they go to the home directory on Linux and | 47 // Consider downloads 'dangerous' if they go to the home directory on Linux and |
47 // to the desktop on any platform. | 48 // to the desktop on any platform. |
48 bool DownloadPathIsDangerous(const base::FilePath& download_path) { | 49 bool DownloadPathIsDangerous(const base::FilePath& download_path) { |
49 #if defined(OS_LINUX) | 50 #if defined(OS_LINUX) |
50 base::FilePath home_dir = base::GetHomeDir(); | 51 base::FilePath home_dir; |
| 52 PathService::Get(base::DIR_HOME, &home_dir); |
51 if (download_path == home_dir) { | 53 if (download_path == home_dir) { |
52 return true; | 54 return true; |
53 } | 55 } |
54 #endif | 56 #endif |
55 | 57 |
56 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
57 // Android does not have a desktop dir. | 59 // Android does not have a desktop dir. |
58 return false; | 60 return false; |
59 #else | 61 #else |
60 base::FilePath desktop_dir; | 62 base::FilePath desktop_dir; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 extensions.erase(extensions.size() - 1); | 328 extensions.erase(extensions.size() - 1); |
327 | 329 |
328 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 330 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
329 } | 331 } |
330 | 332 |
331 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 333 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
332 const base::FilePath::StringType& a, | 334 const base::FilePath::StringType& a, |
333 const base::FilePath::StringType& b) const { | 335 const base::FilePath::StringType& b) const { |
334 return base::FilePath::CompareLessIgnoreCase(a, b); | 336 return base::FilePath::CompareLessIgnoreCase(a, b); |
335 } | 337 } |
OLD | NEW |