| 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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 void TestingAutomationProvider::Observe(NotificationType type, | 196 void TestingAutomationProvider::Observe(NotificationType type, |
| 197 const NotificationSource& source, | 197 const NotificationSource& source, |
| 198 const NotificationDetails& details) { | 198 const NotificationDetails& details) { |
| 199 DCHECK(type == NotificationType::SESSION_END); | 199 DCHECK(type == NotificationType::SESSION_END); |
| 200 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit | 200 // OnBrowserRemoved does a ReleaseLater. When session end is received we exit |
| 201 // before the task runs resulting in this object not being deleted. This | 201 // before the task runs resulting in this object not being deleted. This |
| 202 // Release balance out the Release scheduled by OnBrowserRemoved. | 202 // Release balance out the Release scheduled by OnBrowserRemoved. |
| 203 Release(); | 203 Release(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void TestingAutomationProvider::OnMessageReceived( | 206 bool TestingAutomationProvider::OnMessageReceived( |
| 207 const IPC::Message& message) { | 207 const IPC::Message& message) { |
| 208 bool handled = true; |
| 208 IPC_BEGIN_MESSAGE_MAP(TestingAutomationProvider, message) | 209 IPC_BEGIN_MESSAGE_MAP(TestingAutomationProvider, message) |
| 209 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser) | 210 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser) |
| 210 IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync, | 211 IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync, |
| 211 CloseBrowserAsync) | 212 CloseBrowserAsync) |
| 212 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) | 213 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) |
| 213 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) | 214 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) |
| 214 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) | 215 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) |
| 215 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) | 216 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) |
| 216 IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) | 217 IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) |
| 217 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) | 218 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, | 383 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, |
| 383 WaitForInfoBarCount) | 384 WaitForInfoBarCount) |
| 384 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, | 385 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, |
| 385 GetPageCurrentEncoding) | 386 GetPageCurrentEncoding) |
| 386 IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService, | 387 IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService, |
| 387 ShutdownSessionService) | 388 ShutdownSessionService) |
| 388 IPC_MESSAGE_HANDLER(AutomationMsg_SetContentSetting, SetContentSetting) | 389 IPC_MESSAGE_HANDLER(AutomationMsg_SetContentSetting, SetContentSetting) |
| 389 IPC_MESSAGE_HANDLER(AutomationMsg_LoadBlockedPlugins, LoadBlockedPlugins) | 390 IPC_MESSAGE_HANDLER(AutomationMsg_LoadBlockedPlugins, LoadBlockedPlugins) |
| 390 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) | 391 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) |
| 391 | 392 |
| 392 IPC_MESSAGE_UNHANDLED(AutomationProvider::OnMessageReceived(message)); | 393 IPC_MESSAGE_UNHANDLED( |
| 394 handled = AutomationProvider::OnMessageReceived(message)) |
| 393 IPC_END_MESSAGE_MAP() | 395 IPC_END_MESSAGE_MAP() |
| 396 return handled; |
| 394 } | 397 } |
| 395 | 398 |
| 396 void TestingAutomationProvider::OnChannelError() { | 399 void TestingAutomationProvider::OnChannelError() { |
| 397 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) | 400 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) |
| 398 BrowserList::CloseAllBrowsersAndExit(); | 401 BrowserList::CloseAllBrowsersAndExit(); |
| 399 AutomationProvider::OnChannelError(); | 402 AutomationProvider::OnChannelError(); |
| 400 } | 403 } |
| 401 | 404 |
| 402 void TestingAutomationProvider::CloseBrowser(int browser_handle, | 405 void TestingAutomationProvider::CloseBrowser(int browser_handle, |
| 403 IPC::Message* reply_message) { | 406 IPC::Message* reply_message) { |
| (...skipping 4091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4495 // If you change this, update Observer for NotificationType::SESSION_END | 4498 // If you change this, update Observer for NotificationType::SESSION_END |
| 4496 // below. | 4499 // below. |
| 4497 MessageLoop::current()->PostTask(FROM_HERE, | 4500 MessageLoop::current()->PostTask(FROM_HERE, |
| 4498 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4501 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
| 4499 } | 4502 } |
| 4500 } | 4503 } |
| 4501 | 4504 |
| 4502 void TestingAutomationProvider::OnRemoveProvider() { | 4505 void TestingAutomationProvider::OnRemoveProvider() { |
| 4503 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4506 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 4504 } | 4507 } |
| OLD | NEW |