| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 return_value->Set("downloads", list_of_downloads); | 2591 return_value->Set("downloads", list_of_downloads); |
| 2592 reply.SendSuccess(return_value.get()); | 2592 reply.SendSuccess(return_value.get()); |
| 2593 // All value objects allocated above are owned by |return_value| | 2593 // All value objects allocated above are owned by |return_value| |
| 2594 // and get freed by it. | 2594 // and get freed by it. |
| 2595 } | 2595 } |
| 2596 | 2596 |
| 2597 void TestingAutomationProvider::WaitForDownloadsToComplete( | 2597 void TestingAutomationProvider::WaitForDownloadsToComplete( |
| 2598 Browser* browser, | 2598 Browser* browser, |
| 2599 DictionaryValue* args, | 2599 DictionaryValue* args, |
| 2600 IPC::Message* reply_message) { | 2600 IPC::Message* reply_message) { |
| 2601 AutomationJSONReply reply(this, reply_message); | |
| 2602 | 2601 |
| 2603 // Look for a quick return. | 2602 // Look for a quick return. |
| 2604 if (!profile_->HasCreatedDownloadManager()) { | 2603 if (!profile_->HasCreatedDownloadManager()) { |
| 2605 reply.SendSuccess(NULL); // No download manager. | 2604 // No download manager. |
| 2605 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 2606 return; | 2606 return; |
| 2607 } | 2607 } |
| 2608 std::vector<DownloadItem*> downloads; | 2608 std::vector<DownloadItem*> downloads; |
| 2609 profile_->GetDownloadManager()->GetCurrentDownloads(FilePath(), &downloads); | 2609 profile_->GetDownloadManager()->GetCurrentDownloads(FilePath(), &downloads); |
| 2610 if (downloads.empty()) { | 2610 if (downloads.empty()) { |
| 2611 reply.SendSuccess(NULL); | 2611 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 2612 return; | 2612 return; |
| 2613 } | 2613 } |
| 2614 | 2614 |
| 2615 // The observer owns itself. When the last observed item pings, it | 2615 // The observer owns itself. When the last observed item pings, it |
| 2616 // deletes itself. | 2616 // deletes itself. |
| 2617 AutomationProviderDownloadItemObserver* item_observer = | 2617 AutomationProviderDownloadItemObserver* item_observer = |
| 2618 new AutomationProviderDownloadItemObserver( | 2618 new AutomationProviderDownloadItemObserver( |
| 2619 this, reply_message, downloads.size()); | 2619 this, reply_message, downloads.size()); |
| 2620 for (std::vector<DownloadItem*>::iterator i = downloads.begin(); | 2620 for (std::vector<DownloadItem*>::iterator i = downloads.begin(); |
| 2621 i != downloads.end(); | 2621 i != downloads.end(); |
| (...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4541 // If you change this, update Observer for NotificationType::SESSION_END | 4541 // If you change this, update Observer for NotificationType::SESSION_END |
| 4542 // below. | 4542 // below. |
| 4543 MessageLoop::current()->PostTask(FROM_HERE, | 4543 MessageLoop::current()->PostTask(FROM_HERE, |
| 4544 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4544 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
| 4545 } | 4545 } |
| 4546 } | 4546 } |
| 4547 | 4547 |
| 4548 void TestingAutomationProvider::OnRemoveProvider() { | 4548 void TestingAutomationProvider::OnRemoveProvider() { |
| 4549 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4549 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 4550 } | 4550 } |
| OLD | NEW |