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 <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
11 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 13 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
12 #include "chrome/browser/download/download_service.h" | 14 #include "chrome/browser/download/download_service.h" |
13 #include "chrome/browser/download/download_service_factory.h" | 15 #include "chrome/browser/download/download_service_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 bool file_chooser_displayed_; | 70 bool file_chooser_displayed_; |
69 base::WeakPtrFactory<MockDownloadManagerDelegate> weak_ptr_factory_; | 71 base::WeakPtrFactory<MockDownloadManagerDelegate> weak_ptr_factory_; |
70 }; | 72 }; |
71 | 73 |
72 DownloadTestFileActivityObserver::DownloadTestFileActivityObserver( | 74 DownloadTestFileActivityObserver::DownloadTestFileActivityObserver( |
73 Profile* profile) { | 75 Profile* profile) { |
74 scoped_ptr<MockDownloadManagerDelegate> mock_delegate( | 76 scoped_ptr<MockDownloadManagerDelegate> mock_delegate( |
75 new MockDownloadManagerDelegate(profile)); | 77 new MockDownloadManagerDelegate(profile)); |
76 test_delegate_ = mock_delegate->GetWeakPtr(); | 78 test_delegate_ = mock_delegate->GetWeakPtr(); |
77 DownloadServiceFactory::GetForBrowserContext(profile) | 79 DownloadServiceFactory::GetForBrowserContext(profile) |
78 ->SetDownloadManagerDelegateForTesting(mock_delegate.Pass()); | 80 ->SetDownloadManagerDelegateForTesting(std::move(mock_delegate)); |
79 } | 81 } |
80 | 82 |
81 DownloadTestFileActivityObserver::~DownloadTestFileActivityObserver() { | 83 DownloadTestFileActivityObserver::~DownloadTestFileActivityObserver() { |
82 } | 84 } |
83 | 85 |
84 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { | 86 void DownloadTestFileActivityObserver::EnableFileChooser(bool enable) { |
85 if (test_delegate_.get()) | 87 if (test_delegate_.get()) |
86 test_delegate_->EnableFileChooser(enable); | 88 test_delegate_->EnableFileChooser(enable); |
87 } | 89 } |
88 | 90 |
89 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { | 91 bool DownloadTestFileActivityObserver::TestAndResetDidShowFileChooser() { |
90 return test_delegate_.get() && | 92 return test_delegate_.get() && |
91 test_delegate_->TestAndResetDidShowFileChooser(); | 93 test_delegate_->TestAndResetDidShowFileChooser(); |
92 } | 94 } |
OLD | NEW |