| 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/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 int number_of_navigations, bool include_current_navigation) { | 209 int number_of_navigations, bool include_current_navigation) { |
| 210 NotificationObserver* observer = | 210 NotificationObserver* observer = |
| 211 new NavigationNotificationObserver(tab, this, reply_message, | 211 new NavigationNotificationObserver(tab, this, reply_message, |
| 212 number_of_navigations, | 212 number_of_navigations, |
| 213 include_current_navigation); | 213 include_current_navigation); |
| 214 | 214 |
| 215 notification_observer_list_.AddObserver(observer); | 215 notification_observer_list_.AddObserver(observer); |
| 216 return observer; | 216 return observer; |
| 217 } | 217 } |
| 218 | 218 |
| 219 void AutomationProvider::RemoveNavigationStatusListener( | |
| 220 NotificationObserver* obs) { | |
| 221 notification_observer_list_.RemoveObserver(obs); | |
| 222 } | |
| 223 | |
| 224 NotificationObserver* AutomationProvider::AddTabStripObserver( | 219 NotificationObserver* AutomationProvider::AddTabStripObserver( |
| 225 Browser* parent, | 220 Browser* parent, |
| 226 IPC::Message* reply_message) { | 221 IPC::Message* reply_message) { |
| 227 NotificationObserver* observer = | 222 NotificationObserver* observer = |
| 228 new TabAppendedNotificationObserver(parent, this, reply_message); | 223 new TabAppendedNotificationObserver(parent, this, reply_message); |
| 229 notification_observer_list_.AddObserver(observer); | 224 notification_observer_list_.AddObserver(observer); |
| 230 | 225 |
| 231 return observer; | 226 return observer; |
| 232 } | 227 } |
| 233 | 228 |
| 234 void AutomationProvider::RemoveTabStripObserver(NotificationObserver* obs) { | 229 void AutomationProvider::RemoveObserver(NotificationObserver* obs) { |
| 235 notification_observer_list_.RemoveObserver(obs); | 230 notification_observer_list_.RemoveObserver(obs); |
| 236 } | 231 } |
| 237 | 232 |
| 238 void AutomationProvider::AddLoginHandler(NavigationController* tab, | 233 void AutomationProvider::AddLoginHandler(NavigationController* tab, |
| 239 LoginHandler* handler) { | 234 LoginHandler* handler) { |
| 240 login_handler_map_[tab] = handler; | 235 login_handler_map_[tab] = handler; |
| 241 } | 236 } |
| 242 | 237 |
| 243 void AutomationProvider::RemoveLoginHandler(NavigationController* tab) { | 238 void AutomationProvider::RemoveLoginHandler(NavigationController* tab) { |
| 244 DCHECK(login_handler_map_[tab]); | 239 DCHECK(login_handler_map_[tab]); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 GetPageCurrentEncoding) | 487 GetPageCurrentEncoding) |
| 493 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) | 488 IPC_MESSAGE_HANDLER(AutomationMsg_OverrideEncoding, OverrideEncoding) |
| 494 IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, | 489 IPC_MESSAGE_HANDLER(AutomationMsg_SavePackageShouldPromptUser, |
| 495 SavePackageShouldPromptUser) | 490 SavePackageShouldPromptUser) |
| 496 IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) | 491 IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) |
| 497 #if defined(OS_WIN) | 492 #if defined(OS_WIN) |
| 498 // Depends on ExternalTabContainer, so Windows-only | 493 // Depends on ExternalTabContainer, so Windows-only |
| 499 IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, | 494 IPC_MESSAGE_HANDLER(AutomationMsg_SetEnableExtensionAutomation, |
| 500 SetEnableExtensionAutomation) | 495 SetEnableExtensionAutomation) |
| 501 #endif | 496 #endif |
| 497 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 498 AutomationMsg_WaitForDownloadShelfVisibilityChange, |
| 499 WaitForDownloadShelfVisibilityChange) |
| 502 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) | 500 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) |
| 503 IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) | 501 IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) |
| 504 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) | 502 IPC_MESSAGE_HANDLER(AutomationMsg_SelectAll, SelectAll) |
| 505 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) | 503 IPC_MESSAGE_HANDLER(AutomationMsg_Cut, Cut) |
| 506 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) | 504 IPC_MESSAGE_HANDLER(AutomationMsg_Copy, Copy) |
| 507 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) | 505 IPC_MESSAGE_HANDLER(AutomationMsg_Paste, Paste) |
| 508 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) | 506 IPC_MESSAGE_HANDLER(AutomationMsg_ReloadAsync, ReloadAsync) |
| 509 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) | 507 IPC_MESSAGE_HANDLER(AutomationMsg_StopAsync, StopAsync) |
| 510 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 508 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 511 AutomationMsg_WaitForBrowserWindowCountToBecome, | 509 AutomationMsg_WaitForBrowserWindowCountToBecome, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 std::string()); | 593 std::string()); |
| 596 if (tab_contents) { | 594 if (tab_contents) { |
| 597 append_tab_response = | 595 append_tab_response = |
| 598 GetIndexForNavigationController(&tab_contents->controller(), browser); | 596 GetIndexForNavigationController(&tab_contents->controller(), browser); |
| 599 } | 597 } |
| 600 } | 598 } |
| 601 | 599 |
| 602 if (append_tab_response < 0) { | 600 if (append_tab_response < 0) { |
| 603 // The append tab failed. Remove the TabStripObserver | 601 // The append tab failed. Remove the TabStripObserver |
| 604 if (observer) { | 602 if (observer) { |
| 605 RemoveTabStripObserver(observer); | 603 RemoveObserver(observer); |
| 606 delete observer; | 604 delete observer; |
| 607 } | 605 } |
| 608 | 606 |
| 609 AutomationMsg_AppendTab::WriteReplyParams(reply_message, | 607 AutomationMsg_AppendTab::WriteReplyParams(reply_message, |
| 610 append_tab_response); | 608 append_tab_response); |
| 611 Send(reply_message); | 609 Send(reply_message); |
| 612 } | 610 } |
| 613 } | 611 } |
| 614 | 612 |
| 615 void AutomationProvider::NavigateToURL(int handle, const GURL& url, | 613 void AutomationProvider::NavigateToURL(int handle, const GURL& url, |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 const BookmarkNode* parent = node->GetParent(); | 1585 const BookmarkNode* parent = node->GetParent(); |
| 1588 DCHECK(parent); | 1586 DCHECK(parent); |
| 1589 model->Remove(parent, parent->IndexOfChild(node)); | 1587 model->Remove(parent, parent->IndexOfChild(node)); |
| 1590 *success = true; | 1588 *success = true; |
| 1591 } | 1589 } |
| 1592 } | 1590 } |
| 1593 } | 1591 } |
| 1594 *success = false; | 1592 *success = false; |
| 1595 } | 1593 } |
| 1596 | 1594 |
| 1595 void AutomationProvider::WaitForDownloadShelfVisibilityChange( |
| 1596 int browser_handle, |
| 1597 bool desired_visibility, |
| 1598 IPC::Message* reply_message) { |
| 1599 bool success = false; |
| 1600 if (browser_tracker_->ContainsHandle(browser_handle)) { |
| 1601 bool visibility = !desired_visibility; |
| 1602 GetShelfVisibility(browser_handle, &visibility); |
| 1603 if (visibility == desired_visibility) { |
| 1604 success = true; |
| 1605 } else { |
| 1606 Browser* browser = browser_tracker_->GetResource(browser_handle); |
| 1607 notification_observer_list_.AddObserver( |
| 1608 new DownloadShelfVisibilityObserver(this, |
| 1609 browser, |
| 1610 desired_visibility, |
| 1611 reply_message)); |
| 1612 return; |
| 1613 } |
| 1614 } |
| 1615 AutomationMsg_WaitForDownloadShelfVisibilityChange::WriteReplyParams( |
| 1616 reply_message, success); |
| 1617 Send(reply_message); |
| 1618 } |
| 1619 |
| 1597 // Sample json input: { "command": "SetWindowDimensions", | 1620 // Sample json input: { "command": "SetWindowDimensions", |
| 1598 // "x": 20, # optional | 1621 // "x": 20, # optional |
| 1599 // "y": 20, # optional | 1622 // "y": 20, # optional |
| 1600 // "width": 800, # optional | 1623 // "width": 800, # optional |
| 1601 // "height": 600 } # optional | 1624 // "height": 600 } # optional |
| 1602 void AutomationProvider::SetWindowDimensions(Browser* browser, | 1625 void AutomationProvider::SetWindowDimensions(Browser* browser, |
| 1603 DictionaryValue* args, | 1626 DictionaryValue* args, |
| 1604 IPC::Message* reply_message) { | 1627 IPC::Message* reply_message) { |
| 1605 gfx::Rect rect = browser->window()->GetRestoredBounds(); | 1628 gfx::Rect rect = browser->window()->GetRestoredBounds(); |
| 1606 int x, y, width, height; | 1629 int x, y, width, height; |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3530 } | 3553 } |
| 3531 | 3554 |
| 3532 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { | 3555 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { |
| 3533 NOTIMPLEMENTED(); | 3556 NOTIMPLEMENTED(); |
| 3534 } | 3557 } |
| 3535 #endif // !defined(TOOLKIT_VIEWS) | 3558 #endif // !defined(TOOLKIT_VIEWS) |
| 3536 | 3559 |
| 3537 void AutomationProvider::ResetToDefaultTheme() { | 3560 void AutomationProvider::ResetToDefaultTheme() { |
| 3538 profile_->ClearTheme(); | 3561 profile_->ClearTheme(); |
| 3539 } | 3562 } |
| OLD | NEW |