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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10805020: Kill DownloadItem::IsOtr() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 DownloadServiceFactory::GetForProfile(browser->profile())); 2716 DownloadServiceFactory::GetForProfile(browser->profile()));
2717 2717
2718 if (download_service->HasCreatedDownloadManager()) { 2718 if (download_service->HasCreatedDownloadManager()) {
2719 std::vector<DownloadItem*> downloads; 2719 std::vector<DownloadItem*> downloads;
2720 BrowserContext::GetDownloadManager(browser->profile())-> 2720 BrowserContext::GetDownloadManager(browser->profile())->
2721 GetAllDownloads(FilePath(), &downloads); 2721 GetAllDownloads(FilePath(), &downloads);
2722 2722
2723 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); 2723 for (std::vector<DownloadItem*>::iterator it = downloads.begin();
2724 it != downloads.end(); 2724 it != downloads.end();
2725 it++) { // Fill info about each download item. 2725 it++) { // Fill info about each download item.
2726 list_of_downloads->Append(GetDictionaryFromDownloadItem(*it)); 2726 list_of_downloads->Append(GetDictionaryFromDownloadItem(
2727 *it, browser->profile()->IsOffTheRecord()));
2727 } 2728 }
2728 } 2729 }
2729 return_value->Set("downloads", list_of_downloads); 2730 return_value->Set("downloads", list_of_downloads);
2730 reply.SendSuccess(return_value.get()); 2731 reply.SendSuccess(return_value.get());
2731 } 2732 }
2732 2733
2733 void TestingAutomationProvider::WaitForAllDownloadsToComplete( 2734 void TestingAutomationProvider::WaitForAllDownloadsToComplete(
2734 Browser* browser, 2735 Browser* browser,
2735 DictionaryValue* args, 2736 DictionaryValue* args,
2736 IPC::Message* reply_message) { 2737 IPC::Message* reply_message) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 // We need to be IN_PROGRESS for these actions. 2812 // We need to be IN_PROGRESS for these actions.
2812 if ((action == "toggle_pause" || action == "cancel") && 2813 if ((action == "toggle_pause" || action == "cancel") &&
2813 !selected_item->IsInProgress()) { 2814 !selected_item->IsInProgress()) {
2814 AutomationJSONReply(this, reply_message) 2815 AutomationJSONReply(this, reply_message)
2815 .SendError("Selected DownloadItem is not in progress."); 2816 .SendError("Selected DownloadItem is not in progress.");
2816 } 2817 }
2817 2818
2818 if (action == "open") { 2819 if (action == "open") {
2819 selected_item->AddObserver( 2820 selected_item->AddObserver(
2820 new AutomationProviderDownloadUpdatedObserver( 2821 new AutomationProviderDownloadUpdatedObserver(
2821 this, reply_message, true)); 2822 this, reply_message, true, browser->profile()->IsOffTheRecord()));
2822 selected_item->OpenDownload(); 2823 selected_item->OpenDownload();
2823 } else if (action == "toggle_open_files_like_this") { 2824 } else if (action == "toggle_open_files_like_this") {
2824 DownloadPrefs* prefs = 2825 DownloadPrefs* prefs =
2825 DownloadPrefs::FromBrowserContext(selected_item->GetBrowserContext()); 2826 DownloadPrefs::FromBrowserContext(selected_item->GetBrowserContext());
2826 FilePath path = selected_item->GetUserVerifiedFilePath(); 2827 FilePath path = selected_item->GetUserVerifiedFilePath();
2827 if (!selected_item->ShouldOpenFileBasedOnExtension()) 2828 if (!selected_item->ShouldOpenFileBasedOnExtension())
2828 prefs->EnableAutoOpenBasedOnExtension(path); 2829 prefs->EnableAutoOpenBasedOnExtension(path);
2829 else 2830 else
2830 prefs->DisableAutoOpenBasedOnExtension(path); 2831 prefs->DisableAutoOpenBasedOnExtension(path);
2831 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 2832 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
2832 } else if (action == "remove") { 2833 } else if (action == "remove") {
2833 download_manager->AddObserver( 2834 download_manager->AddObserver(
2834 new AutomationProviderDownloadModelChangedObserver( 2835 new AutomationProviderDownloadModelChangedObserver(
2835 this, reply_message, download_manager)); 2836 this, reply_message, download_manager));
2836 selected_item->Remove(); 2837 selected_item->Remove();
2837 } else if (action == "decline_dangerous_download") { 2838 } else if (action == "decline_dangerous_download") {
2838 download_manager->AddObserver( 2839 download_manager->AddObserver(
2839 new AutomationProviderDownloadModelChangedObserver( 2840 new AutomationProviderDownloadModelChangedObserver(
2840 this, reply_message, download_manager)); 2841 this, reply_message, download_manager));
2841 selected_item->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 2842 selected_item->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
2842 } else if (action == "save_dangerous_download") { 2843 } else if (action == "save_dangerous_download") {
2843 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( 2844 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
2844 this, reply_message, false)); 2845 this, reply_message, false, browser->profile()->IsOffTheRecord()));
2845 selected_item->DangerousDownloadValidated(); 2846 selected_item->DangerousDownloadValidated();
2846 } else if (action == "toggle_pause") { 2847 } else if (action == "toggle_pause") {
2847 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( 2848 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
2848 this, reply_message, false)); 2849 this, reply_message, false, browser->profile()->IsOffTheRecord()));
2849 // This will still return if download has already completed. 2850 // This will still return if download has already completed.
2850 selected_item->TogglePause(); 2851 selected_item->TogglePause();
2851 } else if (action == "cancel") { 2852 } else if (action == "cancel") {
2852 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( 2853 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
2853 this, reply_message, false)); 2854 this, reply_message, false, browser->profile()->IsOffTheRecord()));
2854 selected_item->Cancel(true); 2855 selected_item->Cancel(true);
2855 } else { 2856 } else {
2856 AutomationJSONReply(this, reply_message) 2857 AutomationJSONReply(this, reply_message)
2857 .SendError(StringPrintf("Invalid action '%s' given.", action.c_str())); 2858 .SendError(StringPrintf("Invalid action '%s' given.", action.c_str()));
2858 } 2859 }
2859 } 2860 }
2860 2861
2861 void TestingAutomationProvider::SetDownloadShelfVisibleJSON( 2862 void TestingAutomationProvider::SetDownloadShelfVisibleJSON(
2862 DictionaryValue* args, 2863 DictionaryValue* args,
2863 IPC::Message* reply_message) { 2864 IPC::Message* reply_message) {
(...skipping 4377 matching lines...) Expand 10 before | Expand all | Expand 10 after
7241 void TestingAutomationProvider::OnRemoveProvider() { 7242 void TestingAutomationProvider::OnRemoveProvider() {
7242 if (g_browser_process) 7243 if (g_browser_process)
7243 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7244 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7244 } 7245 }
7245 7246
7246 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 7247 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
7247 WebContents* tab) { 7248 WebContents* tab) {
7248 if (chrome::GetActiveWebContents(browser) != tab) 7249 if (chrome::GetActiveWebContents(browser) != tab)
7249 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 7250 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
7250 } 7251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698