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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/history/download_row.h" | 10 #include "chrome/browser/history/download_row.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 void ForceSendCurrentDownloads() { | 76 void ForceSendCurrentDownloads() { |
77 ScheduleSendCurrentDownloads(); | 77 ScheduleSendCurrentDownloads(); |
78 } | 78 } |
79 | 79 |
80 void reset_downloads_list() { downloads_list_.reset(); } | 80 void reset_downloads_list() { downloads_list_.reset(); } |
81 void reset_download_updated() { download_updated_.reset(); } | 81 void reset_download_updated() { download_updated_.reset(); } |
82 | 82 |
83 protected: | 83 protected: |
84 virtual content::WebContents* GetWebUIWebContents() OVERRIDE { | 84 virtual content::WebContents* GetWebUIWebContents() override { |
85 return NULL; | 85 return NULL; |
86 } | 86 } |
87 | 87 |
88 virtual void CallDownloadsList(const base::ListValue& downloads) OVERRIDE { | 88 virtual void CallDownloadsList(const base::ListValue& downloads) override { |
89 downloads_list_.reset(downloads.DeepCopy()); | 89 downloads_list_.reset(downloads.DeepCopy()); |
90 if (waiting_list_) { | 90 if (waiting_list_) { |
91 content::BrowserThread::PostTask(content::BrowserThread::UI, | 91 content::BrowserThread::PostTask(content::BrowserThread::UI, |
92 FROM_HERE, | 92 FROM_HERE, |
93 base::MessageLoop::QuitClosure()); | 93 base::MessageLoop::QuitClosure()); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 virtual void CallDownloadUpdated(const base::ListValue& download) OVERRIDE { | 97 virtual void CallDownloadUpdated(const base::ListValue& download) override { |
98 download_updated_.reset(download.DeepCopy()); | 98 download_updated_.reset(download.DeepCopy()); |
99 if (waiting_updated_) { | 99 if (waiting_updated_) { |
100 content::BrowserThread::PostTask(content::BrowserThread::UI, | 100 content::BrowserThread::PostTask(content::BrowserThread::UI, |
101 FROM_HERE, | 101 FROM_HERE, |
102 base::MessageLoop::QuitClosure()); | 102 base::MessageLoop::QuitClosure()); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 private: | 106 private: |
107 scoped_ptr<base::ListValue> downloads_list_; | 107 scoped_ptr<base::ListValue> downloads_list_; |
108 scoped_ptr<base::ListValue> download_updated_; | 108 scoped_ptr<base::ListValue> download_updated_; |
109 bool waiting_list_; | 109 bool waiting_list_; |
110 bool waiting_updated_; | 110 bool waiting_updated_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(MockDownloadsDOMHandler); | 112 DISALLOW_COPY_AND_ASSIGN(MockDownloadsDOMHandler); |
113 }; | 113 }; |
114 | 114 |
115 } // namespace | 115 } // namespace |
116 | 116 |
117 class DownloadsDOMHandlerTest : public InProcessBrowserTest { | 117 class DownloadsDOMHandlerTest : public InProcessBrowserTest { |
118 public: | 118 public: |
119 DownloadsDOMHandlerTest() {} | 119 DownloadsDOMHandlerTest() {} |
120 | 120 |
121 virtual ~DownloadsDOMHandlerTest() {} | 121 virtual ~DownloadsDOMHandlerTest() {} |
122 | 122 |
123 virtual void SetUpOnMainThread() OVERRIDE { | 123 virtual void SetUpOnMainThread() override { |
124 mock_handler_.reset(new MockDownloadsDOMHandler(download_manager())); | 124 mock_handler_.reset(new MockDownloadsDOMHandler(download_manager())); |
125 CHECK(downloads_directory_.CreateUniqueTempDir()); | 125 CHECK(downloads_directory_.CreateUniqueTempDir()); |
126 browser()->profile()->GetPrefs()->SetFilePath( | 126 browser()->profile()->GetPrefs()->SetFilePath( |
127 prefs::kDownloadDefaultDirectory, | 127 prefs::kDownloadDefaultDirectory, |
128 downloads_directory_.path()); | 128 downloads_directory_.path()); |
129 CHECK(test_server()->Start()); | 129 CHECK(test_server()->Start()); |
130 } | 130 } |
131 | 131 |
132 content::DownloadManager* download_manager() { | 132 content::DownloadManager* download_manager() { |
133 return content::BrowserContext::GetDownloadManager(browser()->profile()); | 133 return content::BrowserContext::GetDownloadManager(browser()->profile()); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // TODO(benjhayden): Test incognito, both downloads_list() and that on-record | 250 // TODO(benjhayden): Test incognito, both downloads_list() and that on-record |
251 // calls can't access off-record items. | 251 // calls can't access off-record items. |
252 | 252 |
253 // TODO(benjhayden): Test that bad download ids incoming from the javascript are | 253 // TODO(benjhayden): Test that bad download ids incoming from the javascript are |
254 // dropped on the floor. | 254 // dropped on the floor. |
255 | 255 |
256 // TODO(benjhayden): Test that IsTemporary() downloads are not shown. | 256 // TODO(benjhayden): Test that IsTemporary() downloads are not shown. |
257 | 257 |
258 // TODO(benjhayden): Test that RemoveObserver is called on all download items, | 258 // TODO(benjhayden): Test that RemoveObserver is called on all download items, |
259 // including items that crossed IsTemporary() and back. | 259 // including items that crossed IsTemporary() and back. |
OLD | NEW |