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/message_loop/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 bool file_chooser_enabled_; | 65 bool file_chooser_enabled_; |
66 bool file_chooser_displayed_; | 66 bool file_chooser_displayed_; |
67 base::WeakPtrFactory<MockDownloadManagerDelegate> weak_ptr_factory_; | 67 base::WeakPtrFactory<MockDownloadManagerDelegate> weak_ptr_factory_; |
68 }; | 68 }; |
69 | 69 |
70 DownloadTestFileActivityObserver::DownloadTestFileActivityObserver( | 70 DownloadTestFileActivityObserver::DownloadTestFileActivityObserver( |
71 Profile* profile) { | 71 Profile* profile) { |
72 scoped_ptr<MockDownloadManagerDelegate> mock_delegate( | 72 scoped_ptr<MockDownloadManagerDelegate> mock_delegate( |
73 new MockDownloadManagerDelegate(profile)); | 73 new MockDownloadManagerDelegate(profile)); |
74 test_delegate_ = mock_delegate->GetWeakPtr(); | 74 test_delegate_ = mock_delegate->GetWeakPtr(); |
75 DownloadServiceFactory::GetForBrowserContext(profile)-> | 75 DownloadServiceFactory::GetForBrowserContext(profile) |
76 SetDownloadManagerDelegateForTesting( | 76 ->SetDownloadManagerDelegateForTesting(mock_delegate.Pass()); |
77 mock_delegate.PassAs<ChromeDownloadManagerDelegate>()); | |
78 } | 77 } |
79 | 78 |
80 DownloadTestFileActivityObserver::~DownloadTestFileActivityObserver() { | 79 DownloadTestFileActivityObserver::~DownloadTestFileActivityObserver() { |
81 } | 80 } |
82 | 81 |
83 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { | 82 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { |
84 if (test_delegate_.get()) | 83 if (test_delegate_.get()) |
85 test_delegate_->EnableFileChooser(enable); | 84 test_delegate_->EnableFileChooser(enable); |
86 } | 85 } |
87 | 86 |
88 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { | 87 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { |
89 return test_delegate_.get() && | 88 return test_delegate_.get() && |
90 test_delegate_->TestAndResetDidShowFileChooser(); | 89 test_delegate_->TestAndResetDidShowFileChooser(); |
91 } | 90 } |
OLD | NEW |