diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 20:24:06 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 20:24:06 +0000 |
commit | abf9eacc6f2181c29549053ac73aa1e63882b500 (patch) | |
tree | d9ccf3214c5de09540e5ad2874a396d9607c4f95 /chrome/browser/automation | |
parent | ee740465ab3f4a723e2144db1d9830c3752fc12d (diff) | |
download | chromium_src-abf9eacc6f2181c29549053ac73aa1e63882b500.zip chromium_src-abf9eacc6f2181c29549053ac73aa1e63882b500.tar.gz chromium_src-abf9eacc6f2181c29549053ac73aa1e63882b500.tar.bz2 |
GetDownloadsInfo() should return an empty list in case DownloadManger isn't initialized
GetDownloadsInfo() should return an empty list in case DownloadManger isn't
initialized, instead of causing an error.
BUG=77949
R=rdsmith@chromium.org
TEST=
Review URL: http://codereview.chromium.org/6758044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80364 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 19308d4..a73c983 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -2679,27 +2679,22 @@ void TestingAutomationProvider::GetDownloadsInfo(Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { AutomationJSONReply reply(this, reply_message); - - if (!browser->profile()->HasCreatedDownloadManager()) { - reply.SendError("no download manager"); - return; - } - scoped_ptr<DictionaryValue> return_value(new DictionaryValue); - std::vector<DownloadItem*> downloads; - browser->profile()->GetDownloadManager()-> - GetAllDownloads(FilePath(), &downloads); - ListValue* list_of_downloads = new ListValue; - for (std::vector<DownloadItem*>::iterator it = downloads.begin(); - it != downloads.end(); - it++) { // Fill info about each download item. - list_of_downloads->Append(GetDictionaryFromDownloadItem(*it)); + + if (browser->profile()->HasCreatedDownloadManager()) { + std::vector<DownloadItem*> downloads; + browser->profile()->GetDownloadManager()-> + GetAllDownloads(FilePath(), &downloads); + + for (std::vector<DownloadItem*>::iterator it = downloads.begin(); + it != downloads.end(); + it++) { // Fill info about each download item. + list_of_downloads->Append(GetDictionaryFromDownloadItem(*it)); + } } return_value->Set("downloads", list_of_downloads); reply.SendSuccess(return_value.get()); - // All value objects allocated above are owned by |return_value| - // and get freed by it. } void TestingAutomationProvider::WaitForDownloadsToComplete( |