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

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

Issue 10810062: Moving common code into OmniboxView from OmniboxView* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More win fixes 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 3113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 IPC::Message* reply_message) { 3124 IPC::Message* reply_message) {
3125 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3125 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3126 AutomationJSONReply reply(this, reply_message); 3126 AutomationJSONReply reply(this, reply_message);
3127 3127
3128 LocationBar* loc_bar = browser->window()->GetLocationBar(); 3128 LocationBar* loc_bar = browser->window()->GetLocationBar();
3129 if (!loc_bar) { 3129 if (!loc_bar) {
3130 reply.SendError("The specified browser does not have a location bar."); 3130 reply.SendError("The specified browser does not have a location bar.");
3131 return; 3131 return;
3132 } 3132 }
3133 const OmniboxView* omnibox_view = loc_bar->GetLocationEntry(); 3133 const OmniboxView* omnibox_view = loc_bar->GetLocationEntry();
3134 const OmniboxEditModel* model = omnibox_view->model(); 3134 const OmniboxEditModel* model = omnibox_view->GetModel();
3135 3135
3136 // Fill up matches. 3136 // Fill up matches.
3137 ListValue* matches = new ListValue; 3137 ListValue* matches = new ListValue;
3138 const AutocompleteResult& result = model->result(); 3138 const AutocompleteResult& result = model->result();
3139 for (AutocompleteResult::const_iterator i(result.begin()); i != result.end(); 3139 for (AutocompleteResult::const_iterator i(result.begin()); i != result.end();
3140 ++i) { 3140 ++i) {
3141 const AutocompleteMatch& match = *i; 3141 const AutocompleteMatch& match = *i;
3142 DictionaryValue* item = new DictionaryValue; // owned by return_value 3142 DictionaryValue* item = new DictionaryValue; // owned by return_value
3143 item->SetString("type", AutocompleteMatch::TypeToString(match.type)); 3143 item->SetString("type", AutocompleteMatch::TypeToString(match.type));
3144 item->SetBoolean("starred", match.starred); 3144 item->SetBoolean("starred", match.starred);
(...skipping 27 matching lines...) Expand all
3172 reply.SendError("text missing"); 3172 reply.SendError("text missing");
3173 return; 3173 return;
3174 } 3174 }
3175 chrome::FocusLocationBar(browser); 3175 chrome::FocusLocationBar(browser);
3176 LocationBar* loc_bar = browser->window()->GetLocationBar(); 3176 LocationBar* loc_bar = browser->window()->GetLocationBar();
3177 if (!loc_bar) { 3177 if (!loc_bar) {
3178 reply.SendError("The specified browser does not have a location bar."); 3178 reply.SendError("The specified browser does not have a location bar.");
3179 return; 3179 return;
3180 } 3180 }
3181 OmniboxView* omnibox_view = loc_bar->GetLocationEntry(); 3181 OmniboxView* omnibox_view = loc_bar->GetLocationEntry();
3182 omnibox_view->model()->OnSetFocus(false); 3182 omnibox_view->GetModel()->OnSetFocus(false);
3183 omnibox_view->SetUserText(text); 3183 omnibox_view->SetUserText(text);
3184 reply.SendSuccess(NULL); 3184 reply.SendSuccess(NULL);
3185 } 3185 }
3186 3186
3187 // Sample json input: { "command": "OmniboxMovePopupSelection", 3187 // Sample json input: { "command": "OmniboxMovePopupSelection",
3188 // "count": 1 } 3188 // "count": 1 }
3189 // Negative count implies up, positive implies down. Count values will be 3189 // Negative count implies up, positive implies down. Count values will be
3190 // capped by the size of the popup list. 3190 // capped by the size of the popup list.
3191 void TestingAutomationProvider::OmniboxMovePopupSelection( 3191 void TestingAutomationProvider::OmniboxMovePopupSelection(
3192 Browser* browser, 3192 Browser* browser,
3193 DictionaryValue* args, 3193 DictionaryValue* args,
3194 IPC::Message* reply_message) { 3194 IPC::Message* reply_message) {
3195 int count; 3195 int count;
3196 AutomationJSONReply reply(this, reply_message); 3196 AutomationJSONReply reply(this, reply_message);
3197 if (!args->GetInteger("count", &count)) { 3197 if (!args->GetInteger("count", &count)) {
3198 reply.SendError("count missing"); 3198 reply.SendError("count missing");
3199 return; 3199 return;
3200 } 3200 }
3201 LocationBar* loc_bar = browser->window()->GetLocationBar(); 3201 LocationBar* loc_bar = browser->window()->GetLocationBar();
3202 if (!loc_bar) { 3202 if (!loc_bar) {
3203 reply.SendError("The specified browser does not have a location bar."); 3203 reply.SendError("The specified browser does not have a location bar.");
3204 return; 3204 return;
3205 } 3205 }
3206 OmniboxEditModel* model = loc_bar->GetLocationEntry()->model(); 3206 OmniboxEditModel* model = loc_bar->GetLocationEntry()->GetModel();
3207 model->OnUpOrDownKeyPressed(count); 3207 model->OnUpOrDownKeyPressed(count);
3208 reply.SendSuccess(NULL); 3208 reply.SendSuccess(NULL);
3209 } 3209 }
3210 3210
3211 // Sample json input: { "command": "OmniboxAcceptInput" } 3211 // Sample json input: { "command": "OmniboxAcceptInput" }
3212 void TestingAutomationProvider::OmniboxAcceptInput( 3212 void TestingAutomationProvider::OmniboxAcceptInput(
3213 Browser* browser, 3213 Browser* browser,
3214 DictionaryValue* args, 3214 DictionaryValue* args,
3215 IPC::Message* reply_message) { 3215 IPC::Message* reply_message) {
3216 NavigationController& controller = 3216 NavigationController& controller =
(...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after
6904 void TestingAutomationProvider::OnRemoveProvider() { 6904 void TestingAutomationProvider::OnRemoveProvider() {
6905 if (g_browser_process) 6905 if (g_browser_process)
6906 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6906 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6907 } 6907 }
6908 6908
6909 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6909 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6910 WebContents* tab) { 6910 WebContents* tab) {
6911 if (chrome::GetActiveWebContents(browser) != tab) 6911 if (chrome::GetActiveWebContents(browser) != tab)
6912 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 6912 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
6913 } 6913 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698