| 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 "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 2610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 IPC::Message* reply_message) { | 2621 IPC::Message* reply_message) { |
| 2622 AutomationJSONReply reply(this, reply_message); | 2622 AutomationJSONReply reply(this, reply_message); |
| 2623 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2623 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 2624 ListValue* list_of_downloads = new ListValue; | 2624 ListValue* list_of_downloads = new ListValue; |
| 2625 | 2625 |
| 2626 DownloadService* download_service( | 2626 DownloadService* download_service( |
| 2627 DownloadServiceFactory::GetForProfile(browser->profile())); | 2627 DownloadServiceFactory::GetForProfile(browser->profile())); |
| 2628 | 2628 |
| 2629 if (download_service->HasCreatedDownloadManager()) { | 2629 if (download_service->HasCreatedDownloadManager()) { |
| 2630 std::vector<DownloadItem*> downloads; | 2630 std::vector<DownloadItem*> downloads; |
| 2631 BrowserContext::GetDownloadManager(browser->profile())-> | 2631 BrowserContext::GetDownloadManager(browser->profile())->GetAllDownloads( |
| 2632 GetAllDownloads(FilePath(), &downloads); | 2632 &downloads); |
| 2633 | 2633 |
| 2634 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); | 2634 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); |
| 2635 it != downloads.end(); | 2635 it != downloads.end(); |
| 2636 it++) { // Fill info about each download item. | 2636 it++) { // Fill info about each download item. |
| 2637 list_of_downloads->Append(GetDictionaryFromDownloadItem( | 2637 list_of_downloads->Append(GetDictionaryFromDownloadItem( |
| 2638 *it, browser->profile()->IsOffTheRecord())); | 2638 *it, browser->profile()->IsOffTheRecord())); |
| 2639 } | 2639 } |
| 2640 } | 2640 } |
| 2641 return_value->Set("downloads", list_of_downloads); | 2641 return_value->Set("downloads", list_of_downloads); |
| 2642 reply.SendSuccess(return_value.get()); | 2642 reply.SendSuccess(return_value.get()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2666 new AllDownloadsCompleteObserver( | 2666 new AllDownloadsCompleteObserver( |
| 2667 this, reply_message, | 2667 this, reply_message, |
| 2668 BrowserContext::GetDownloadManager(browser->profile()), | 2668 BrowserContext::GetDownloadManager(browser->profile()), |
| 2669 pre_download_ids); | 2669 pre_download_ids); |
| 2670 } | 2670 } |
| 2671 | 2671 |
| 2672 namespace { | 2672 namespace { |
| 2673 | 2673 |
| 2674 DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) { | 2674 DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) { |
| 2675 std::vector<DownloadItem*> downloads; | 2675 std::vector<DownloadItem*> downloads; |
| 2676 download_manager->GetAllDownloads(FilePath(), &downloads); | 2676 download_manager->GetAllDownloads(&downloads); |
| 2677 DownloadItem* selected_item = NULL; | 2677 DownloadItem* selected_item = NULL; |
| 2678 | 2678 |
| 2679 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); | 2679 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); |
| 2680 it != downloads.end(); | 2680 it != downloads.end(); |
| 2681 it++) { | 2681 it++) { |
| 2682 DownloadItem* curr_item = *it; | 2682 DownloadItem* curr_item = *it; |
| 2683 if (curr_item->GetId() == id) { | 2683 if (curr_item->GetId() == id) { |
| 2684 selected_item = curr_item; | 2684 selected_item = curr_item; |
| 2685 break; | 2685 break; |
| 2686 } | 2686 } |
| (...skipping 3749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6436 void TestingAutomationProvider::OnRemoveProvider() { | 6436 void TestingAutomationProvider::OnRemoveProvider() { |
| 6437 if (g_browser_process) | 6437 if (g_browser_process) |
| 6438 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6438 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6439 } | 6439 } |
| 6440 | 6440 |
| 6441 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6441 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6442 WebContents* tab) { | 6442 WebContents* tab) { |
| 6443 if (chrome::GetActiveWebContents(browser) != tab) | 6443 if (chrome::GetActiveWebContents(browser) != tab) |
| 6444 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6444 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
| 6445 } | 6445 } |
| OLD | NEW |