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

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 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 DownloadServiceFactory::GetForProfile(browser->profile())); 2639 DownloadServiceFactory::GetForProfile(browser->profile()));
2640 2640
2641 if (download_service->HasCreatedDownloadManager()) { 2641 if (download_service->HasCreatedDownloadManager()) {
2642 std::vector<DownloadItem*> downloads; 2642 std::vector<DownloadItem*> downloads;
2643 BrowserContext::GetDownloadManager(browser->profile())-> 2643 BrowserContext::GetDownloadManager(browser->profile())->
2644 GetAllDownloads(FilePath(), &downloads); 2644 GetAllDownloads(FilePath(), &downloads);
2645 2645
2646 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); 2646 for (std::vector<DownloadItem*>::iterator it = downloads.begin();
2647 it != downloads.end(); 2647 it != downloads.end();
2648 it++) { // Fill info about each download item. 2648 it++) { // Fill info about each download item.
2649 list_of_downloads->Append(GetDictionaryFromDownloadItem(*it)); 2649 list_of_downloads->Append(GetDictionaryFromDownloadItem(
2650 *it, browser->profile()->IsOffTheRecord()));
2650 } 2651 }
2651 } 2652 }
2652 return_value->Set("downloads", list_of_downloads); 2653 return_value->Set("downloads", list_of_downloads);
2653 reply.SendSuccess(return_value.get()); 2654 reply.SendSuccess(return_value.get());
2654 } 2655 }
2655 2656
2656 void TestingAutomationProvider::WaitForAllDownloadsToComplete( 2657 void TestingAutomationProvider::WaitForAllDownloadsToComplete(
2657 Browser* browser, 2658 Browser* browser,
2658 DictionaryValue* args, 2659 DictionaryValue* args,
2659 IPC::Message* reply_message) { 2660 IPC::Message* reply_message) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 // We need to be IN_PROGRESS for these actions. 2735 // We need to be IN_PROGRESS for these actions.
2735 if ((action == "toggle_pause" || action == "cancel") && 2736 if ((action == "toggle_pause" || action == "cancel") &&
2736 !selected_item->IsInProgress()) { 2737 !selected_item->IsInProgress()) {
2737 AutomationJSONReply(this, reply_message) 2738 AutomationJSONReply(this, reply_message)
2738 .SendError("Selected DownloadItem is not in progress."); 2739 .SendError("Selected DownloadItem is not in progress.");
2739 } 2740 }
2740 2741
2741 if (action == "open") { 2742 if (action == "open") {
2742 selected_item->AddObserver( 2743 selected_item->AddObserver(
2743 new AutomationProviderDownloadUpdatedObserver( 2744 new AutomationProviderDownloadUpdatedObserver(
2744 this, reply_message, true)); 2745 this, reply_message, true, browser->profile()->IsOffTheRecord()));
2745 selected_item->OpenDownload(); 2746 selected_item->OpenDownload();
2746 } else if (action == "toggle_open_files_like_this") { 2747 } else if (action == "toggle_open_files_like_this") {
2747 DownloadPrefs* prefs = 2748 DownloadPrefs* prefs =
2748 DownloadPrefs::FromBrowserContext(selected_item->GetBrowserContext()); 2749 DownloadPrefs::FromBrowserContext(selected_item->GetBrowserContext());
2749 FilePath path = selected_item->GetUserVerifiedFilePath(); 2750 FilePath path = selected_item->GetUserVerifiedFilePath();
2750 if (!selected_item->ShouldOpenFileBasedOnExtension()) 2751 if (!selected_item->ShouldOpenFileBasedOnExtension())
2751 prefs->EnableAutoOpenBasedOnExtension(path); 2752 prefs->EnableAutoOpenBasedOnExtension(path);
2752 else 2753 else
2753 prefs->DisableAutoOpenBasedOnExtension(path); 2754 prefs->DisableAutoOpenBasedOnExtension(path);
2754 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 2755 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
2755 } else if (action == "remove") { 2756 } else if (action == "remove") {
2756 download_manager->AddObserver( 2757 download_manager->AddObserver(
2757 new AutomationProviderDownloadModelChangedObserver( 2758 new AutomationProviderDownloadModelChangedObserver(
2758 this, reply_message, download_manager)); 2759 this, reply_message, download_manager));
2759 selected_item->Remove(); 2760 selected_item->Remove();
2760 } else if (action == "decline_dangerous_download") { 2761 } else if (action == "decline_dangerous_download") {
2761 download_manager->AddObserver( 2762 download_manager->AddObserver(
2762 new AutomationProviderDownloadModelChangedObserver( 2763 new AutomationProviderDownloadModelChangedObserver(
2763 this, reply_message, download_manager)); 2764 this, reply_message, download_manager));
2764 selected_item->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD); 2765 selected_item->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
2765 } else if (action == "save_dangerous_download") { 2766 } else if (action == "save_dangerous_download") {
2766 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( 2767 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
2767 this, reply_message, false)); 2768 this, reply_message, false, browser->profile()->IsOffTheRecord()));
2768 selected_item->DangerousDownloadValidated(); 2769 selected_item->DangerousDownloadValidated();
2769 } else if (action == "toggle_pause") { 2770 } else if (action == "toggle_pause") {
2770 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( 2771 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
2771 this, reply_message, false)); 2772 this, reply_message, false, browser->profile()->IsOffTheRecord()));
2772 // This will still return if download has already completed. 2773 // This will still return if download has already completed.
2773 selected_item->TogglePause(); 2774 selected_item->TogglePause();
2774 } else if (action == "cancel") { 2775 } else if (action == "cancel") {
2775 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( 2776 selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
2776 this, reply_message, false)); 2777 this, reply_message, false, browser->profile()->IsOffTheRecord()));
2777 selected_item->Cancel(true); 2778 selected_item->Cancel(true);
2778 } else { 2779 } else {
2779 AutomationJSONReply(this, reply_message) 2780 AutomationJSONReply(this, reply_message)
2780 .SendError(StringPrintf("Invalid action '%s' given.", action.c_str())); 2781 .SendError(StringPrintf("Invalid action '%s' given.", action.c_str()));
2781 } 2782 }
2782 } 2783 }
2783 2784
2784 void TestingAutomationProvider::SetDownloadShelfVisibleJSON( 2785 void TestingAutomationProvider::SetDownloadShelfVisibleJSON(
2785 DictionaryValue* args, 2786 DictionaryValue* args,
2786 IPC::Message* reply_message) { 2787 IPC::Message* reply_message) {
(...skipping 4378 matching lines...) Expand 10 before | Expand all | Expand 10 after
7165 void TestingAutomationProvider::OnRemoveProvider() { 7166 void TestingAutomationProvider::OnRemoveProvider() {
7166 if (g_browser_process) 7167 if (g_browser_process)
7167 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 7168 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
7168 } 7169 }
7169 7170
7170 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 7171 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
7171 WebContents* tab) { 7172 WebContents* tab) {
7172 if (chrome::GetActiveWebContents(browser) != tab) 7173 if (chrome::GetActiveWebContents(browser) != tab)
7173 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 7174 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
7174 } 7175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698