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

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

Issue 625113002: replace OVERRIDE and FINAL with override and final in chrome/browser/[a-i]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix newly added OVERRIDEs Created 6 years, 2 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 manager_->GetAllDownloads(&downloads); 129 manager_->GetAllDownloads(&downloads);
130 if (!downloads.empty()) 130 if (!downloads.empty())
131 return; 131 return;
132 waiting_ = true; 132 waiting_ = true;
133 content::RunMessageLoop(); 133 content::RunMessageLoop();
134 waiting_ = false; 134 waiting_ = false;
135 } 135 }
136 136
137 private: 137 private:
138 virtual void OnDownloadCreated(content::DownloadManager* manager, 138 virtual void OnDownloadCreated(content::DownloadManager* manager,
139 content::DownloadItem* item) OVERRIDE { 139 content::DownloadItem* item) override {
140 DCHECK_EQ(manager_, manager); 140 DCHECK_EQ(manager_, manager);
141 if (waiting_) 141 if (waiting_)
142 base::MessageLoopForUI::current()->Quit(); 142 base::MessageLoopForUI::current()->Quit();
143 } 143 }
144 144
145 content::DownloadManager* manager_; 145 content::DownloadManager* manager_;
146 bool waiting_; 146 bool waiting_;
147 147
148 DISALLOW_COPY_AND_ASSIGN(CreatedObserver); 148 DISALLOW_COPY_AND_ASSIGN(CreatedObserver);
149 }; 149 };
(...skipping 16 matching lines...) Expand all
166 if (item_->GetState() == DownloadItem::COMPLETE) { 166 if (item_->GetState() == DownloadItem::COMPLETE) {
167 return item_->PercentComplete() == 100; 167 return item_->PercentComplete() == 100;
168 } 168 }
169 waiting_ = true; 169 waiting_ = true;
170 content::RunMessageLoop(); 170 content::RunMessageLoop();
171 waiting_ = false; 171 waiting_ = false;
172 return !error_; 172 return !error_;
173 } 173 }
174 174
175 private: 175 private:
176 virtual void OnDownloadUpdated(content::DownloadItem* item) OVERRIDE { 176 virtual void OnDownloadUpdated(content::DownloadItem* item) override {
177 DCHECK_EQ(item_, item); 177 DCHECK_EQ(item_, item);
178 if (!error_ && 178 if (!error_ &&
179 ((prev_percent_ > item_->PercentComplete()) || 179 ((prev_percent_ > item_->PercentComplete()) ||
180 (item_->GetState() == DownloadItem::COMPLETE && 180 (item_->GetState() == DownloadItem::COMPLETE &&
181 (item_->PercentComplete() != 100)))) { 181 (item_->PercentComplete() != 100)))) {
182 error_ = true; 182 error_ = true;
183 if (waiting_) 183 if (waiting_)
184 base::MessageLoopForUI::current()->Quit(); 184 base::MessageLoopForUI::current()->Quit();
185 } 185 }
186 if (item_->GetState() == DownloadItem::COMPLETE && waiting_) 186 if (item_->GetState() == DownloadItem::COMPLETE && waiting_)
187 base::MessageLoopForUI::current()->Quit(); 187 base::MessageLoopForUI::current()->Quit();
188 } 188 }
189 189
190 virtual void OnDownloadDestroyed(content::DownloadItem* item) OVERRIDE { 190 virtual void OnDownloadDestroyed(content::DownloadItem* item) override {
191 DCHECK_EQ(item_, item); 191 DCHECK_EQ(item_, item);
192 item_->RemoveObserver(this); 192 item_->RemoveObserver(this);
193 item_ = NULL; 193 item_ = NULL;
194 } 194 }
195 195
196 content::DownloadItem* item_; 196 content::DownloadItem* item_;
197 bool waiting_; 197 bool waiting_;
198 bool error_; 198 bool error_;
199 int prev_percent_; 199 int prev_percent_;
200 200
(...skipping 11 matching lines...) Expand all
212 size_t transition_count) 212 size_t transition_count)
213 : DownloadTestObserver(download_manager, 1, 213 : DownloadTestObserver(download_manager, 1,
214 ON_DANGEROUS_DOWNLOAD_FAIL), 214 ON_DANGEROUS_DOWNLOAD_FAIL),
215 was_previously_resumable_(false), 215 was_previously_resumable_(false),
216 transitions_left_(transition_count) { 216 transitions_left_(transition_count) {
217 Init(); 217 Init();
218 } 218 }
219 virtual ~DownloadTestObserverResumable() {} 219 virtual ~DownloadTestObserverResumable() {}
220 220
221 private: 221 private:
222 virtual bool IsDownloadInFinalState(DownloadItem* download) OVERRIDE { 222 virtual bool IsDownloadInFinalState(DownloadItem* download) override {
223 bool is_resumable_now = download->CanResume(); 223 bool is_resumable_now = download->CanResume();
224 if (!was_previously_resumable_ && is_resumable_now) 224 if (!was_previously_resumable_ && is_resumable_now)
225 --transitions_left_; 225 --transitions_left_;
226 was_previously_resumable_ = is_resumable_now; 226 was_previously_resumable_ = is_resumable_now;
227 return transitions_left_ == 0; 227 return transitions_left_ == 0;
228 } 228 }
229 229
230 bool was_previously_resumable_; 230 bool was_previously_resumable_;
231 size_t transitions_left_; 231 size_t transitions_left_;
232 232
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { 284 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt {
285 public: 285 public:
286 MockAbortExtensionInstallPrompt() : 286 MockAbortExtensionInstallPrompt() :
287 ExtensionInstallPrompt(NULL) { 287 ExtensionInstallPrompt(NULL) {
288 } 288 }
289 289
290 // Simulate a user abort on an extension installation. 290 // Simulate a user abort on an extension installation.
291 virtual void ConfirmInstall( 291 virtual void ConfirmInstall(
292 Delegate* delegate, 292 Delegate* delegate,
293 const Extension* extension, 293 const Extension* extension,
294 const ShowDialogCallback& show_dialog_callback) OVERRIDE { 294 const ShowDialogCallback& show_dialog_callback) override {
295 delegate->InstallUIAbort(true); 295 delegate->InstallUIAbort(true);
296 base::MessageLoopForUI::current()->Quit(); 296 base::MessageLoopForUI::current()->Quit();
297 } 297 }
298 298
299 virtual void OnInstallSuccess(const Extension* extension, 299 virtual void OnInstallSuccess(const Extension* extension,
300 SkBitmap* icon) OVERRIDE { 300 SkBitmap* icon) override {
301 } 301 }
302 virtual void OnInstallFailure( 302 virtual void OnInstallFailure(
303 const extensions::CrxInstallerError& error) OVERRIDE { 303 const extensions::CrxInstallerError& error) override {
304 } 304 }
305 }; 305 };
306 306
307 // Mock that simulates a permissions dialog where the user allows 307 // Mock that simulates a permissions dialog where the user allows
308 // installation. 308 // installation.
309 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { 309 class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt {
310 public: 310 public:
311 explicit MockAutoConfirmExtensionInstallPrompt( 311 explicit MockAutoConfirmExtensionInstallPrompt(
312 content::WebContents* web_contents) 312 content::WebContents* web_contents)
313 : ExtensionInstallPrompt(web_contents) {} 313 : ExtensionInstallPrompt(web_contents) {}
314 314
315 // Proceed without confirmation prompt. 315 // Proceed without confirmation prompt.
316 virtual void ConfirmInstall( 316 virtual void ConfirmInstall(
317 Delegate* delegate, 317 Delegate* delegate,
318 const Extension* extension, 318 const Extension* extension,
319 const ShowDialogCallback& show_dialog_callback) OVERRIDE { 319 const ShowDialogCallback& show_dialog_callback) override {
320 delegate->InstallUIProceed(); 320 delegate->InstallUIProceed();
321 } 321 }
322 322
323 virtual void OnInstallSuccess(const Extension* extension, 323 virtual void OnInstallSuccess(const Extension* extension,
324 SkBitmap* icon) OVERRIDE { 324 SkBitmap* icon) override {
325 } 325 }
326 virtual void OnInstallFailure( 326 virtual void OnInstallFailure(
327 const extensions::CrxInstallerError& error) OVERRIDE { 327 const extensions::CrxInstallerError& error) override {
328 } 328 }
329 }; 329 };
330 330
331 static DownloadManager* DownloadManagerForBrowser(Browser* browser) { 331 static DownloadManager* DownloadManagerForBrowser(Browser* browser) {
332 return BrowserContext::GetDownloadManager(browser->profile()); 332 return BrowserContext::GetDownloadManager(browser->profile());
333 } 333 }
334 334
335 bool WasAutoOpened(DownloadItem* item) { 335 bool WasAutoOpened(DownloadItem* item) {
336 return item->GetAutoOpened(); 336 return item->GetAutoOpened();
337 } 337 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (service && service->GetDownloadHistory()) 387 if (service && service->GetDownloadHistory())
388 service->GetDownloadHistory()->RemoveObserver(this); 388 service->GetDownloadHistory()->RemoveObserver(this);
389 } 389 }
390 390
391 void SetFilterCallback(const FilterCallback& callback) { 391 void SetFilterCallback(const FilterCallback& callback) {
392 callback_ = callback; 392 callback_ = callback;
393 } 393 }
394 394
395 virtual void OnDownloadStored( 395 virtual void OnDownloadStored(
396 content::DownloadItem* item, 396 content::DownloadItem* item,
397 const history::DownloadRow& info) OVERRIDE { 397 const history::DownloadRow& info) override {
398 if (!callback_.is_null() && (!callback_.Run(info))) 398 if (!callback_.is_null() && (!callback_.Run(info)))
399 return; 399 return;
400 400
401 seen_stored_ = true; 401 seen_stored_ = true;
402 if (waiting_) 402 if (waiting_)
403 base::MessageLoopForUI::current()->Quit(); 403 base::MessageLoopForUI::current()->Quit();
404 } 404 }
405 405
406 virtual void OnDownloadHistoryDestroyed() OVERRIDE { 406 virtual void OnDownloadHistoryDestroyed() override {
407 DownloadServiceFactory::GetForBrowserContext(profile_)-> 407 DownloadServiceFactory::GetForBrowserContext(profile_)->
408 GetDownloadHistory()->RemoveObserver(this); 408 GetDownloadHistory()->RemoveObserver(this);
409 } 409 }
410 410
411 void WaitForStored() { 411 void WaitForStored() {
412 if (seen_stored_) 412 if (seen_stored_)
413 return; 413 return;
414 waiting_ = true; 414 waiting_ = true;
415 content::RunMessageLoop(); 415 content::RunMessageLoop();
416 waiting_ = false; 416 waiting_ = false;
(...skipping 26 matching lines...) Expand all
443 bool should_redirect_to_documents; // True if we save it in "My Documents". 443 bool should_redirect_to_documents; // True if we save it in "My Documents".
444 }; 444 };
445 445
446 struct FileErrorInjectInfo { 446 struct FileErrorInjectInfo {
447 DownloadInfo download_info; 447 DownloadInfo download_info;
448 content::TestFileErrorInjector::FileErrorInfo error_info; 448 content::TestFileErrorInjector::FileErrorInfo error_info;
449 }; 449 };
450 450
451 DownloadTest() {} 451 DownloadTest() {}
452 452
453 virtual void SetUpOnMainThread() OVERRIDE { 453 virtual void SetUpOnMainThread() override {
454 BrowserThread::PostTask( 454 BrowserThread::PostTask(
455 BrowserThread::IO, FROM_HERE, 455 BrowserThread::IO, FROM_HERE,
456 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); 456 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
457 ASSERT_TRUE(InitialSetup()); 457 ASSERT_TRUE(InitialSetup());
458 } 458 }
459 459
460 virtual void TearDownOnMainThread() OVERRIDE { 460 virtual void TearDownOnMainThread() override {
461 // Needs to be torn down on the main thread. file_activity_observer_ holds a 461 // Needs to be torn down on the main thread. file_activity_observer_ holds a
462 // reference to the ChromeDownloadManagerDelegate which should be destroyed 462 // reference to the ChromeDownloadManagerDelegate which should be destroyed
463 // on the UI thread. 463 // on the UI thread.
464 file_activity_observer_.reset(); 464 file_activity_observer_.reset();
465 } 465 }
466 466
467 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 467 virtual void SetUpCommandLine(CommandLine* command_line) override {
468 command_line->AppendSwitch(switches::kDisablePluginsDiscovery); 468 command_line->AppendSwitch(switches::kDisablePluginsDiscovery);
469 } 469 }
470 470
471 // Returning false indicates a failure of the setup, and should be asserted 471 // Returning false indicates a failure of the setup, and should be asserted
472 // in the caller. 472 // in the caller.
473 virtual bool InitialSetup() { 473 virtual bool InitialSetup() {
474 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); 474 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_);
475 EXPECT_TRUE(have_test_dir); 475 EXPECT_TRUE(have_test_dir);
476 if (!have_test_dir) 476 if (!have_test_dir)
477 return false; 477 return false;
(...skipping 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 explicit DisableSafeBrowsingOnInProgressDownload(Browser* browser) 3365 explicit DisableSafeBrowsingOnInProgressDownload(Browser* browser)
3366 : DownloadTestObserver(DownloadManagerForBrowser(browser), 3366 : DownloadTestObserver(DownloadManagerForBrowser(browser),
3367 1, 3367 1,
3368 ON_DANGEROUS_DOWNLOAD_QUIT), 3368 ON_DANGEROUS_DOWNLOAD_QUIT),
3369 browser_(browser), 3369 browser_(browser),
3370 final_state_seen_(false) { 3370 final_state_seen_(false) {
3371 Init(); 3371 Init();
3372 } 3372 }
3373 virtual ~DisableSafeBrowsingOnInProgressDownload() {} 3373 virtual ~DisableSafeBrowsingOnInProgressDownload() {}
3374 3374
3375 virtual bool IsDownloadInFinalState(DownloadItem* download) OVERRIDE { 3375 virtual bool IsDownloadInFinalState(DownloadItem* download) override {
3376 if (download->GetState() != DownloadItem::IN_PROGRESS || 3376 if (download->GetState() != DownloadItem::IN_PROGRESS ||
3377 download->GetTargetFilePath().empty()) 3377 download->GetTargetFilePath().empty())
3378 return false; 3378 return false;
3379 3379
3380 if (final_state_seen_) 3380 if (final_state_seen_)
3381 return true; 3381 return true;
3382 3382
3383 final_state_seen_ = true; 3383 final_state_seen_ = true;
3384 browser_->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, 3384 browser_->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled,
3385 false); 3385 false);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
3528 *(downloads[0]))); 3528 *(downloads[0])));
3529 3529
3530 // Begin feedback and check that the file is "stolen". 3530 // Begin feedback and check that the file is "stolen".
3531 download_protection_service->feedback_service()->BeginFeedbackForDownload( 3531 download_protection_service->feedback_service()->BeginFeedbackForDownload(
3532 downloads[0]); 3532 downloads[0]);
3533 std::vector<DownloadItem*> updated_downloads; 3533 std::vector<DownloadItem*> updated_downloads;
3534 GetDownloads(browser(), &updated_downloads); 3534 GetDownloads(browser(), &updated_downloads);
3535 ASSERT_TRUE(updated_downloads.empty()); 3535 ASSERT_TRUE(updated_downloads.empty());
3536 } 3536 }
3537 #endif 3537 #endif
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.h ('k') | chrome/browser/download/download_danger_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698