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

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

Issue 8503018: Split DownloadItem into an ABC, an Impl, and a Mock. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 3120
3121 DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) { 3121 DownloadItem* GetDownloadItemFromId(int id, DownloadManager* download_manager) {
3122 std::vector<DownloadItem*> downloads; 3122 std::vector<DownloadItem*> downloads;
3123 download_manager->GetAllDownloads(FilePath(), &downloads); 3123 download_manager->GetAllDownloads(FilePath(), &downloads);
3124 DownloadItem* selected_item = NULL; 3124 DownloadItem* selected_item = NULL;
3125 3125
3126 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); 3126 for (std::vector<DownloadItem*>::iterator it = downloads.begin();
3127 it != downloads.end(); 3127 it != downloads.end();
3128 it++) { 3128 it++) {
3129 DownloadItem* curr_item = *it; 3129 DownloadItem* curr_item = *it;
3130 if (curr_item->id() == id) { 3130 if (curr_item->GetId() == id) {
3131 selected_item = curr_item; 3131 selected_item = curr_item;
3132 break; 3132 break;
3133 } 3133 }
3134 } 3134 }
3135 return selected_item; 3135 return selected_item;
3136 } 3136 }
3137 3137
3138 } // namespace 3138 } // namespace
3139 3139
3140 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample 3140 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample
(...skipping 25 matching lines...) Expand all
3166 return; 3166 return;
3167 } 3167 }
3168 3168
3169 if (action == "open") { 3169 if (action == "open") {
3170 selected_item->AddObserver( 3170 selected_item->AddObserver(
3171 new AutomationProviderDownloadUpdatedObserver( 3171 new AutomationProviderDownloadUpdatedObserver(
3172 this, reply_message, true)); 3172 this, reply_message, true));
3173 selected_item->OpenDownload(); 3173 selected_item->OpenDownload();
3174 } else if (action == "toggle_open_files_like_this") { 3174 } else if (action == "toggle_open_files_like_this") {
3175 DownloadPrefs* prefs = 3175 DownloadPrefs* prefs =
3176 DownloadPrefs::FromDownloadManager(selected_item->download_manager()); 3176 DownloadPrefs::FromDownloadManager(selected_item->GetDownloadManager());
3177 FilePath path = selected_item->GetUserVerifiedFilePath(); 3177 FilePath path = selected_item->GetUserVerifiedFilePath();
3178 if (!selected_item->ShouldOpenFileBasedOnExtension()) 3178 if (!selected_item->ShouldOpenFileBasedOnExtension())
3179 prefs->EnableAutoOpenBasedOnExtension(path); 3179 prefs->EnableAutoOpenBasedOnExtension(path);
3180 else 3180 else
3181 prefs->DisableAutoOpenBasedOnExtension(path); 3181 prefs->DisableAutoOpenBasedOnExtension(path);
3182 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 3182 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
3183 } else if (action == "remove") { 3183 } else if (action == "remove") {
3184 download_manager->AddObserver( 3184 download_manager->AddObserver(
3185 new AutomationProviderDownloadModelChangedObserver( 3185 new AutomationProviderDownloadModelChangedObserver(
3186 this, reply_message, download_manager)); 3186 this, reply_message, download_manager));
(...skipping 3201 matching lines...) Expand 10 before | Expand all | Expand 10 after
6388 6388
6389 Send(reply_message_); 6389 Send(reply_message_);
6390 redirect_query_ = 0; 6390 redirect_query_ = 0;
6391 reply_message_ = NULL; 6391 reply_message_ = NULL;
6392 } 6392 }
6393 6393
6394 void TestingAutomationProvider::OnRemoveProvider() { 6394 void TestingAutomationProvider::OnRemoveProvider() {
6395 if (g_browser_process) 6395 if (g_browser_process)
6396 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6396 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6397 } 6397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698