| 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/test_download_shelf.h" | 5 #include "chrome/browser/download/test_download_shelf.h" |
| 6 | 6 |
| 7 #include "content/public/browser/download_manager.h" | 7 #include "content/public/browser/download_manager.h" |
| 8 | 8 |
| 9 TestDownloadShelf::TestDownloadShelf() | 9 TestDownloadShelf::TestDownloadShelf() |
| 10 : is_showing_(false), | 10 : is_showing_(false), |
| 11 did_add_download_(false) { | 11 did_add_download_(false), |
| 12 download_manager_(NULL) { |
| 12 } | 13 } |
| 13 | 14 |
| 14 TestDownloadShelf::~TestDownloadShelf() { | 15 TestDownloadShelf::~TestDownloadShelf() { |
| 16 if (download_manager_) |
| 17 download_manager_->RemoveObserver(this); |
| 15 } | 18 } |
| 16 | 19 |
| 17 bool TestDownloadShelf::IsShowing() const { | 20 bool TestDownloadShelf::IsShowing() const { |
| 18 return is_showing_; | 21 return is_showing_; |
| 19 } | 22 } |
| 20 | 23 |
| 21 bool TestDownloadShelf::IsClosing() const { | 24 bool TestDownloadShelf::IsClosing() const { |
| 22 return false; | 25 return false; |
| 23 } | 26 } |
| 24 | 27 |
| 25 Browser* TestDownloadShelf::browser() const { | 28 Browser* TestDownloadShelf::browser() const { |
| 26 return NULL; | 29 return NULL; |
| 27 } | 30 } |
| 28 | 31 |
| 29 void TestDownloadShelf::set_download_manager( | 32 void TestDownloadShelf::set_download_manager( |
| 30 content::DownloadManager* download_manager) { | 33 content::DownloadManager* download_manager) { |
| 34 if (download_manager_) |
| 35 download_manager_->RemoveObserver(this); |
| 31 download_manager_ = download_manager; | 36 download_manager_ = download_manager; |
| 37 if (download_manager_) |
| 38 download_manager_->AddObserver(this); |
| 39 } |
| 40 |
| 41 void TestDownloadShelf::ManagerGoingDown(content::DownloadManager* manager) { |
| 42 DCHECK_EQ(manager, download_manager_); |
| 43 download_manager_ = NULL; |
| 32 } | 44 } |
| 33 | 45 |
| 34 void TestDownloadShelf::DoAddDownload(content::DownloadItem* download) { | 46 void TestDownloadShelf::DoAddDownload(content::DownloadItem* download) { |
| 35 did_add_download_ = true; | 47 did_add_download_ = true; |
| 36 } | 48 } |
| 37 | 49 |
| 38 void TestDownloadShelf::DoShow() { | 50 void TestDownloadShelf::DoShow() { |
| 39 is_showing_ = true; | 51 is_showing_ = true; |
| 40 } | 52 } |
| 41 | 53 |
| 42 void TestDownloadShelf::DoClose(CloseReason reason) { | 54 void TestDownloadShelf::DoClose(CloseReason reason) { |
| 43 is_showing_ = false; | 55 is_showing_ = false; |
| 44 } | 56 } |
| 45 | 57 |
| 46 base::TimeDelta TestDownloadShelf::GetTransientDownloadShowDelay() { | 58 base::TimeDelta TestDownloadShelf::GetTransientDownloadShowDelay() { |
| 47 return base::TimeDelta(); | 59 return base::TimeDelta(); |
| 48 } | 60 } |
| 49 | 61 |
| 50 content::DownloadManager* TestDownloadShelf::GetDownloadManager() { | 62 content::DownloadManager* TestDownloadShelf::GetDownloadManager() { |
| 51 return download_manager_.get(); | 63 return download_manager_; |
| 52 } | 64 } |
| OLD | NEW |