summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-21 15:32:12 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-21 15:32:12 +0000
commitffc0c2d51b01e5ea248ffd13d3c158b65d987afd (patch)
treeab4acf8819ac105859a0bafe7e0bcb5f4bec59c5 /chrome/browser
parentd66ce661974416e8f0ffa4089a892b253828d398 (diff)
downloadchromium_src-ffc0c2d51b01e5ea248ffd13d3c158b65d987afd.zip
chromium_src-ffc0c2d51b01e5ea248ffd13d3c158b65d987afd.tar.gz
chromium_src-ffc0c2d51b01e5ea248ffd13d3c158b65d987afd.tar.bz2
Move OpenItem/ShowItemInFolder from ContentBrowserClient to DownloadManagerDelegate
ChromeDownloadManagerDelegate provides Profile which can be used to perform drive file operations. MockDownloadOpenForTesting is moved from DownloadItem to DownloadManager. Rename DownloadManager::DownloadOpened to OpenDownload. Add DownloadManager::ShowDownloadInShell. BUG=154713 TEST=git try TBR=joth@chromium.org for android_webview Review URL: https://chromiumcodereview.appspot.com/11941015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chrome_content_browser_client.cc8
-rw-r--r--chrome/browser/chrome_content_browser_client.h2
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.cc10
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.h2
-rw-r--r--chrome/browser/download/download_browsertest.cc27
-rw-r--r--chrome/browser/extensions/api/downloads/downloads_api_unittest.cc26
6 files changed, 14 insertions, 61 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index a430cc9..d27c0b2 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1193,14 +1193,6 @@ ChromeContentBrowserClient::CreateQuotaPermissionContext() {
return new ChromeQuotaPermissionContext();
}
-void ChromeContentBrowserClient::OpenItem(const FilePath& path) {
- platform_util::OpenItem(path);
-}
-
-void ChromeContentBrowserClient::ShowItemInFolder(const FilePath& path) {
- platform_util::ShowItemInFolder(path);
-}
-
void ChromeContentBrowserClient::AllowCertificateError(
int render_process_id,
int render_view_id,
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index 136ddab..129a5d6 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -126,8 +126,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const GURL& url, content::ResourceContext* context) OVERRIDE;
virtual content::QuotaPermissionContext*
CreateQuotaPermissionContext() OVERRIDE;
- virtual void OpenItem(const FilePath& path) OVERRIDE;
- virtual void ShowItemInFolder(const FilePath& path) OVERRIDE;
virtual void AllowCertificateError(
int render_process_id,
int render_view_id,
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index 1c9dd5f..90770c2 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/intents/web_intents_util.h"
+#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
@@ -523,6 +524,15 @@ void ChromeDownloadManagerDelegate::ChooseSavePath(
#endif
}
+void ChromeDownloadManagerDelegate::OpenDownload(DownloadItem* download) {
+ platform_util::OpenItem(download->GetFullPath());
+}
+
+void ChromeDownloadManagerDelegate::ShowDownloadInShell(
+ DownloadItem* download) {
+ platform_util::ShowItemInFolder(download->GetFullPath());
+}
+
void ChromeDownloadManagerDelegate::ClearLastDownloadPath() {
last_download_path_.clear();
}
diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h
index 9224165..c10cb1d 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.h
+++ b/chrome/browser/download/chrome_download_manager_delegate.h
@@ -86,6 +86,8 @@ class ChromeDownloadManagerDelegate
const FilePath::StringType& default_extension,
bool can_save_as_complete,
const content::SavePackagePathPickedCallback& callback) OVERRIDE;
+ virtual void OpenDownload(content::DownloadItem* download) OVERRIDE;
+ virtual void ShowDownloadInShell(content::DownloadItem* download) OVERRIDE;
// Clears the last directory chosen by the user in response to a file chooser
// prompt. Called when clearing recent history.
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 66830ad..c2a7678 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -167,30 +167,6 @@ void SetHiddenDownloadCallback(DownloadItem* item, net::Error error) {
} // namespace
-// While an object of this class exists, it will mock out download
-// opening for all downloads created on the specified download manager.
-class MockDownloadOpeningObserver : public DownloadManager::Observer {
- public:
- explicit MockDownloadOpeningObserver(DownloadManager* manager)
- : download_manager_(manager) {
- download_manager_->AddObserver(this);
- }
-
- ~MockDownloadOpeningObserver() {
- download_manager_->RemoveObserver(this);
- }
-
- virtual void OnDownloadCreated(
- DownloadManager* manager, DownloadItem* item) OVERRIDE {
- item->MockDownloadOpenForTesting();
- }
-
- private:
- DownloadManager* download_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(MockDownloadOpeningObserver);
-};
-
class HistoryObserver : public DownloadHistory::Observer {
public:
explicit HistoryObserver(Profile* profile)
@@ -1487,8 +1463,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) {
ASSERT_TRUE(
GetDownloadPrefs(browser())->EnableAutoOpenBasedOnExtension(file));
- // Mock out external opening on all downloads until end of test.
- MockDownloadOpeningObserver observer(DownloadManagerForBrowser(browser()));
+ DownloadManagerForBrowser(browser())->MockDownloadOpenForTesting();
DownloadAndWait(browser(), url);
diff --git a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
index 451bb6a..2c818f2 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc
@@ -813,30 +813,6 @@ const char HTML5FileWriter::kHTML5FileWritten[] = "html5_file_written";
const char HTML5FileWriter::kURLRequestContextToreDown[] =
"url_request_context_tore_down";
-// While an object of this class exists, it will mock out download
-// opening for all downloads created on the specified download manager.
-class MockDownloadOpeningObserver : public DownloadManager::Observer {
- public:
- explicit MockDownloadOpeningObserver(DownloadManager* manager)
- : download_manager_(manager) {
- download_manager_->AddObserver(this);
- }
-
- ~MockDownloadOpeningObserver() {
- download_manager_->RemoveObserver(this);
- }
-
- virtual void OnDownloadCreated(
- DownloadManager* manager, DownloadItem* item) OVERRIDE {
- item->MockDownloadOpenForTesting();
- }
-
- private:
- DownloadManager* download_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(MockDownloadOpeningObserver);
-};
-
} // namespace
IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
@@ -846,7 +822,7 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
new DownloadsOpenFunction(),
"[-42]").c_str());
- MockDownloadOpeningObserver mock_open_observer(GetCurrentManager());
+ GetCurrentManager()->MockDownloadOpenForTesting();
DownloadItem* download_item = CreateSlowTestDownload();
ASSERT_TRUE(download_item);
EXPECT_FALSE(download_item->GetOpened());