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

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: Rebase. 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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 } 870 }
870 } 871 }
871 872
872 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message, 873 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message,
873 int handle, 874 int handle,
874 const gfx::Point& click, 875 const gfx::Point& click,
875 int flags) { 876 int flags) {
876 if (window_tracker_->ContainsHandle(handle)) { 877 if (window_tracker_->ContainsHandle(handle)) {
877 // TODO(phajdan.jr): This is flaky. We should wait for the final click. 878 // TODO(phajdan.jr): This is flaky. We should wait for the final click.
878 ui_controls::SendMouseMoveNotifyWhenDone( 879 ui_controls::SendMouseMoveNotifyWhenDone(
879 click.x(), click.y(), NewRunnableFunction(&SendMouseClick, flags)); 880 click.x(), click.y(), base::Bind(&SendMouseClick, flags));
880 } 881 }
881 } 882 }
882 883
883 void TestingAutomationProvider::WindowSimulateMouseMove( 884 void TestingAutomationProvider::WindowSimulateMouseMove(
884 const IPC::Message& message, 885 const IPC::Message& message,
885 int handle, 886 int handle,
886 const gfx::Point& location) { 887 const gfx::Point& location) {
887 if (window_tracker_->ContainsHandle(handle)) 888 if (window_tracker_->ContainsHandle(handle))
888 ui_controls::SendMouseMove(location.x(), location.y()); 889 ui_controls::SendMouseMove(location.x(), location.y());
889 } 890 }
(...skipping 4645 matching lines...) Expand 10 before | Expand all | Expand 10 after
5535 return; 5536 return;
5536 } 5537 }
5537 5538
5538 bool control = !!(modifiers & automation::kControlKeyMask); 5539 bool control = !!(modifiers & automation::kControlKeyMask);
5539 bool shift = !!(modifiers & automation::kShiftKeyMask); 5540 bool shift = !!(modifiers & automation::kShiftKeyMask);
5540 bool alt = !!(modifiers & automation::kAltKeyMask); 5541 bool alt = !!(modifiers & automation::kAltKeyMask);
5541 bool meta = !!(modifiers & automation::kMetaKeyMask); 5542 bool meta = !!(modifiers & automation::kMetaKeyMask);
5542 if (!ui_controls::SendKeyPressNotifyWhenDone( 5543 if (!ui_controls::SendKeyPressNotifyWhenDone(
5543 window, static_cast<ui::KeyboardCode>(keycode), 5544 window, static_cast<ui::KeyboardCode>(keycode),
5544 control, shift, alt, meta, 5545 control, shift, alt, meta,
5545 NewRunnableMethod(this, 5546 base::Bind(&TestingAutomationProvider::SendSuccessReply, this,
5546 &TestingAutomationProvider::SendSuccessReply, reply_message))) { 5547 reply_message))) {
5547 AutomationJSONReply(this, reply_message) 5548 AutomationJSONReply(this, reply_message)
5548 .SendError("Could not send the native key event"); 5549 .SendError("Could not send the native key event");
5549 } 5550 }
5550 } 5551 }
5551 5552
5552 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) { 5553 void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) {
5553 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 5554 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
5554 } 5555 }
5555 5556
5556 namespace { 5557 namespace {
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
6527 6528
6528 Send(reply_message_); 6529 Send(reply_message_);
6529 redirect_query_ = 0; 6530 redirect_query_ = 0;
6530 reply_message_ = NULL; 6531 reply_message_ = NULL;
6531 } 6532 }
6532 6533
6533 void TestingAutomationProvider::OnRemoveProvider() { 6534 void TestingAutomationProvider::OnRemoveProvider() {
6534 if (g_browser_process) 6535 if (g_browser_process)
6535 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6536 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6536 } 6537 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698