| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "app/message_box_flags.h" | 9 #include "app/message_box_flags.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 is_connected_ = true; | 351 is_connected_ = true; |
| 352 LOG(INFO) << "Testing channel connected, sending hello message"; | 352 LOG(INFO) << "Testing channel connected, sending hello message"; |
| 353 | 353 |
| 354 // Send a hello message with our current automation protocol version. | 354 // Send a hello message with our current automation protocol version. |
| 355 chrome::VersionInfo version_info; | 355 chrome::VersionInfo version_info; |
| 356 channel_->Send(new AutomationMsg_Hello(version_info.Version())); | 356 channel_->Send(new AutomationMsg_Hello(version_info.Version())); |
| 357 if (initial_loads_complete_) | 357 if (initial_loads_complete_) |
| 358 Send(new AutomationMsg_InitialLoadsComplete()); | 358 Send(new AutomationMsg_InitialLoadsComplete()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void AutomationProvider::OnMessageReceived(const IPC::Message& message) { | 361 bool AutomationProvider::OnMessageReceived(const IPC::Message& message) { |
| 362 bool handled = true; |
| 362 IPC_BEGIN_MESSAGE_MAP(AutomationProvider, message) | 363 IPC_BEGIN_MESSAGE_MAP(AutomationProvider, message) |
| 363 #if !defined(OS_MACOSX) | 364 #if !defined(OS_MACOSX) |
| 364 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, | 365 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, |
| 365 WindowSimulateDrag) | 366 WindowSimulateDrag) |
| 366 #endif // !defined(OS_MACOSX) | 367 #endif // !defined(OS_MACOSX) |
| 367 IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused) | 368 IPC_MESSAGE_HANDLER(AutomationMsg_HandleUnused, HandleUnused) |
| 368 IPC_MESSAGE_HANDLER(AutomationMsg_SetProxyConfig, SetProxyConfig); | 369 IPC_MESSAGE_HANDLER(AutomationMsg_SetProxyConfig, SetProxyConfig) |
| 369 IPC_MESSAGE_HANDLER(AutomationMsg_PrintAsync, PrintAsync) | 370 IPC_MESSAGE_HANDLER(AutomationMsg_PrintAsync, PrintAsync) |
| 370 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, HandleFindRequest) | 371 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Find, HandleFindRequest) |
| 371 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) | 372 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) |
| 372 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) | 373 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) |
| 373 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) | 374 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) |
| 374 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) | 375 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) |
| 375 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) | 376 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) |
| 376 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) | 377 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) |
| 377 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) | 378 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) |
| 378 IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) | 379 IPC_MESSAGE_HANDLER(AutomationMsg_SetPageFontSize, OnSetPageFontSize) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 OnMessageFromExternalHost) | 423 OnMessageFromExternalHost) |
| 423 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved) | 424 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserMove, OnBrowserMoved) |
| 424 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RunUnloadHandlers, | 425 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_RunUnloadHandlers, |
| 425 OnRunUnloadHandlers) | 426 OnRunUnloadHandlers) |
| 426 IPC_MESSAGE_HANDLER(AutomationMsg_SetZoomLevel, OnSetZoomLevel) | 427 IPC_MESSAGE_HANDLER(AutomationMsg_SetZoomLevel, OnSetZoomLevel) |
| 427 #endif // defined(OS_WIN) | 428 #endif // defined(OS_WIN) |
| 428 #if defined(OS_CHROMEOS) | 429 #if defined(OS_CHROMEOS) |
| 429 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoginWithUserAndPass, | 430 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoginWithUserAndPass, |
| 430 LoginWithUserAndPass) | 431 LoginWithUserAndPass) |
| 431 #endif // defined(OS_CHROMEOS) | 432 #endif // defined(OS_CHROMEOS) |
| 432 IPC_MESSAGE_UNHANDLED(OnUnhandledMessage()) | 433 IPC_MESSAGE_UNHANDLED(handled = false;OnUnhandledMessage()) |
| 433 IPC_END_MESSAGE_MAP() | 434 IPC_END_MESSAGE_MAP() |
| 435 return handled; |
| 434 } | 436 } |
| 435 | 437 |
| 436 void AutomationProvider::OnUnhandledMessage() { | 438 void AutomationProvider::OnUnhandledMessage() { |
| 437 // We should not hang here. Print a message to indicate what's going on, | 439 // We should not hang here. Print a message to indicate what's going on, |
| 438 // and disconnect the channel to notify the caller about the error | 440 // and disconnect the channel to notify the caller about the error |
| 439 // in a way it can't ignore, and make any further attempts to send | 441 // in a way it can't ignore, and make any further attempts to send |
| 440 // messages fail fast. | 442 // messages fail fast. |
| 441 LOG(ERROR) << "AutomationProvider received a message it can't handle. " | 443 LOG(ERROR) << "AutomationProvider received a message it can't handle. " |
| 442 << "Please make sure that you use switches::kTestingChannelID " | 444 << "Please make sure that you use switches::kTestingChannelID " |
| 443 << "for test code (TestingAutomationProvider), and " | 445 << "for test code (TestingAutomationProvider), and " |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 } | 1016 } |
| 1015 } | 1017 } |
| 1016 } | 1018 } |
| 1017 | 1019 |
| 1018 void AutomationProvider::SaveAsAsync(int tab_handle) { | 1020 void AutomationProvider::SaveAsAsync(int tab_handle) { |
| 1019 NavigationController* tab = NULL; | 1021 NavigationController* tab = NULL; |
| 1020 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); | 1022 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); |
| 1021 if (tab_contents) | 1023 if (tab_contents) |
| 1022 tab_contents->OnSavePage(); | 1024 tab_contents->OnSavePage(); |
| 1023 } | 1025 } |
| OLD | NEW |