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

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

Issue 7464009: Removal of Profile from content part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_context Created 9 years, 5 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) 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 694 }
695 } 695 }
696 } 696 }
697 697
698 void TestingAutomationProvider::GetRedirectsFrom(int tab_handle, 698 void TestingAutomationProvider::GetRedirectsFrom(int tab_handle,
699 const GURL& source_url, 699 const GURL& source_url,
700 IPC::Message* reply_message) { 700 IPC::Message* reply_message) {
701 if (redirect_query_) { 701 if (redirect_query_) {
702 LOG(ERROR) << "Can only handle one redirect query at once."; 702 LOG(ERROR) << "Can only handle one redirect query at once.";
703 } else if (tab_tracker_->ContainsHandle(tab_handle)) { 703 } else if (tab_tracker_->ContainsHandle(tab_handle)) {
704 NavigationController* tab = tab_tracker_->GetResource(tab_handle); 704 NavigationController* nav = tab_tracker_->GetResource(tab_handle);
705 Profile* profile = static_cast<Profile*>(nav->browser_context());
705 HistoryService* history_service = 706 HistoryService* history_service =
706 tab->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); 707 profile->GetHistoryService(Profile::EXPLICIT_ACCESS);
707 708
708 DCHECK(history_service) << "Tab " << tab_handle << "'s profile " << 709 DCHECK(history_service) << "Tab " << tab_handle << "'s profile " <<
709 "has no history service"; 710 "has no history service";
710 if (history_service) { 711 if (history_service) {
711 DCHECK(!reply_message_); 712 DCHECK(!reply_message_);
712 reply_message_ = reply_message; 713 reply_message_ = reply_message;
713 // Schedule a history query for redirects. The response will be sent 714 // Schedule a history query for redirects. The response will be sent
714 // asynchronously from the callback the history system uses to notify us 715 // asynchronously from the callback the history system uses to notify us
715 // that it's done: OnRedirectQueryComplete. 716 // that it's done: OnRedirectQueryComplete.
716 redirect_query_ = history_service->QueryRedirectsFrom( 717 redirect_query_ = history_service->QueryRedirectsFrom(
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 DevToolsWindow::InspectElement(tab_contents->render_view_host(), x, y); 1314 DevToolsWindow::InspectElement(tab_contents->render_view_host(), x, y);
1314 } else { 1315 } else {
1315 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); 1316 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1);
1316 Send(reply_message); 1317 Send(reply_message);
1317 } 1318 }
1318 } 1319 }
1319 1320
1320 void TestingAutomationProvider::GetDownloadDirectory( 1321 void TestingAutomationProvider::GetDownloadDirectory(
1321 int handle, FilePath* download_directory) { 1322 int handle, FilePath* download_directory) {
1322 if (tab_tracker_->ContainsHandle(handle)) { 1323 if (tab_tracker_->ContainsHandle(handle)) {
1323 NavigationController* tab = tab_tracker_->GetResource(handle); 1324 NavigationController* nav = tab_tracker_->GetResource(handle);
1324 DownloadManager* dlm = tab->profile()->GetDownloadManager(); 1325 Profile* profile = static_cast<Profile*>(nav->browser_context());
1326 DownloadManager* dlm = profile->GetDownloadManager();
1325 *download_directory = dlm->download_prefs()->download_path(); 1327 *download_directory = dlm->download_prefs()->download_path();
1326 } 1328 }
1327 } 1329 }
1328 1330
1329 void TestingAutomationProvider::OpenNewBrowserWindowOfType( 1331 void TestingAutomationProvider::OpenNewBrowserWindowOfType(
1330 int type, bool show, IPC::Message* reply_message) { 1332 int type, bool show, IPC::Message* reply_message) {
1331 new BrowserOpenedNotificationObserver(this, reply_message); 1333 new BrowserOpenedNotificationObserver(this, reply_message);
1332 // We may have no current browser windows open so don't rely on 1334 // We may have no current browser windows open so don't rely on
1333 // asking an existing browser to execute the IDC_NEWWINDOW command 1335 // asking an existing browser to execute the IDC_NEWWINDOW command
1334 Browser* browser = new Browser(static_cast<Browser::Type>(type), profile_); 1336 Browser* browser = new Browser(static_cast<Browser::Type>(type), profile_);
(...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after
4262 DictionaryValue* args, 4264 DictionaryValue* args,
4263 IPC::Message* reply_message) { 4265 IPC::Message* reply_message) {
4264 AutomationJSONReply reply(this, reply_message); 4266 AutomationJSONReply reply(this, reply_message);
4265 // Get the AutofillProfiles currently in the database. 4267 // Get the AutofillProfiles currently in the database.
4266 int tab_index = 0; 4268 int tab_index = 0;
4267 if (!args->GetInteger("tab_index", &tab_index)) { 4269 if (!args->GetInteger("tab_index", &tab_index)) {
4268 reply.SendError("Invalid or missing tab_index integer value."); 4270 reply.SendError("Invalid or missing tab_index integer value.");
4269 return; 4271 return;
4270 } 4272 }
4271 4273
4272 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); 4274 TabContentsWrapper* tab_contents =
4275 browser->GetTabContentsWrapperAt(tab_index);
4273 if (tab_contents) { 4276 if (tab_contents) {
4274 PersonalDataManager* pdm = tab_contents->profile()->GetOriginalProfile() 4277 PersonalDataManager* pdm =
4275 ->GetPersonalDataManager(); 4278 tab_contents->profile()->GetOriginalProfile()->GetPersonalDataManager();
4276 if (pdm) { 4279 if (pdm) {
4277 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); 4280 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles();
4278 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); 4281 std::vector<CreditCard*> credit_cards = pdm->credit_cards();
4279 4282
4280 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); 4283 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles);
4281 ListValue* cards = GetListFromCreditCards(credit_cards); 4284 ListValue* cards = GetListFromCreditCards(credit_cards);
4282 4285
4283 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 4286 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
4284 4287
4285 return_value->Set("profiles", profiles); 4288 return_value->Set("profiles", profiles);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 } 4330 }
4328 4331
4329 // Save the AutofillProfiles. 4332 // Save the AutofillProfiles.
4330 int tab_index = 0; 4333 int tab_index = 0;
4331 if (!args->GetInteger("tab_index", &tab_index)) { 4334 if (!args->GetInteger("tab_index", &tab_index)) {
4332 AutomationJSONReply(this, reply_message).SendError( 4335 AutomationJSONReply(this, reply_message).SendError(
4333 "Invalid or missing tab_index integer"); 4336 "Invalid or missing tab_index integer");
4334 return; 4337 return;
4335 } 4338 }
4336 4339
4337 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); 4340 TabContentsWrapper* tab_contents =
4341 browser->GetTabContentsWrapperAt(tab_index);
4338 4342
4339 if (tab_contents) { 4343 if (tab_contents) {
4340 PersonalDataManager* pdm = tab_contents->profile() 4344 PersonalDataManager* pdm =
4341 ->GetPersonalDataManager(); 4345 tab_contents->profile()->GetPersonalDataManager();
4342 if (pdm) { 4346 if (pdm) {
4343 if (profiles || cards) { 4347 if (profiles || cards) {
4344 // This observer will delete itself. 4348 // This observer will delete itself.
4345 AutofillChangedObserver* observer = new AutofillChangedObserver( 4349 AutofillChangedObserver* observer = new AutofillChangedObserver(
4346 this, reply_message, autofill_profiles.size(), credit_cards.size()); 4350 this, reply_message, autofill_profiles.size(), credit_cards.size());
4347 observer->Init(); 4351 observer->Init();
4348 4352
4349 if (profiles) 4353 if (profiles)
4350 pdm->SetProfiles(&autofill_profiles); 4354 pdm->SetProfiles(&autofill_profiles);
4351 if (cards) 4355 if (cards)
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
6070 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); 6074 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);
6071 6075
6072 Send(reply_message_); 6076 Send(reply_message_);
6073 redirect_query_ = 0; 6077 redirect_query_ = 0;
6074 reply_message_ = NULL; 6078 reply_message_ = NULL;
6075 } 6079 }
6076 6080
6077 void TestingAutomationProvider::OnRemoveProvider() { 6081 void TestingAutomationProvider::OnRemoveProvider() {
6078 AutomationProviderList::GetInstance()->RemoveProvider(this); 6082 AutomationProviderList::GetInstance()->RemoveProvider(this);
6079 } 6083 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698