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

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

Issue 6539002: Begun the DCHECK() cleanup. Starting off with /src/chrome/a* and /src/chrome/... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 10 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 if (redirect_query_) { 712 if (redirect_query_) {
713 LOG(ERROR) << "Can only handle one redirect query at once."; 713 LOG(ERROR) << "Can only handle one redirect query at once.";
714 } else if (tab_tracker_->ContainsHandle(tab_handle)) { 714 } else if (tab_tracker_->ContainsHandle(tab_handle)) {
715 NavigationController* tab = tab_tracker_->GetResource(tab_handle); 715 NavigationController* tab = tab_tracker_->GetResource(tab_handle);
716 HistoryService* history_service = 716 HistoryService* history_service =
717 tab->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); 717 tab->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
718 718
719 DCHECK(history_service) << "Tab " << tab_handle << "'s profile " << 719 DCHECK(history_service) << "Tab " << tab_handle << "'s profile " <<
720 "has no history service"; 720 "has no history service";
721 if (history_service) { 721 if (history_service) {
722 DCHECK(reply_message_ == NULL); 722 DCHECK(!reply_message_);
723 reply_message_ = reply_message; 723 reply_message_ = reply_message;
724 // Schedule a history query for redirects. The response will be sent 724 // Schedule a history query for redirects. The response will be sent
725 // asynchronously from the callback the history system uses to notify us 725 // asynchronously from the callback the history system uses to notify us
726 // that it's done: OnRedirectQueryComplete. 726 // that it's done: OnRedirectQueryComplete.
727 redirect_query_ = history_service->QueryRedirectsFrom( 727 redirect_query_ = history_service->QueryRedirectsFrom(
728 source_url, &consumer_, 728 source_url, &consumer_,
729 NewCallback(this, 729 NewCallback(this,
730 &TestingAutomationProvider::OnRedirectQueryComplete)); 730 &TestingAutomationProvider::OnRedirectQueryComplete));
731 return; // Response will be sent when query completes. 731 return; // Response will be sent when query completes.
732 } 732 }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1131
1132 // Set the routing id of this message with the controller. 1132 // Set the routing id of this message with the controller.
1133 // This routing id needs to be remembered for the reverse 1133 // This routing id needs to be remembered for the reverse
1134 // communication while sending back the response of 1134 // communication while sending back the response of
1135 // this javascript execution. 1135 // this javascript execution.
1136 std::string set_automation_id; 1136 std::string set_automation_id;
1137 base::SStringPrintf(&set_automation_id, 1137 base::SStringPrintf(&set_automation_id,
1138 "window.domAutomationController.setAutomationId(%d);", 1138 "window.domAutomationController.setAutomationId(%d);",
1139 reply_message->routing_id()); 1139 reply_message->routing_id());
1140 1140
1141 DCHECK(reply_message_ == NULL); 1141 DCHECK(!reply_message_);
1142 reply_message_ = reply_message; 1142 reply_message_ = reply_message;
1143 1143
1144 tab_contents->render_view_host()->ExecuteJavascriptInWebFrame( 1144 tab_contents->render_view_host()->ExecuteJavascriptInWebFrame(
1145 WideToUTF16Hack(frame_xpath), UTF8ToUTF16(set_automation_id)); 1145 WideToUTF16Hack(frame_xpath), UTF8ToUTF16(set_automation_id));
1146 tab_contents->render_view_host()->ExecuteJavascriptInWebFrame( 1146 tab_contents->render_view_host()->ExecuteJavascriptInWebFrame(
1147 WideToUTF16Hack(frame_xpath), WideToUTF16Hack(script)); 1147 WideToUTF16Hack(frame_xpath), WideToUTF16Hack(script));
1148 } 1148 }
1149 1149
1150 void TestingAutomationProvider::GetConstrainedWindowCount(int handle, 1150 void TestingAutomationProvider::GetConstrainedWindowCount(int handle,
1151 int* count) { 1151 int* count) {
1152 *count = -1; // -1 is the error code 1152 *count = -1; // -1 is the error code
1153 if (tab_tracker_->ContainsHandle(handle)) { 1153 if (tab_tracker_->ContainsHandle(handle)) {
1154 NavigationController* nav_controller = tab_tracker_->GetResource(handle); 1154 NavigationController* nav_controller = tab_tracker_->GetResource(handle);
1155 TabContents* tab_contents = nav_controller->tab_contents(); 1155 TabContents* tab_contents = nav_controller->tab_contents();
1156 if (tab_contents) 1156 if (tab_contents)
1157 *count = static_cast<int>(tab_contents->child_windows_.size()); 1157 *count = static_cast<int>(tab_contents->child_windows_.size());
1158 } 1158 }
1159 } 1159 }
1160 1160
1161 void TestingAutomationProvider::HandleInspectElementRequest( 1161 void TestingAutomationProvider::HandleInspectElementRequest(
1162 int handle, int x, int y, IPC::Message* reply_message) { 1162 int handle, int x, int y, IPC::Message* reply_message) {
1163 TabContents* tab_contents = GetTabContentsForHandle(handle, NULL); 1163 TabContents* tab_contents = GetTabContentsForHandle(handle, NULL);
1164 if (tab_contents) { 1164 if (tab_contents) {
1165 DCHECK(reply_message_ == NULL); 1165 DCHECK(!reply_message_);
1166 reply_message_ = reply_message; 1166 reply_message_ = reply_message;
1167 1167
1168 DevToolsManager::GetInstance()->InspectElement( 1168 DevToolsManager::GetInstance()->InspectElement(
1169 tab_contents->render_view_host(), x, y); 1169 tab_contents->render_view_host(), x, y);
1170 } else { 1170 } else {
1171 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); 1171 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1);
1172 Send(reply_message); 1172 Send(reply_message);
1173 } 1173 }
1174 } 1174 }
1175 1175
(...skipping 3458 matching lines...) Expand 10 before | Expand all | Expand 10 after
4634 } 4634 }
4635 } 4635 }
4636 } 4636 }
4637 4637
4638 // TODO(brettw) change this to accept GURLs when history supports it 4638 // TODO(brettw) change this to accept GURLs when history supports it
4639 void TestingAutomationProvider::OnRedirectQueryComplete( 4639 void TestingAutomationProvider::OnRedirectQueryComplete(
4640 HistoryService::Handle request_handle, 4640 HistoryService::Handle request_handle,
4641 GURL from_url, 4641 GURL from_url,
4642 bool success, 4642 bool success,
4643 history::RedirectList* redirects) { 4643 history::RedirectList* redirects) {
4644 DCHECK(request_handle == redirect_query_); 4644 DCHECK_EQ(request_handle, redirect_query_);
4645 DCHECK(reply_message_ != NULL); 4645 DCHECK(reply_message_ != NULL);
4646 4646
4647 std::vector<GURL> redirects_gurl; 4647 std::vector<GURL> redirects_gurl;
4648 reply_message_->WriteBool(success); 4648 reply_message_->WriteBool(success);
4649 if (success) { 4649 if (success) {
4650 for (size_t i = 0; i < redirects->size(); i++) 4650 for (size_t i = 0; i < redirects->size(); i++)
4651 redirects_gurl.push_back(redirects->at(i)); 4651 redirects_gurl.push_back(redirects->at(i));
4652 } 4652 }
4653 4653
4654 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); 4654 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl);
(...skipping 15 matching lines...) Expand all
4670 // If you change this, update Observer for NotificationType::SESSION_END 4670 // If you change this, update Observer for NotificationType::SESSION_END
4671 // below. 4671 // below.
4672 MessageLoop::current()->PostTask(FROM_HERE, 4672 MessageLoop::current()->PostTask(FROM_HERE,
4673 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); 4673 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider));
4674 } 4674 }
4675 } 4675 }
4676 4676
4677 void TestingAutomationProvider::OnRemoveProvider() { 4677 void TestingAutomationProvider::OnRemoveProvider() {
4678 AutomationProviderList::GetInstance()->RemoveProvider(this); 4678 AutomationProviderList::GetInstance()->RemoveProvider(this);
4679 } 4679 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698