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

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

Issue 8212006: base::Bind: Cleanup in automation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac build fixes. Created 9 years, 2 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) { 209 void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) {
210 // For backwards compatibility with the testing automation interface, we 210 // For backwards compatibility with the testing automation interface, we
211 // want the automation provider (and hence the process) to go away when the 211 // want the automation provider (and hence the process) to go away when the
212 // last browser goes away. 212 // last browser goes away.
213 if (BrowserList::empty() && !CommandLine::ForCurrentProcess()->HasSwitch( 213 if (BrowserList::empty() && !CommandLine::ForCurrentProcess()->HasSwitch(
214 switches::kKeepAliveForTest)) { 214 switches::kKeepAliveForTest)) {
215 // If you change this, update Observer for chrome::SESSION_END 215 // If you change this, update Observer for chrome::SESSION_END
216 // below. 216 // below.
217 MessageLoop::current()->PostTask(FROM_HERE, 217 MessageLoop::current()->PostTask(
218 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); 218 FROM_HERE,
219 base::Bind(&TestingAutomationProvider::OnRemoveProvider, this));
219 } 220 }
220 } 221 }
221 222
222 void TestingAutomationProvider::OnSourceProfilesLoaded() { 223 void TestingAutomationProvider::OnSourceProfilesLoaded() {
223 DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get()); 224 DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get());
224 225
225 // Get the correct profile based on the browser that the user provided. 226 // Get the correct profile based on the browser that the user provided.
226 importer::SourceProfile source_profile; 227 importer::SourceProfile source_profile;
227 size_t i = 0; 228 size_t i = 0;
228 size_t importers_count = importer_list_->count(); 229 size_t importers_count = importer_list_->count();
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 866 }
866 } 867 }
867 868
868 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message, 869 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message,
869 int handle, 870 int handle,
870 const gfx::Point& click, 871 const gfx::Point& click,
871 int flags) { 872 int flags) {
872 if (window_tracker_->ContainsHandle(handle)) { 873 if (window_tracker_->ContainsHandle(handle)) {
873 // TODO(phajdan.jr): This is flaky. We should wait for the final click. 874 // TODO(phajdan.jr): This is flaky. We should wait for the final click.
874 ui_controls::SendMouseMoveNotifyWhenDone( 875 ui_controls::SendMouseMoveNotifyWhenDone(
875 click.x(), click.y(), NewRunnableFunction(&SendMouseClick, flags)); 876 click.x(), click.y(), base::Bind(&SendMouseClick, flags));
876 } 877 }
877 } 878 }
878 879
879 void TestingAutomationProvider::WindowSimulateMouseMove( 880 void TestingAutomationProvider::WindowSimulateMouseMove(
880 const IPC::Message& message, 881 const IPC::Message& message,
881 int handle, 882 int handle,
882 const gfx::Point& location) { 883 const gfx::Point& location) {
883 if (window_tracker_->ContainsHandle(handle)) 884 if (window_tracker_->ContainsHandle(handle))
884 ui_controls::SendMouseMove(location.x(), location.y()); 885 ui_controls::SendMouseMove(location.x(), location.y());
885 } 886 }
(...skipping 4630 matching lines...) Expand 10 before | Expand all | Expand 10 after
5516 return; 5517 return;
5517 } 5518 }
5518 5519
5519 bool control = !!(modifiers & automation::kControlKeyMask); 5520 bool control = !!(modifiers & automation::kControlKeyMask);
5520 bool shift = !!(modifiers & automation::kShiftKeyMask); 5521 bool shift = !!(modifiers & automation::kShiftKeyMask);
5521 bool alt = !!(modifiers & automation::kAltKeyMask); 5522 bool alt = !!(modifiers & automation::kAltKeyMask);
5522 bool meta = !!(modifiers & automation::kMetaKeyMask); 5523 bool meta = !!(modifiers & automation::kMetaKeyMask);
5523 if (!ui_controls::SendKeyPressNotifyWhenDone( 5524 if (!ui_controls::SendKeyPressNotifyWhenDone(
5524 window, static_cast<ui::KeyboardCode>(keycode), 5525 window, static_cast<ui::KeyboardCode>(keycode),
5525 control, shift, alt, meta, 5526 control, shift, alt, meta,
5526 NewRunnableMethod(this, 5527 base::Bind(&TestingAutomationProvider::SendSuccessReply, this,
5527 &TestingAutomationProvider::SendSuccessReply, reply_message))) { 5528 reply_message))) {
5528 AutomationJSONReply(this, reply_message) 5529 AutomationJSONReply(this, reply_message)
5529 .SendError("Could not send the native key event"); 5530 .SendError("Could not send the native key event");
5530 } 5531 }
5531 } 5532 }
5532 5533
5533 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) { 5534 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) {
5534 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 5535 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
5535 } 5536 }
5536 5537
5537 namespace { 5538 namespace {
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
6507 6508
6508 Send(reply_message_); 6509 Send(reply_message_);
6509 redirect_query_ = 0; 6510 redirect_query_ = 0;
6510 reply_message_ = NULL; 6511 reply_message_ = NULL;
6511 } 6512 }
6512 6513
6513 void TestingAutomationProvider::OnRemoveProvider() { 6514 void TestingAutomationProvider::OnRemoveProvider() {
6514 if (g_browser_process) 6515 if (g_browser_process)
6515 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6516 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6516 } 6517 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698