| 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/message_loop.h" |   8 #include "base/location.h" | 
 |   9 #include "base/single_thread_task_runner.h" | 
 |  10 #include "base/thread_task_runner_handle.h" | 
|   9 #include "chrome/browser/download/chrome_download_manager_delegate.h" |  11 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 
|  10 #include "chrome/browser/download/download_service.h" |  12 #include "chrome/browser/download/download_service.h" | 
|  11 #include "chrome/browser/download/download_service_factory.h" |  13 #include "chrome/browser/download/download_service_factory.h" | 
|  12 #include "chrome/browser/profiles/profile.h" |  14 #include "chrome/browser/profiles/profile.h" | 
|  13  |  15  | 
|  14 namespace content { |  16 namespace content { | 
|  15 class DownloadItem; |  17 class DownloadItem; | 
|  16 } |  18 } | 
|  17  |  19  | 
|  18 // Test ChromeDownloadManagerDelegate that controls whether how file chooser |  20 // Test ChromeDownloadManagerDelegate that controls whether how file chooser | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
|  46   base::WeakPtr<MockDownloadManagerDelegate> GetWeakPtr() { |  48   base::WeakPtr<MockDownloadManagerDelegate> GetWeakPtr() { | 
|  47     return weak_ptr_factory_.GetWeakPtr(); |  49     return weak_ptr_factory_.GetWeakPtr(); | 
|  48   } |  50   } | 
|  49  |  51  | 
|  50  protected: |  52  protected: | 
|  51   void PromptUserForDownloadPath( |  53   void PromptUserForDownloadPath( | 
|  52       content::DownloadItem* item, |  54       content::DownloadItem* item, | 
|  53       const base::FilePath& suggested_path, |  55       const base::FilePath& suggested_path, | 
|  54       const FileSelectedCallback& callback) override { |  56       const FileSelectedCallback& callback) override { | 
|  55     file_chooser_displayed_ = true; |  57     file_chooser_displayed_ = true; | 
|  56     base::MessageLoop::current()->PostTask( |  58     base::ThreadTaskRunnerHandle::Get()->PostTask( | 
|  57         FROM_HERE, base::Bind(callback, (file_chooser_enabled_ ? suggested_path |  59         FROM_HERE, | 
|  58                                          : base::FilePath()))); |  60         base::Bind(callback, (file_chooser_enabled_ ? suggested_path | 
 |  61                                                     : base::FilePath()))); | 
|  59   } |  62   } | 
|  60  |  63  | 
|  61   void OpenDownload(content::DownloadItem* item) override {} |  64   void OpenDownload(content::DownloadItem* item) override {} | 
|  62  |  65  | 
|  63  private: |  66  private: | 
|  64   bool file_chooser_enabled_; |  67   bool file_chooser_enabled_; | 
|  65   bool file_chooser_displayed_; |  68   bool file_chooser_displayed_; | 
|  66   base::WeakPtrFactory<MockDownloadManagerDelegate> weak_ptr_factory_; |  69   base::WeakPtrFactory<MockDownloadManagerDelegate> weak_ptr_factory_; | 
|  67 }; |  70 }; | 
|  68  |  71  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  80  |  83  | 
|  81 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { |  84 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { | 
|  82   if (test_delegate_.get()) |  85   if (test_delegate_.get()) | 
|  83     test_delegate_->EnableFileChooser(enable); |  86     test_delegate_->EnableFileChooser(enable); | 
|  84 } |  87 } | 
|  85  |  88  | 
|  86 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { |  89 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { | 
|  87   return test_delegate_.get() && |  90   return test_delegate_.get() && | 
|  88       test_delegate_->TestAndResetDidShowFileChooser(); |  91       test_delegate_->TestAndResetDidShowFileChooser(); | 
|  89 } |  92 } | 
| OLD | NEW |