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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/test/test_file_util.h" | 16 #include "base/test/test_file_util.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/common/cancelable_request.h" | 20 #include "chrome/browser/common/cancelable_request.h" |
21 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 21 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
22 #include "chrome/browser/download/download_crx_util.h" | 22 #include "chrome/browser/download/download_crx_util.h" |
23 #include "chrome/browser/download/download_history.h" | 23 #include "chrome/browser/download/download_history.h" |
| 24 #include "chrome/browser/download/download_item_model.h" |
24 #include "chrome/browser/download/download_prefs.h" | 25 #include "chrome/browser/download/download_prefs.h" |
25 #include "chrome/browser/download/download_request_limiter.h" | 26 #include "chrome/browser/download/download_request_limiter.h" |
26 #include "chrome/browser/download/download_service.h" | 27 #include "chrome/browser/download/download_service.h" |
27 #include "chrome/browser/download/download_service_factory.h" | 28 #include "chrome/browser/download/download_service_factory.h" |
28 #include "chrome/browser/download/download_shelf.h" | 29 #include "chrome/browser/download/download_shelf.h" |
29 #include "chrome/browser/download/download_test_file_chooser_observer.h" | 30 #include "chrome/browser/download/download_test_file_chooser_observer.h" |
30 #include "chrome/browser/download/download_util.h" | 31 #include "chrome/browser/download/download_util.h" |
31 #include "chrome/browser/extensions/extension_install_prompt.h" | 32 #include "chrome/browser/extensions/extension_install_prompt.h" |
32 #include "chrome/browser/extensions/extension_service.h" | 33 #include "chrome/browser/extensions/extension_service.h" |
33 #include "chrome/browser/extensions/extension_system.h" | 34 #include "chrome/browser/extensions/extension_system.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 155 |
155 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); | 156 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); |
156 }; | 157 }; |
157 | 158 |
158 bool WasAutoOpened(DownloadItem* item) { | 159 bool WasAutoOpened(DownloadItem* item) { |
159 return item->GetAutoOpened(); | 160 return item->GetAutoOpened(); |
160 } | 161 } |
161 | 162 |
162 // Called when a download starts. Marks the download as hidden. | 163 // Called when a download starts. Marks the download as hidden. |
163 void SetHiddenDownloadCallback(DownloadItem* item, net::Error error) { | 164 void SetHiddenDownloadCallback(DownloadItem* item, net::Error error) { |
164 download_util::SetShouldShowInShelf(item, false); | 165 DownloadItemModel(item).SetShouldShowInShelf(false); |
165 } | 166 } |
166 | 167 |
167 } // namespace | 168 } // namespace |
168 | 169 |
169 // While an object of this class exists, it will mock out download | 170 // While an object of this class exists, it will mock out download |
170 // opening for all downloads created on the specified download manager. | 171 // opening for all downloads created on the specified download manager. |
171 class MockDownloadOpeningObserver : public DownloadManager::Observer { | 172 class MockDownloadOpeningObserver : public DownloadManager::Observer { |
172 public: | 173 public: |
173 explicit MockDownloadOpeningObserver(DownloadManager* manager) | 174 explicit MockDownloadOpeningObserver(DownloadManager* manager) |
174 : download_manager_(manager) { | 175 : download_manager_(manager) { |
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 2228 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
2228 scoped_ptr<DownloadUrlParameters> params( | 2229 scoped_ptr<DownloadUrlParameters> params( |
2229 DownloadUrlParameters::FromWebContents(web_contents, url)); | 2230 DownloadUrlParameters::FromWebContents(web_contents, url)); |
2230 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); | 2231 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); |
2231 download_manager->DownloadUrl(params.Pass()); | 2232 download_manager->DownloadUrl(params.Pass()); |
2232 observer->WaitForFinished(); | 2233 observer->WaitForFinished(); |
2233 | 2234 |
2234 // Verify that download shelf is not shown. | 2235 // Verify that download shelf is not shown. |
2235 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2236 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2236 } | 2237 } |
OLD | NEW |