OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/safe_browsing/incident_reporting/last_download_finder.h
" | 5 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h
" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
19 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 scoped_ptr<history::HistoryService> history_service( | 68 scoped_ptr<history::HistoryService> history_service( |
69 new history::HistoryService( | 69 new history::HistoryService( |
70 make_scoped_ptr(new ChromeHistoryClient( | 70 make_scoped_ptr(new ChromeHistoryClient( |
71 BookmarkModelFactory::GetForProfile(profile))), | 71 BookmarkModelFactory::GetForProfile(profile))), |
72 scoped_ptr<history::VisitDelegate>())); | 72 scoped_ptr<history::VisitDelegate>())); |
73 if (history_service->Init( | 73 if (history_service->Init( |
74 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 74 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
75 history::HistoryDatabaseParamsForPath(profile->GetPath()))) { | 75 history::HistoryDatabaseParamsForPath(profile->GetPath()))) { |
76 return history_service.Pass(); | 76 return std::move(history_service); |
77 } | 77 } |
78 | 78 |
79 ADD_FAILURE() << "failed to initialize history service"; | 79 ADD_FAILURE() << "failed to initialize history service"; |
80 return nullptr; | 80 return nullptr; |
81 } | 81 } |
82 | 82 |
83 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
84 static const base::FilePath::CharType kBinaryFileName[] = | 84 static const base::FilePath::CharType kBinaryFileName[] = |
85 FILE_PATH_LITERAL("spam.exe"); | 85 FILE_PATH_LITERAL("spam.exe"); |
86 static const base::FilePath::CharType kBinaryFileNameForOtherOS[] = | 86 static const base::FilePath::CharType kBinaryFileNameForOtherOS[] = |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // LastDownloadFinder::LastDownloadCallback implementation that | 131 // LastDownloadFinder::LastDownloadCallback implementation that |
132 // passes the found download to |result| and then runs a closure. | 132 // passes the found download to |result| and then runs a closure. |
133 void OnLastDownload(scoped_ptr<ClientIncidentReport_DownloadDetails>* result, | 133 void OnLastDownload(scoped_ptr<ClientIncidentReport_DownloadDetails>* result, |
134 scoped_ptr<ClientIncidentReport_NonBinaryDownloadDetails>* | 134 scoped_ptr<ClientIncidentReport_NonBinaryDownloadDetails>* |
135 non_binary_result, | 135 non_binary_result, |
136 const base::Closure& quit_closure, | 136 const base::Closure& quit_closure, |
137 scoped_ptr<ClientIncidentReport_DownloadDetails> download, | 137 scoped_ptr<ClientIncidentReport_DownloadDetails> download, |
138 scoped_ptr<ClientIncidentReport_NonBinaryDownloadDetails> | 138 scoped_ptr<ClientIncidentReport_NonBinaryDownloadDetails> |
139 non_binary_download) { | 139 non_binary_download) { |
140 *result = download.Pass(); | 140 *result = std::move(download); |
141 *non_binary_result = non_binary_download.Pass(); | 141 *non_binary_result = std::move(non_binary_download); |
142 quit_closure.Run(); | 142 quit_closure.Run(); |
143 } | 143 } |
144 | 144 |
145 protected: | 145 protected: |
146 // A type for specifying whether or not a profile created by CreateProfile | 146 // A type for specifying whether or not a profile created by CreateProfile |
147 // participates in safe browsing. | 147 // participates in safe browsing. |
148 enum SafeBrowsingDisposition { | 148 enum SafeBrowsingDisposition { |
149 SAFE_BROWSING_OPT_OUT, | 149 SAFE_BROWSING_OPT_OUT, |
150 SAFE_BROWSING_OPT_IN, | 150 SAFE_BROWSING_OPT_IN, |
151 EXTENDED_REPORTING_OPT_IN, | 151 EXTENDED_REPORTING_OPT_IN, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // Create prefs for the profile with safe browsing enabled or not. | 190 // Create prefs for the profile with safe browsing enabled or not. |
191 scoped_ptr<syncable_prefs::TestingPrefServiceSyncable> prefs( | 191 scoped_ptr<syncable_prefs::TestingPrefServiceSyncable> prefs( |
192 new syncable_prefs::TestingPrefServiceSyncable); | 192 new syncable_prefs::TestingPrefServiceSyncable); |
193 chrome::RegisterUserProfilePrefs(prefs->registry()); | 193 chrome::RegisterUserProfilePrefs(prefs->registry()); |
194 prefs->SetBoolean(prefs::kSafeBrowsingEnabled, | 194 prefs->SetBoolean(prefs::kSafeBrowsingEnabled, |
195 safe_browsing_opt_in != SAFE_BROWSING_OPT_OUT); | 195 safe_browsing_opt_in != SAFE_BROWSING_OPT_OUT); |
196 prefs->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, | 196 prefs->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, |
197 safe_browsing_opt_in == EXTENDED_REPORTING_OPT_IN); | 197 safe_browsing_opt_in == EXTENDED_REPORTING_OPT_IN); |
198 | 198 |
199 TestingProfile* profile = profile_manager_->CreateTestingProfile( | 199 TestingProfile* profile = profile_manager_->CreateTestingProfile( |
200 profile_name, | 200 profile_name, std::move(prefs), |
201 prefs.Pass(), | |
202 base::UTF8ToUTF16(profile_name), // user_name | 201 base::UTF8ToUTF16(profile_name), // user_name |
203 0, // avatar_id | 202 0, // avatar_id |
204 std::string(), // supervised_user_id | 203 std::string(), // supervised_user_id |
205 factories); | 204 factories); |
206 | 205 |
207 return profile; | 206 return profile; |
208 } | 207 } |
209 | 208 |
210 LastDownloadFinder::DownloadDetailsGetter GetDownloadDetailsGetter() { | 209 LastDownloadFinder::DownloadDetailsGetter GetDownloadDetailsGetter() { |
211 return base::Bind(&LastDownloadFinderTest::GetDownloadDetails, | 210 return base::Bind(&LastDownloadFinderTest::GetDownloadDetails, |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 base::Bind(&LastDownloadFinderTest::OnLastDownload, | 451 base::Bind(&LastDownloadFinderTest::OnLastDownload, |
453 base::Unretained(this), &last_binary_download, | 452 base::Unretained(this), &last_binary_download, |
454 &last_non_binary_download, run_loop.QuitClosure()))); | 453 &last_non_binary_download, run_loop.QuitClosure()))); |
455 | 454 |
456 run_loop.Run(); | 455 run_loop.Run(); |
457 | 456 |
458 ASSERT_TRUE(last_binary_download); | 457 ASSERT_TRUE(last_binary_download); |
459 } | 458 } |
460 | 459 |
461 } // namespace safe_browsing | 460 } // namespace safe_browsing |
OLD | NEW |