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_test_file_activity_observer.h" | 5 #include "chrome/browser/download/download_test_file_activity_observer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 9 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 10 #include "chrome/browser/download/download_service.h" | 10 #include "chrome/browser/download/download_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool TestAndResetDidShowFileChooser() { | 33 bool TestAndResetDidShowFileChooser() { |
| 34 bool did_show = file_chooser_displayed_; | 34 bool did_show = file_chooser_displayed_; |
| 35 file_chooser_displayed_ = false; | 35 file_chooser_displayed_ = false; |
| 36 return did_show; | 36 return did_show; |
| 37 } | 37 } |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 | 40 |
| 41 virtual void ChooseDownloadPath(content::DownloadItem* item, | 41 virtual void PromptUserForDownloadPath( |
| 42 const base::FilePath& suggested_path, | 42 content::DownloadItem* item, |
| 43 const FileSelectedCallback& | 43 const base::FilePath& suggested_path, |
| 44 callback) OVERRIDE { | 44 const DownloadTargetDeterminerDelegate::FileSelectedCallback& |
| 45 callback) OVERRIDE { | |
| 46 base::FilePath target_path = | |
| 47 file_chooser_enabled_ ? suggested_path : base::FilePath(); | |
| 45 file_chooser_displayed_ = true; | 48 file_chooser_displayed_ = true; |
| 46 MessageLoop::current()->PostTask( | 49 MessageLoop::current()->PostTask( |
| 47 FROM_HERE, base::Bind(callback, (file_chooser_enabled_ ? suggested_path | 50 FROM_HERE, base::Bind(callback, target_path)); |
|
Randy Smith (Not in Mondays)
2013/04/26 19:05:46
Why the change? I don't object, but it looks sema
asanka
2013/04/29 18:43:20
Ah. This was an artifact of doing and undoing a fe
| |
| 48 : base::FilePath()))); | |
| 49 } | 51 } |
| 50 | 52 |
| 51 virtual void OpenDownload(content::DownloadItem* item) OVERRIDE {} | 53 virtual void OpenDownload(content::DownloadItem* item) OVERRIDE {} |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 virtual ~MockDownloadManagerDelegate() {} | 56 virtual ~MockDownloadManagerDelegate() {} |
| 55 | 57 |
| 56 bool file_chooser_enabled_; | 58 bool file_chooser_enabled_; |
| 57 bool file_chooser_displayed_; | 59 bool file_chooser_displayed_; |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 DownloadTestFileActivityObserver::DownloadTestFileActivityObserver( | 62 DownloadTestFileActivityObserver::DownloadTestFileActivityObserver( |
| 61 Profile* profile) { | 63 Profile* profile) { |
| 62 test_delegate_ = new MockDownloadManagerDelegate(profile); | 64 test_delegate_ = new MockDownloadManagerDelegate(profile); |
| 63 DownloadServiceFactory::GetForProfile(profile)-> | 65 DownloadServiceFactory::GetForProfile(profile)-> |
| 64 SetDownloadManagerDelegateForTesting(test_delegate_.get()); | 66 SetDownloadManagerDelegateForTesting(test_delegate_.get()); |
| 65 } | 67 } |
| 66 | 68 |
| 67 DownloadTestFileActivityObserver::~DownloadTestFileActivityObserver() { | 69 DownloadTestFileActivityObserver::~DownloadTestFileActivityObserver() { |
| 68 } | 70 } |
| 69 | 71 |
| 70 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { | 72 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { |
| 71 test_delegate_->EnableFileChooser(enable); | 73 test_delegate_->EnableFileChooser(enable); |
| 72 } | 74 } |
| 73 | 75 |
| 74 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { | 76 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { |
| 75 return test_delegate_->TestAndResetDidShowFileChooser(); | 77 return test_delegate_->TestAndResetDidShowFileChooser(); |
| 76 } | 78 } |
| OLD | NEW |