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

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

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 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 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 IPC::Message* reply_message) { 2972 IPC::Message* reply_message) {
2973 AutomationJSONReply reply(this, reply_message); 2973 AutomationJSONReply reply(this, reply_message);
2974 int tab_index; 2974 int tab_index;
2975 TabContents* tab_contents = NULL; 2975 TabContents* tab_contents = NULL;
2976 if (!args->GetInteger("tab_index", &tab_index) || 2976 if (!args->GetInteger("tab_index", &tab_index) ||
2977 !(tab_contents = browser->GetTabContentsAt(tab_index))) { 2977 !(tab_contents = browser->GetTabContentsAt(tab_index))) {
2978 reply.SendError("tab_index missing or invalid."); 2978 reply.SendError("tab_index missing or invalid.");
2979 return; 2979 return;
2980 } 2980 }
2981 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 2981 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
2982 const NavigationController& controller = tab_contents->GetController(); 2982 const content::NavigationController& controller =
2983 tab_contents->GetController();
2983 NavigationEntry* nav_entry = controller.GetActiveEntry(); 2984 NavigationEntry* nav_entry = controller.GetActiveEntry();
2984 DCHECK(nav_entry); 2985 DCHECK(nav_entry);
2985 2986
2986 // Security info. 2987 // Security info.
2987 DictionaryValue* ssl = new DictionaryValue; 2988 DictionaryValue* ssl = new DictionaryValue;
2988 std::map<content::SecurityStyle, std::string> style_to_string; 2989 std::map<content::SecurityStyle, std::string> style_to_string;
2989 style_to_string[content::SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN"; 2990 style_to_string[content::SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN";
2990 style_to_string[content::SECURITY_STYLE_UNAUTHENTICATED] = 2991 style_to_string[content::SECURITY_STYLE_UNAUTHENTICATED] =
2991 "SECURITY_STYLE_UNAUTHENTICATED"; 2992 "SECURITY_STYLE_UNAUTHENTICATED";
2992 style_to_string[content::SECURITY_STYLE_AUTHENTICATION_BROKEN] = 2993 style_to_string[content::SECURITY_STYLE_AUTHENTICATION_BROKEN] =
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 AutocompleteEditModel* model = loc_bar->location_entry()->model(); 3537 AutocompleteEditModel* model = loc_bar->location_entry()->model();
3537 model->OnUpOrDownKeyPressed(count); 3538 model->OnUpOrDownKeyPressed(count);
3538 reply.SendSuccess(NULL); 3539 reply.SendSuccess(NULL);
3539 } 3540 }
3540 3541
3541 // Sample json input: { "command": "OmniboxAcceptInput" } 3542 // Sample json input: { "command": "OmniboxAcceptInput" }
3542 void TestingAutomationProvider::OmniboxAcceptInput( 3543 void TestingAutomationProvider::OmniboxAcceptInput(
3543 Browser* browser, 3544 Browser* browser,
3544 DictionaryValue* args, 3545 DictionaryValue* args,
3545 IPC::Message* reply_message) { 3546 IPC::Message* reply_message) {
3546 NavigationController& controller = 3547 content::NavigationController& controller =
3547 browser->GetSelectedWebContents()->GetController(); 3548 browser->GetSelectedWebContents()->GetController();
3548 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); 3549 new OmniboxAcceptNotificationObserver(&controller, this, reply_message);
3549 browser->window()->GetLocationBar()->AcceptInput(); 3550 browser->window()->GetLocationBar()->AcceptInput();
3550 } 3551 }
3551 3552
3552 // Sample json input: { "command": "GetInstantInfo" } 3553 // Sample json input: { "command": "GetInstantInfo" }
3553 void TestingAutomationProvider::GetInstantInfo(Browser* browser, 3554 void TestingAutomationProvider::GetInstantInfo(Browser* browser,
3554 DictionaryValue* args, 3555 DictionaryValue* args,
3555 IPC::Message* reply_message) { 3556 IPC::Message* reply_message) {
3556 DictionaryValue* info = new DictionaryValue; 3557 DictionaryValue* info = new DictionaryValue;
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after
6186 IPC::Message* reply_message) { 6187 IPC::Message* reply_message) {
6187 if (SendErrorIfModalDialogActive(this, reply_message)) 6188 if (SendErrorIfModalDialogActive(this, reply_message))
6188 return; 6189 return;
6189 6190
6190 TabContents* tab_contents; 6191 TabContents* tab_contents;
6191 std::string error; 6192 std::string error;
6192 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { 6193 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
6193 AutomationJSONReply(this, reply_message).SendError(error); 6194 AutomationJSONReply(this, reply_message).SendError(error);
6194 return; 6195 return;
6195 } 6196 }
6196 NavigationController& controller = tab_contents->GetController(); 6197 content::NavigationController& controller = tab_contents->GetController();
6197 if (!controller.CanGoForward()) { 6198 if (!controller.CanGoForward()) {
6198 DictionaryValue dict; 6199 DictionaryValue dict;
6199 dict.SetBoolean("did_go_forward", false); 6200 dict.SetBoolean("did_go_forward", false);
6200 AutomationJSONReply(this, reply_message).SendSuccess(&dict); 6201 AutomationJSONReply(this, reply_message).SendSuccess(&dict);
6201 return; 6202 return;
6202 } 6203 }
6203 new NavigationNotificationObserver(&controller, this, reply_message, 6204 new NavigationNotificationObserver(&controller, this, reply_message,
6204 1, false, true); 6205 1, false, true);
6205 controller.GoForward(); 6206 controller.GoForward();
6206 } 6207 }
6207 6208
6208 void TestingAutomationProvider::GoBack( 6209 void TestingAutomationProvider::GoBack(
6209 DictionaryValue* args, 6210 DictionaryValue* args,
6210 IPC::Message* reply_message) { 6211 IPC::Message* reply_message) {
6211 if (SendErrorIfModalDialogActive(this, reply_message)) 6212 if (SendErrorIfModalDialogActive(this, reply_message))
6212 return; 6213 return;
6213 6214
6214 TabContents* tab_contents; 6215 TabContents* tab_contents;
6215 std::string error; 6216 std::string error;
6216 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { 6217 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
6217 AutomationJSONReply(this, reply_message).SendError(error); 6218 AutomationJSONReply(this, reply_message).SendError(error);
6218 return; 6219 return;
6219 } 6220 }
6220 NavigationController& controller = tab_contents->GetController(); 6221 content::NavigationController& controller = tab_contents->GetController();
6221 if (!controller.CanGoBack()) { 6222 if (!controller.CanGoBack()) {
6222 DictionaryValue dict; 6223 DictionaryValue dict;
6223 dict.SetBoolean("did_go_back", false); 6224 dict.SetBoolean("did_go_back", false);
6224 AutomationJSONReply(this, reply_message).SendSuccess(&dict); 6225 AutomationJSONReply(this, reply_message).SendSuccess(&dict);
6225 return; 6226 return;
6226 } 6227 }
6227 new NavigationNotificationObserver(&controller, this, reply_message, 6228 new NavigationNotificationObserver(&controller, this, reply_message,
6228 1, false, true); 6229 1, false, true);
6229 controller.GoBack(); 6230 controller.GoBack();
6230 } 6231 }
6231 6232
6232 void TestingAutomationProvider::ReloadJSON( 6233 void TestingAutomationProvider::ReloadJSON(
6233 DictionaryValue* args, 6234 DictionaryValue* args,
6234 IPC::Message* reply_message) { 6235 IPC::Message* reply_message) {
6235 if (SendErrorIfModalDialogActive(this, reply_message)) 6236 if (SendErrorIfModalDialogActive(this, reply_message))
6236 return; 6237 return;
6237 6238
6238 TabContents* tab_contents; 6239 TabContents* tab_contents;
6239 std::string error; 6240 std::string error;
6240 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) { 6241 if (!GetTabFromJSONArgs(args, &tab_contents, &error)) {
6241 AutomationJSONReply(this, reply_message).SendError(error); 6242 AutomationJSONReply(this, reply_message).SendError(error);
6242 return; 6243 return;
6243 } 6244 }
6244 NavigationController& controller = tab_contents->GetController(); 6245 content::NavigationController& controller = tab_contents->GetController();
6245 new NavigationNotificationObserver(&controller, this, reply_message, 6246 new NavigationNotificationObserver(&controller, this, reply_message,
6246 1, false, true); 6247 1, false, true);
6247 controller.Reload(false); 6248 controller.Reload(false);
6248 } 6249 }
6249 6250
6250 void TestingAutomationProvider::CaptureEntirePageJSON( 6251 void TestingAutomationProvider::CaptureEntirePageJSON(
6251 DictionaryValue* args, 6252 DictionaryValue* args,
6252 IPC::Message* reply_message) { 6253 IPC::Message* reply_message) {
6253 if (SendErrorIfModalDialogActive(this, reply_message)) 6254 if (SendErrorIfModalDialogActive(this, reply_message))
6254 return; 6255 return;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
6691 6692
6692 Send(reply_message_); 6693 Send(reply_message_);
6693 redirect_query_ = 0; 6694 redirect_query_ = 0;
6694 reply_message_ = NULL; 6695 reply_message_ = NULL;
6695 } 6696 }
6696 6697
6697 void TestingAutomationProvider::OnRemoveProvider() { 6698 void TestingAutomationProvider::OnRemoveProvider() {
6698 if (g_browser_process) 6699 if (g_browser_process)
6699 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6700 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6700 } 6701 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698