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

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: Views test 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) { 211 void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) {
212 // For backwards compatibility with the testing automation interface, we 212 // For backwards compatibility with the testing automation interface, we
213 // want the automation provider (and hence the process) to go away when the 213 // want the automation provider (and hence the process) to go away when the
214 // last browser goes away. 214 // last browser goes away.
215 if (BrowserList::empty() && !CommandLine::ForCurrentProcess()->HasSwitch( 215 if (BrowserList::empty() && !CommandLine::ForCurrentProcess()->HasSwitch(
216 switches::kKeepAliveForTest)) { 216 switches::kKeepAliveForTest)) {
217 // If you change this, update Observer for chrome::SESSION_END 217 // If you change this, update Observer for chrome::SESSION_END
218 // below. 218 // below.
219 MessageLoop::current()->PostTask(FROM_HERE, 219 MessageLoop::current()->PostTask(
220 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); 220 FROM_HERE,
221 base::Bind(&TestingAutomationProvider::OnRemoveProvider, this));
221 } 222 }
222 } 223 }
223 224
224 void TestingAutomationProvider::OnSourceProfilesLoaded() { 225 void TestingAutomationProvider::OnSourceProfilesLoaded() {
225 DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get()); 226 DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get());
226 227
227 // Get the correct profile based on the browser that the user provided. 228 // Get the correct profile based on the browser that the user provided.
228 importer::SourceProfile source_profile; 229 importer::SourceProfile source_profile;
229 size_t i = 0; 230 size_t i = 0;
230 size_t importers_count = importer_list_->count(); 231 size_t importers_count = importer_list_->count();
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 868 }
868 } 869 }
869 870
870 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message, 871 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message,
871 int handle, 872 int handle,
872 const gfx::Point& click, 873 const gfx::Point& click,
873 int flags) { 874 int flags) {
874 if (window_tracker_->ContainsHandle(handle)) { 875 if (window_tracker_->ContainsHandle(handle)) {
875 // TODO(phajdan.jr): This is flaky. We should wait for the final click. 876 // TODO(phajdan.jr): This is flaky. We should wait for the final click.
876 ui_controls::SendMouseMoveNotifyWhenDone( 877 ui_controls::SendMouseMoveNotifyWhenDone(
877 click.x(), click.y(), NewRunnableFunction(&SendMouseClick, flags)); 878 click.x(), click.y(), base::Bind(&SendMouseClick, flags));
878 } 879 }
879 } 880 }
880 881
881 void TestingAutomationProvider::WindowSimulateMouseMove( 882 void TestingAutomationProvider::WindowSimulateMouseMove(
882 const IPC::Message& message, 883 const IPC::Message& message,
883 int handle, 884 int handle,
884 const gfx::Point& location) { 885 const gfx::Point& location) {
885 if (window_tracker_->ContainsHandle(handle)) 886 if (window_tracker_->ContainsHandle(handle))
886 ui_controls::SendMouseMove(location.x(), location.y()); 887 ui_controls::SendMouseMove(location.x(), location.y());
887 } 888 }
(...skipping 4644 matching lines...) Expand 10 before | Expand all | Expand 10 after
5532 return; 5533 return;
5533 } 5534 }
5534 5535
5535 bool control = !!(modifiers & automation::kControlKeyMask); 5536 bool control = !!(modifiers & automation::kControlKeyMask);
5536 bool shift = !!(modifiers & automation::kShiftKeyMask); 5537 bool shift = !!(modifiers & automation::kShiftKeyMask);
5537 bool alt = !!(modifiers & automation::kAltKeyMask); 5538 bool alt = !!(modifiers & automation::kAltKeyMask);
5538 bool meta = !!(modifiers & automation::kMetaKeyMask); 5539 bool meta = !!(modifiers & automation::kMetaKeyMask);
5539 if (!ui_controls::SendKeyPressNotifyWhenDone( 5540 if (!ui_controls::SendKeyPressNotifyWhenDone(
5540 window, static_cast<ui::KeyboardCode>(keycode), 5541 window, static_cast<ui::KeyboardCode>(keycode),
5541 control, shift, alt, meta, 5542 control, shift, alt, meta,
5542 NewRunnableMethod(this, 5543 base::Bind(&TestingAutomationProvider::SendSuccessReply, this,
5543 &TestingAutomationProvider::SendSuccessReply, reply_message))) { 5544 reply_message))) {
5544 AutomationJSONReply(this, reply_message) 5545 AutomationJSONReply(this, reply_message)
5545 .SendError("Could not send the native key event"); 5546 .SendError("Could not send the native key event");
5546 } 5547 }
5547 } 5548 }
5548 5549
5549 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) { 5550 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) {
5550 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 5551 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
5551 } 5552 }
5552 5553
5553 namespace { 5554 namespace {
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
6523 6524
6524 Send(reply_message_); 6525 Send(reply_message_);
6525 redirect_query_ = 0; 6526 redirect_query_ = 0;
6526 reply_message_ = NULL; 6527 reply_message_ = NULL;
6527 } 6528 }
6528 6529
6529 void TestingAutomationProvider::OnRemoveProvider() { 6530 void TestingAutomationProvider::OnRemoveProvider() {
6530 if (g_browser_process) 6531 if (g_browser_process)
6531 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6532 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6532 } 6533 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_util.cc ('k') | chrome/browser/automation/testing_automation_provider_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698