Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/safe_browsing/file_type_policies.h" | 30 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 31 #include "components/pref_registry/pref_registry_syncable.h" | 31 #include "components/pref_registry/pref_registry_syncable.h" |
| 32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/download_manager.h" | 34 #include "content/public/browser/download_manager.h" |
| 35 #include "content/public/browser/save_page_type.h" | 35 #include "content/public/browser/save_page_type.h" |
| 36 | 36 |
| 37 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 38 #include "chrome/browser/shell_integration_linux.h" | |
| 39 #endif | |
| 40 | |
| 37 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
| 38 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 42 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 39 #include "chrome/browser/chromeos/drive/file_system_util.h" | 43 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 40 #include "chrome/browser/chromeos/file_manager/path_util.h" | 44 #include "chrome/browser/chromeos/file_manager/path_util.h" |
| 41 #endif | 45 #endif |
| 42 | 46 |
| 43 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 44 #include "chrome/browser/ui/pdf/adobe_reader_info_win.h" | 48 #include "chrome/browser/ui/pdf/adobe_reader_info_win.h" |
| 45 #endif | 49 #endif |
| 46 | 50 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 #if defined(OS_CHROMEOS) | 252 #if defined(OS_CHROMEOS) |
| 249 // If the download path is under /drive, and DriveIntegrationService isn't | 253 // If the download path is under /drive, and DriveIntegrationService isn't |
| 250 // available (which it isn't for incognito mode, for instance), use the | 254 // available (which it isn't for incognito mode, for instance), use the |
| 251 // default download directory (/Downloads). | 255 // default download directory (/Downloads). |
| 252 if (drive::util::IsUnderDriveMountPoint(*download_path_)) { | 256 if (drive::util::IsUnderDriveMountPoint(*download_path_)) { |
| 253 drive::DriveIntegrationService* integration_service = | 257 drive::DriveIntegrationService* integration_service = |
| 254 drive::DriveIntegrationServiceFactory::FindForProfile(profile_); | 258 drive::DriveIntegrationServiceFactory::FindForProfile(profile_); |
| 255 if (!integration_service || !integration_service->is_enabled()) | 259 if (!integration_service || !integration_service->is_enabled()) |
| 256 return GetDefaultDownloadDirectoryForProfile(); | 260 return GetDefaultDownloadDirectoryForProfile(); |
| 257 } | 261 } |
| 262 #elif defined(OS_LINUX) | |
| 263 // TODO(thomasanderson): Remove this when all Linux distros with | |
|
qinmin
2017/06/07 14:21:18
This logic would override the |download_path_| set
Tom Anderson
2017/06/07 18:38:38
oops.. done.
Hopefully this will fix the test fail
| |
| 264 // versions of GTK lower than 3.14.7 are no longer supported. This | |
| 265 // should happen when support for Ubuntu Trusty and Debian Jessie | |
| 266 // are removed. | |
| 267 std::unique_ptr<base::Environment> env(base::Environment::Create()); | |
| 268 return shell_integration_linux::GetDataWriteLocation(env.get()); | |
| 258 #endif | 269 #endif |
| 259 return *download_path_; | 270 return *download_path_; |
| 260 } | 271 } |
| 261 | 272 |
| 262 void DownloadPrefs::SetDownloadPath(const base::FilePath& path) { | 273 void DownloadPrefs::SetDownloadPath(const base::FilePath& path) { |
| 263 download_path_.SetValue(path); | 274 download_path_.SetValue(path); |
| 264 SetSaveFilePath(path); | 275 SetSaveFilePath(path); |
| 265 } | 276 } |
| 266 | 277 |
| 267 base::FilePath DownloadPrefs::SaveFilePath() const { | 278 base::FilePath DownloadPrefs::SaveFilePath() const { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 extensions.erase(extensions.size() - 1); | 391 extensions.erase(extensions.size() - 1); |
| 381 | 392 |
| 382 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); | 393 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); |
| 383 } | 394 } |
| 384 | 395 |
| 385 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( | 396 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( |
| 386 const base::FilePath::StringType& a, | 397 const base::FilePath::StringType& a, |
| 387 const base::FilePath::StringType& b) const { | 398 const base::FilePath::StringType& b) const { |
| 388 return base::FilePath::CompareLessIgnoreCase(a, b); | 399 return base::FilePath::CompareLessIgnoreCase(a, b); |
| 389 } | 400 } |
| OLD | NEW |