Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2260)

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 8135017: Refactor downloads into a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 4c0a5234203e7f3754672852d52da22f3777584d..63cf9ab820de21e81d9d6635b8f62d30e2811fc4 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -46,6 +46,8 @@
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/download/download_service.h"
+#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/download/save_package_file_picker.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_host.h"
@@ -3082,9 +3084,12 @@ void TestingAutomationProvider::GetDownloadsInfo(Browser* browser,
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
ListValue* list_of_downloads = new ListValue;
- if (browser->profile()->HasCreatedDownloadManager()) {
+ DownloadService* download_service(
+ DownloadServiceFactory::GetForProfile(browser->profile()));
+
+ if (download_service->HasCreatedDownloadManager()) {
std::vector<DownloadItem*> downloads;
- browser->profile()->GetDownloadManager()->
+ download_service->GetDownloadManager()->
GetAllDownloads(FilePath(), &downloads);
for (std::vector<DownloadItem*>::iterator it = downloads.begin();
@@ -3108,7 +3113,10 @@ void TestingAutomationProvider::WaitForAllDownloadsToComplete(
.SendError(StringPrintf("List of IDs of previous downloads required."));
return;
}
- if (!browser->profile()->HasCreatedDownloadManager()) {
+
+ DownloadService* download_service =
+ DownloadServiceFactory::GetForProfile(browser->profile());
+ if (!download_service->HasCreatedDownloadManager()) {
// No download manager, so no downloads to wait for.
AutomationJSONReply(this, reply_message).SendSuccess(NULL);
return;
@@ -3116,7 +3124,7 @@ void TestingAutomationProvider::WaitForAllDownloadsToComplete(
// This observer will delete itself.
new AllDownloadsCompleteObserver(
- this, reply_message, browser->profile()->GetDownloadManager(),
+ this, reply_message, download_service->GetDownloadManager(),
pre_download_ids);
}
@@ -3150,7 +3158,9 @@ void TestingAutomationProvider::PerformActionOnDownload(
int id;
std::string action;
- if (!browser->profile()->HasCreatedDownloadManager()) {
+ DownloadService* download_service =
+ DownloadServiceFactory::GetForProfile(browser->profile());
+ if (!download_service->HasCreatedDownloadManager()) {
AutomationJSONReply(this, reply_message).SendError("No download manager.");
return;
}
@@ -3160,7 +3170,7 @@ void TestingAutomationProvider::PerformActionOnDownload(
return;
}
- DownloadManager* download_manager = browser->profile()->GetDownloadManager();
+ DownloadManager* download_manager = download_service->GetDownloadManager();
DownloadItem* selected_item = GetDownloadItemFromId(id, download_manager);
if (!selected_item) {
AutomationJSONReply(this, reply_message)
@@ -3689,7 +3699,9 @@ void TestingAutomationProvider::SaveTabContents(
}
// The observer will delete itself when done.
new SavePackageNotificationObserver(
- browser->profile()->GetDownloadManager(), this, reply_message);
+ DownloadServiceFactory::GetForProfile(
+ browser->profile())->GetDownloadManager(),
+ this, reply_message);
}
// Refer to ImportSettings() in chrome/test/pyautolib/pyauto.py for sample

Powered by Google App Engine
This is Rietveld 408576698