| 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 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 IPC::Message* reply_message) { | 2636 IPC::Message* reply_message) { |
| 2637 AutomationJSONReply reply(this, reply_message); | 2637 AutomationJSONReply reply(this, reply_message); |
| 2638 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2638 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 2639 ListValue* list_of_downloads = new ListValue; | 2639 ListValue* list_of_downloads = new ListValue; |
| 2640 | 2640 |
| 2641 DownloadService* download_service( | 2641 DownloadService* download_service( |
| 2642 DownloadServiceFactory::GetForProfile(browser->profile())); | 2642 DownloadServiceFactory::GetForProfile(browser->profile())); |
| 2643 | 2643 |
| 2644 if (download_service->HasCreatedDownloadManager()) { | 2644 if (download_service->HasCreatedDownloadManager()) { |
| 2645 std::vector<DownloadItem*> downloads; | 2645 std::vector<DownloadItem*> downloads; |
| 2646 BrowserContext::GetDownloadManager(browser->profile())->GetAllDownloads( | 2646 BrowserContext::GetDownloadManager(browser->profile())-> |
| 2647 &downloads); | 2647 GetAllDownloads(FilePath(), &downloads); |
| 2648 | 2648 |
| 2649 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); | 2649 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); |
| 2650 it != downloads.end(); | 2650 it != downloads.end(); |
| 2651 it++) { // Fill info about each download item. | 2651 it++) { // Fill info about each download item. |
| 2652 list_of_downloads->Append(GetDictionaryFromDownloadItem( | 2652 list_of_downloads->Append(GetDictionaryFromDownloadItem( |
| 2653 *it, browser->profile()->IsOffTheRecord())); | 2653 *it, browser->profile()->IsOffTheRecord())); |
| 2654 } | 2654 } |
| 2655 } | 2655 } |
| 2656 return_value->Set("downloads", list_of_downloads); | 2656 return_value->Set("downloads", list_of_downloads); |
| 2657 reply.SendSuccess(return_value.get()); | 2657 reply.SendSuccess(return_value.get()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2681 new AllDownloadsCompleteObserver( | 2681 new AllDownloadsCompleteObserver( |
| 2682 this, reply_message, | 2682 this, reply_message, |
| 2683 BrowserContext::GetDownloadManager(browser->profile()), | 2683 BrowserContext::GetDownloadManager(browser->profile()), |
| 2684 pre_download_ids); | 2684 pre_download_ids); |
| 2685 } | 2685 } |
| 2686 | 2686 |
| 2687 namespace { | 2687 namespace { |
| 2688 | 2688 |
| 2689 DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) { | 2689 DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) { |
| 2690 std::vector<DownloadItem*> downloads; | 2690 std::vector<DownloadItem*> downloads; |
| 2691 download_manager->GetAllDownloads(&downloads); | 2691 download_manager->GetAllDownloads(FilePath(), &downloads); |
| 2692 DownloadItem* selected_item = NULL; | 2692 DownloadItem* selected_item = NULL; |
| 2693 | 2693 |
| 2694 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); | 2694 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); |
| 2695 it != downloads.end(); | 2695 it != downloads.end(); |
| 2696 it++) { | 2696 it++) { |
| 2697 DownloadItem* curr_item = *it; | 2697 DownloadItem* curr_item = *it; |
| 2698 if (curr_item->GetId() == id) { | 2698 if (curr_item->GetId() == id) { |
| 2699 selected_item = curr_item; | 2699 selected_item = curr_item; |
| 2700 break; | 2700 break; |
| 2701 } | 2701 } |
| (...skipping 3739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6441 void TestingAutomationProvider::OnRemoveProvider() { | 6441 void TestingAutomationProvider::OnRemoveProvider() { |
| 6442 if (g_browser_process) | 6442 if (g_browser_process) |
| 6443 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6443 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6444 } | 6444 } |
| 6445 | 6445 |
| 6446 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6446 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6447 WebContents* tab) { | 6447 WebContents* tab) { |
| 6448 if (chrome::GetActiveWebContents(browser) != tab) | 6448 if (chrome::GetActiveWebContents(browser) != tab) |
| 6449 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 6449 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
| 6450 } | 6450 } |
| OLD | NEW |