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

Side by Side Diff: chrome/browser/download/download_prefs.cc

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: l10n again Created 3 years, 9 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
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/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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 return (download_path == desktop_dir); 75 return (download_path == desktop_dir);
76 #endif 76 #endif
77 } 77 }
78 78
79 class DefaultDownloadDirectory { 79 class DefaultDownloadDirectory {
80 public: 80 public:
81 const base::FilePath& path() const { return path_; } 81 const base::FilePath& path() const { return path_; }
82 82
83 private: 83 private:
84 friend struct base::DefaultLazyInstanceTraits<DefaultDownloadDirectory>; 84 friend struct base::LazyInstanceTraitsBase<DefaultDownloadDirectory>;
85 85
86 DefaultDownloadDirectory() { 86 DefaultDownloadDirectory() {
87 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &path_)) { 87 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &path_)) {
88 NOTREACHED(); 88 NOTREACHED();
89 } 89 }
90 if (DownloadPathIsDangerous(path_)) { 90 if (DownloadPathIsDangerous(path_)) {
91 // This is only useful on platforms that support 91 // This is only useful on platforms that support
92 // DIR_DEFAULT_DOWNLOADS_SAFE. 92 // DIR_DEFAULT_DOWNLOADS_SAFE.
93 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS_SAFE, &path_)) { 93 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS_SAFE, &path_)) {
94 NOTREACHED(); 94 NOTREACHED();
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 base::FilePath path_; 99 base::FilePath path_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(DefaultDownloadDirectory); 101 DISALLOW_COPY_AND_ASSIGN(DefaultDownloadDirectory);
102 }; 102 };
103 103
104 base::LazyInstance<DefaultDownloadDirectory> 104 base::LazyInstance<DefaultDownloadDirectory>::DestructorAtExit
105 g_default_download_directory = LAZY_INSTANCE_INITIALIZER; 105 g_default_download_directory = LAZY_INSTANCE_INITIALIZER;
106 106
107 } // namespace 107 } // namespace
108 108
109 DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) { 109 DownloadPrefs::DownloadPrefs(Profile* profile) : profile_(profile) {
110 PrefService* prefs = profile->GetPrefs(); 110 PrefService* prefs = profile->GetPrefs();
111 111
112 #if defined(OS_CHROMEOS) 112 #if defined(OS_CHROMEOS)
113 // On Chrome OS, the default download directory is different for each profile. 113 // On Chrome OS, the default download directory is different for each profile.
114 // If the profile-unaware default path (from GetDefaultDownloadDirectory()) 114 // If the profile-unaware default path (from GetDefaultDownloadDirectory())
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 extensions.erase(extensions.size() - 1); 382 extensions.erase(extensions.size() - 1);
383 383
384 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions); 384 profile_->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, extensions);
385 } 385 }
386 386
387 bool DownloadPrefs::AutoOpenCompareFunctor::operator()( 387 bool DownloadPrefs::AutoOpenCompareFunctor::operator()(
388 const base::FilePath::StringType& a, 388 const base::FilePath::StringType& a,
389 const base::FilePath::StringType& b) const { 389 const base::FilePath::StringType& b) const {
390 return base::FilePath::CompareLessIgnoreCase(a, b); 390 return base::FilePath::CompareLessIgnoreCase(a, b);
391 } 391 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/device/usb/android_usb_device.cc ('k') | chrome/browser/extensions/activity_log/activity_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698