| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/autofill/personal_data_manager.h" | 30 #include "chrome/browser/autofill/personal_data_manager.h" |
| 31 #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h" | 31 #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h" |
| 32 #include "chrome/browser/automation/automation_browser_tracker.h" | 32 #include "chrome/browser/automation/automation_browser_tracker.h" |
| 33 #include "chrome/browser/automation/automation_provider_json.h" | 33 #include "chrome/browser/automation/automation_provider_json.h" |
| 34 #include "chrome/browser/automation/automation_provider_list.h" | 34 #include "chrome/browser/automation/automation_provider_list.h" |
| 35 #include "chrome/browser/automation/automation_provider_observers.h" | 35 #include "chrome/browser/automation/automation_provider_observers.h" |
| 36 #include "chrome/browser/automation/automation_tab_tracker.h" | 36 #include "chrome/browser/automation/automation_tab_tracker.h" |
| 37 #include "chrome/browser/automation/automation_util.h" | 37 #include "chrome/browser/automation/automation_util.h" |
| 38 #include "chrome/browser/automation/automation_window_tracker.h" | 38 #include "chrome/browser/automation/automation_window_tracker.h" |
| 39 #include "chrome/browser/automation/ui_controls.h" | 39 #include "chrome/browser/automation/ui_controls.h" |
| 40 #include "chrome/browser/blocked_content_container.h" | |
| 41 #include "chrome/browser/bookmarks/bookmark_model.h" | 40 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 42 #include "chrome/browser/bookmarks/bookmark_storage.h" | 41 #include "chrome/browser/bookmarks/bookmark_storage.h" |
| 43 #include "chrome/browser/browser_process.h" | 42 #include "chrome/browser/browser_process.h" |
| 44 #include "chrome/browser/browser_shutdown.h" | 43 #include "chrome/browser/browser_shutdown.h" |
| 45 #include "chrome/browser/debugger/devtools_manager.h" | 44 #include "chrome/browser/debugger/devtools_manager.h" |
| 46 #include "chrome/browser/download/download_prefs.h" | 45 #include "chrome/browser/download/download_prefs.h" |
| 47 #include "chrome/browser/download/download_shelf.h" | 46 #include "chrome/browser/download/download_shelf.h" |
| 48 #include "chrome/browser/download/save_package.h" | 47 #include "chrome/browser/download/save_package.h" |
| 49 #include "chrome/browser/extensions/extension_host.h" | 48 #include "chrome/browser/extensions/extension_host.h" |
| 50 #include "chrome/browser/extensions/extension_service.h" | 49 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 #include "chrome/browser/search_engines/template_url_model.h" | 64 #include "chrome/browser/search_engines/template_url_model.h" |
| 66 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 65 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 67 #include "chrome/browser/tab_contents/link_infobar_delegate.h" | 66 #include "chrome/browser/tab_contents/link_infobar_delegate.h" |
| 68 #include "chrome/browser/themes/theme_service.h" | 67 #include "chrome/browser/themes/theme_service.h" |
| 69 #include "chrome/browser/themes/theme_service_factory.h" | 68 #include "chrome/browser/themes/theme_service_factory.h" |
| 70 #include "chrome/browser/translate/translate_infobar_delegate.h" | 69 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 71 #include "chrome/browser/translate/translate_tab_helper.h" | 70 #include "chrome/browser/translate/translate_tab_helper.h" |
| 72 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 71 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 73 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 72 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 74 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 73 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 74 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 75 #include "chrome/browser/ui/browser_window.h" | 75 #include "chrome/browser/ui/browser_window.h" |
| 76 #include "chrome/browser/ui/download/download_tab_helper.h" | 76 #include "chrome/browser/ui/download/download_tab_helper.h" |
| 77 #include "chrome/browser/ui/find_bar/find_bar.h" | 77 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 78 #include "chrome/browser/ui/login/login_prompt.h" | 78 #include "chrome/browser/ui/login/login_prompt.h" |
| 79 #include "chrome/browser/ui/omnibox/location_bar.h" | 79 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 80 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 80 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
| 81 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 81 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 82 #include "chrome/browser/ui/webui/shown_sections_handler.h" | 82 #include "chrome/browser/ui/webui/shown_sections_handler.h" |
| 83 #include "chrome/common/automation_messages.h" | 83 #include "chrome/common/automation_messages.h" |
| 84 #include "chrome/common/chrome_constants.h" | 84 #include "chrome/common/chrome_constants.h" |
| (...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 else | 2002 else |
| 2003 browser->window()->GetDownloadShelf()->Close(); | 2003 browser->window()->GetDownloadShelf()->Close(); |
| 2004 } | 2004 } |
| 2005 } | 2005 } |
| 2006 } | 2006 } |
| 2007 | 2007 |
| 2008 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { | 2008 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { |
| 2009 *count = -1; // -1 is the error code | 2009 *count = -1; // -1 is the error code |
| 2010 if (tab_tracker_->ContainsHandle(handle)) { | 2010 if (tab_tracker_->ContainsHandle(handle)) { |
| 2011 NavigationController* nav_controller = tab_tracker_->GetResource(handle); | 2011 NavigationController* nav_controller = tab_tracker_->GetResource(handle); |
| 2012 TabContents* tab_contents = nav_controller->tab_contents(); | 2012 TabContentsWrapper* tab_contents = |
| 2013 TabContentsWrapper::GetCurrentWrapperForContents( |
| 2014 nav_controller->tab_contents()); |
| 2013 if (tab_contents) { | 2015 if (tab_contents) { |
| 2014 BlockedContentContainer* container = | 2016 BlockedContentTabHelper* blocked_content = |
| 2015 tab_contents->blocked_content_container(); | 2017 tab_contents->blocked_content_tab_helper(); |
| 2016 if (container) { | 2018 *count = static_cast<int>(blocked_content->GetBlockedContentsCount()); |
| 2017 *count = static_cast<int>(container->GetBlockedContentsCount()); | |
| 2018 } else { | |
| 2019 // If we don't have a container, we don't have any blocked popups to | |
| 2020 // contain! | |
| 2021 *count = 0; | |
| 2022 } | |
| 2023 } | 2019 } |
| 2024 } | 2020 } |
| 2025 } | 2021 } |
| 2026 | 2022 |
| 2027 void TestingAutomationProvider::SendJSONRequest(int handle, | 2023 void TestingAutomationProvider::SendJSONRequest(int handle, |
| 2028 const std::string& json_request, | 2024 const std::string& json_request, |
| 2029 IPC::Message* reply_message) { | 2025 IPC::Message* reply_message) { |
| 2030 scoped_ptr<Value> values; | 2026 scoped_ptr<Value> values; |
| 2031 base::JSONReader reader; | 2027 base::JSONReader reader; |
| 2032 std::string error; | 2028 std::string error; |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3537 | 3533 |
| 3538 remover->AddObserver( | 3534 remover->AddObserver( |
| 3539 new AutomationProviderBrowsingDataObserver(this, reply_message)); | 3535 new AutomationProviderBrowsingDataObserver(this, reply_message)); |
| 3540 remover->Remove(remove_mask); | 3536 remover->Remove(remove_mask); |
| 3541 // BrowsingDataRemover deletes itself using DeleteTask. | 3537 // BrowsingDataRemover deletes itself using DeleteTask. |
| 3542 // The observer also deletes itself after sending the reply. | 3538 // The observer also deletes itself after sending the reply. |
| 3543 } | 3539 } |
| 3544 | 3540 |
| 3545 namespace { | 3541 namespace { |
| 3546 | 3542 |
| 3547 // Get the TabContents from a dictionary of arguments. | 3543 // Get the TabContentsWrapper from a dictionary of arguments. |
| 3548 TabContents* GetTabContentsFromDict(const Browser* browser, | 3544 TabContentsWrapper* GetTabContentsWrapperFromDict(const Browser* browser, |
| 3549 const DictionaryValue* args, | 3545 const DictionaryValue* args, |
| 3550 std::string* error_message) { | 3546 std::string* error_message) { |
| 3551 int tab_index; | 3547 int tab_index; |
| 3552 if (!args->GetInteger("tab_index", &tab_index)) { | 3548 if (!args->GetInteger("tab_index", &tab_index)) { |
| 3553 *error_message = "Must include tab_index."; | 3549 *error_message = "Must include tab_index."; |
| 3554 return NULL; | 3550 return NULL; |
| 3555 } | |
| 3556 | |
| 3557 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); | |
| 3558 if (!tab_contents) { | |
| 3559 *error_message = StringPrintf("No tab at index %d.", tab_index); | |
| 3560 return NULL; | |
| 3561 } | |
| 3562 return tab_contents; | |
| 3563 } | 3551 } |
| 3564 | 3552 |
| 3565 // Get the TranslateInfoBarDelegate from TabContents. | 3553 TabContentsWrapper* tab_contents = |
| 3566 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( | 3554 browser->GetTabContentsWrapperAt(tab_index); |
| 3567 TabContents* tab_contents) { | 3555 if (!tab_contents) { |
| 3568 for (size_t i = 0; i < tab_contents->infobar_count(); i++) { | 3556 *error_message = StringPrintf("No tab at index %d.", tab_index); |
| 3569 InfoBarDelegate* infobar = tab_contents->GetInfoBarDelegateAt(i); | |
| 3570 if (infobar->AsTranslateInfoBarDelegate()) | |
| 3571 return infobar->AsTranslateInfoBarDelegate(); | |
| 3572 } | |
| 3573 // No translate infobar. | |
| 3574 return NULL; | 3557 return NULL; |
| 3575 } | 3558 } |
| 3559 return tab_contents; |
| 3560 } |
| 3561 |
| 3562 // Get the TranslateInfoBarDelegate from TabContents. |
| 3563 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( |
| 3564 TabContents* tab_contents) { |
| 3565 for (size_t i = 0; i < tab_contents->infobar_count(); i++) { |
| 3566 InfoBarDelegate* infobar = tab_contents->GetInfoBarDelegateAt(i); |
| 3567 if (infobar->AsTranslateInfoBarDelegate()) |
| 3568 return infobar->AsTranslateInfoBarDelegate(); |
| 3569 } |
| 3570 // No translate infobar. |
| 3571 return NULL; |
| 3572 } |
| 3573 |
| 3576 } // namespace | 3574 } // namespace |
| 3577 | 3575 |
| 3578 void TestingAutomationProvider::FindInPage( | 3576 void TestingAutomationProvider::FindInPage( |
| 3579 Browser* browser, | 3577 Browser* browser, |
| 3580 DictionaryValue* args, | 3578 DictionaryValue* args, |
| 3581 IPC::Message* reply_message) { | 3579 IPC::Message* reply_message) { |
| 3582 std::string error_message; | 3580 std::string error_message; |
| 3583 TabContents* tab_contents = GetTabContentsFromDict(browser, args, | 3581 TabContentsWrapper* tab_contents = |
| 3584 &error_message); | 3582 GetTabContentsWrapperFromDict(browser, args, &error_message); |
| 3585 if (!tab_contents) { | 3583 if (!tab_contents) { |
| 3586 AutomationJSONReply(this, reply_message).SendError(error_message); | 3584 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3587 return; | 3585 return; |
| 3588 } | 3586 } |
| 3589 string16 search_string; | 3587 string16 search_string; |
| 3590 bool forward; | 3588 bool forward; |
| 3591 bool match_case; | 3589 bool match_case; |
| 3592 bool find_next; | 3590 bool find_next; |
| 3593 if (!args->GetString("search_string", &search_string)) { | 3591 if (!args->GetString("search_string", &search_string)) { |
| 3594 AutomationJSONReply(this, reply_message). | 3592 AutomationJSONReply(this, reply_message). |
| 3595 SendError("Must include search_string string."); | 3593 SendError("Must include search_string string."); |
| 3596 return; | 3594 return; |
| 3597 } | 3595 } |
| 3598 if (!args->GetBoolean("forward", &forward)) { | 3596 if (!args->GetBoolean("forward", &forward)) { |
| 3599 AutomationJSONReply(this, reply_message). | 3597 AutomationJSONReply(this, reply_message). |
| 3600 SendError("Must include forward boolean."); | 3598 SendError("Must include forward boolean."); |
| 3601 return; | 3599 return; |
| 3602 } | 3600 } |
| 3603 if (!args->GetBoolean("match_case", &match_case)) { | 3601 if (!args->GetBoolean("match_case", &match_case)) { |
| 3604 AutomationJSONReply(this, reply_message). | 3602 AutomationJSONReply(this, reply_message). |
| 3605 SendError("Must include match_case boolean."); | 3603 SendError("Must include match_case boolean."); |
| 3606 return; | 3604 return; |
| 3607 } | 3605 } |
| 3608 if (!args->GetBoolean("find_next", &find_next)) { | 3606 if (!args->GetBoolean("find_next", &find_next)) { |
| 3609 AutomationJSONReply(this, reply_message). | 3607 AutomationJSONReply(this, reply_message). |
| 3610 SendError("Must include find_next boolean."); | 3608 SendError("Must include find_next boolean."); |
| 3611 return; | 3609 return; |
| 3612 } | 3610 } |
| 3613 SendFindRequest(tab_contents, | 3611 SendFindRequest(tab_contents->tab_contents(), |
| 3614 true, | 3612 true, |
| 3615 search_string, | 3613 search_string, |
| 3616 forward, | 3614 forward, |
| 3617 match_case, | 3615 match_case, |
| 3618 find_next, | 3616 find_next, |
| 3619 reply_message); | 3617 reply_message); |
| 3620 } | 3618 } |
| 3621 | 3619 |
| 3622 // See GetTranslateInfo() in chrome/test/pyautolib/pyauto.py for sample json | 3620 // See GetTranslateInfo() in chrome/test/pyautolib/pyauto.py for sample json |
| 3623 // input and output. | 3621 // input and output. |
| 3624 void TestingAutomationProvider::GetTranslateInfo( | 3622 void TestingAutomationProvider::GetTranslateInfo( |
| 3625 Browser* browser, | 3623 Browser* browser, |
| 3626 DictionaryValue* args, | 3624 DictionaryValue* args, |
| 3627 IPC::Message* reply_message) { | 3625 IPC::Message* reply_message) { |
| 3628 std::string error_message; | 3626 std::string error_message; |
| 3629 TabContents* tab_contents = GetTabContentsFromDict(browser, args, | 3627 TabContentsWrapper* tab_contents_wrapper = |
| 3630 &error_message); | 3628 GetTabContentsWrapperFromDict(browser, args, &error_message); |
| 3631 if (!tab_contents) { | 3629 if (!tab_contents_wrapper) { |
| 3632 AutomationJSONReply(this, reply_message).SendError(error_message); | 3630 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3633 return; | 3631 return; |
| 3634 } | 3632 } |
| 3635 | 3633 |
| 3634 TabContents* tab_contents = tab_contents_wrapper->tab_contents(); |
| 3636 // Get the translate bar if there is one and pass it to the observer. | 3635 // Get the translate bar if there is one and pass it to the observer. |
| 3637 // The observer will check for null and populate the information accordingly. | 3636 // The observer will check for null and populate the information accordingly. |
| 3638 TranslateInfoBarDelegate* translate_bar = | 3637 TranslateInfoBarDelegate* translate_bar = |
| 3639 GetTranslateInfoBarDelegate(tab_contents); | 3638 GetTranslateInfoBarDelegate(tab_contents); |
| 3640 | 3639 |
| 3641 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver( | 3640 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver( |
| 3642 this, reply_message, tab_contents, translate_bar); | 3641 this, reply_message, tab_contents, translate_bar); |
| 3643 // If the language for the page hasn't been loaded yet, then just make | 3642 // If the language for the page hasn't been loaded yet, then just make |
| 3644 // the observer, otherwise call observe directly. | 3643 // the observer, otherwise call observe directly. |
| 3645 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( | 3644 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( |
| 3646 tab_contents)->translate_tab_helper(); | 3645 tab_contents)->translate_tab_helper(); |
| 3647 std::string language = helper->language_state().original_language(); | 3646 std::string language = helper->language_state().original_language(); |
| 3648 if (!language.empty()) { | 3647 if (!language.empty()) { |
| 3649 observer->Observe(NotificationType::TAB_LANGUAGE_DETERMINED, | 3648 observer->Observe(NotificationType::TAB_LANGUAGE_DETERMINED, |
| 3650 Source<TabContents>(tab_contents), | 3649 Source<TabContents>(tab_contents), |
| 3651 Details<std::string>(&language)); | 3650 Details<std::string>(&language)); |
| 3652 } | 3651 } |
| 3653 } | 3652 } |
| 3654 | 3653 |
| 3655 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample | 3654 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample |
| 3656 // json input. | 3655 // json input. |
| 3657 // Sample json output: {} | 3656 // Sample json output: {} |
| 3658 void TestingAutomationProvider::SelectTranslateOption( | 3657 void TestingAutomationProvider::SelectTranslateOption( |
| 3659 Browser* browser, | 3658 Browser* browser, |
| 3660 DictionaryValue* args, | 3659 DictionaryValue* args, |
| 3661 IPC::Message* reply_message) { | 3660 IPC::Message* reply_message) { |
| 3662 std::string option; | 3661 std::string option; |
| 3663 std::string error_message; | 3662 std::string error_message; |
| 3664 TabContents* tab_contents = GetTabContentsFromDict(browser, args, | 3663 TabContentsWrapper* tab_contents_wrapper = |
| 3665 &error_message); | 3664 GetTabContentsWrapperFromDict(browser, args, &error_message); |
| 3666 if (!tab_contents) { | 3665 if (!tab_contents_wrapper) { |
| 3667 AutomationJSONReply(this, reply_message).SendError(error_message); | 3666 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3668 return; | 3667 return; |
| 3669 } | 3668 } |
| 3670 | 3669 |
| 3670 TabContents* tab_contents = tab_contents_wrapper->tab_contents(); |
| 3671 TranslateInfoBarDelegate* translate_bar = | 3671 TranslateInfoBarDelegate* translate_bar = |
| 3672 GetTranslateInfoBarDelegate(tab_contents); | 3672 GetTranslateInfoBarDelegate(tab_contents); |
| 3673 if (!translate_bar) { | 3673 if (!translate_bar) { |
| 3674 AutomationJSONReply(this, reply_message) | 3674 AutomationJSONReply(this, reply_message) |
| 3675 .SendError("There is no translate bar open."); | 3675 .SendError("There is no translate bar open."); |
| 3676 return; | 3676 return; |
| 3677 } | 3677 } |
| 3678 | 3678 |
| 3679 if (!args->GetString("option", &option)) { | 3679 if (!args->GetString("option", &option)) { |
| 3680 AutomationJSONReply(this, reply_message).SendError("Must include option"); | 3680 AutomationJSONReply(this, reply_message).SendError("Must include option"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3774 | 3774 |
| 3775 // Sample json input: { "command": "GetBlockedPopupsInfo", | 3775 // Sample json input: { "command": "GetBlockedPopupsInfo", |
| 3776 // "tab_index": 1 } | 3776 // "tab_index": 1 } |
| 3777 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output. | 3777 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output. |
| 3778 void TestingAutomationProvider::GetBlockedPopupsInfo( | 3778 void TestingAutomationProvider::GetBlockedPopupsInfo( |
| 3779 Browser* browser, | 3779 Browser* browser, |
| 3780 DictionaryValue* args, | 3780 DictionaryValue* args, |
| 3781 IPC::Message* reply_message) { | 3781 IPC::Message* reply_message) { |
| 3782 AutomationJSONReply reply(this, reply_message); | 3782 AutomationJSONReply reply(this, reply_message); |
| 3783 std::string error_message; | 3783 std::string error_message; |
| 3784 TabContents* tab_contents = GetTabContentsFromDict( | 3784 TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict( |
| 3785 browser, args, &error_message); | 3785 browser, args, &error_message); |
| 3786 if (!tab_contents) { | 3786 if (!tab_contents) { |
| 3787 reply.SendError(error_message); | 3787 reply.SendError(error_message); |
| 3788 return; | 3788 return; |
| 3789 } | 3789 } |
| 3790 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3790 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 3791 BlockedContentContainer* popup_container = | 3791 BlockedContentTabHelper* blocked_content = |
| 3792 tab_contents->blocked_content_container(); | 3792 tab_contents->blocked_content_tab_helper(); |
| 3793 ListValue* blocked_popups_list = new ListValue; | 3793 ListValue* blocked_popups_list = new ListValue; |
| 3794 if (popup_container) { | 3794 std::vector<TabContentsWrapper*> blocked_contents; |
| 3795 std::vector<TabContents*> blocked_contents; | 3795 blocked_content->GetBlockedContents(&blocked_contents); |
| 3796 popup_container->GetBlockedContents(&blocked_contents); | 3796 for (std::vector<TabContentsWrapper*>::const_iterator it = |
| 3797 for (std::vector<TabContents*>::const_iterator it = | 3797 blocked_contents.begin(); it != blocked_contents.end(); ++it) { |
| 3798 blocked_contents.begin(); it != blocked_contents.end(); ++it) { | 3798 DictionaryValue* item = new DictionaryValue; |
| 3799 DictionaryValue* item = new DictionaryValue; | 3799 item->SetString("url", (*it)->tab_contents()->GetURL().spec()); |
| 3800 item->SetString("url", (*it)->GetURL().spec()); | 3800 item->SetString("title", (*it)->tab_contents()->GetTitle()); |
| 3801 item->SetString("title", (*it)->GetTitle()); | 3801 blocked_popups_list->Append(item); |
| 3802 blocked_popups_list->Append(item); | |
| 3803 } | |
| 3804 } | 3802 } |
| 3805 return_value->Set("blocked_popups", blocked_popups_list); | 3803 return_value->Set("blocked_popups", blocked_popups_list); |
| 3806 reply.SendSuccess(return_value.get()); | 3804 reply.SendSuccess(return_value.get()); |
| 3807 } | 3805 } |
| 3808 | 3806 |
| 3809 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input. | 3807 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input. |
| 3810 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup( | 3808 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup( |
| 3811 Browser* browser, | 3809 Browser* browser, |
| 3812 DictionaryValue* args, | 3810 DictionaryValue* args, |
| 3813 IPC::Message* reply_message) { | 3811 IPC::Message* reply_message) { |
| 3814 AutomationJSONReply reply(this, reply_message); | 3812 AutomationJSONReply reply(this, reply_message); |
| 3815 std::string error_message; | 3813 std::string error_message; |
| 3816 TabContents* tab_contents = GetTabContentsFromDict( | 3814 TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict( |
| 3817 browser, args, &error_message); | 3815 browser, args, &error_message); |
| 3818 if (!tab_contents) { | 3816 if (!tab_contents) { |
| 3819 reply.SendError(error_message); | 3817 reply.SendError(error_message); |
| 3820 return; | 3818 return; |
| 3821 } | 3819 } |
| 3822 int popup_index; | 3820 int popup_index; |
| 3823 if (!args->GetInteger("popup_index", &popup_index)) { | 3821 if (!args->GetInteger("popup_index", &popup_index)) { |
| 3824 reply.SendError("Need popup_index arg"); | 3822 reply.SendError("Need popup_index arg"); |
| 3825 return; | 3823 return; |
| 3826 } | 3824 } |
| 3827 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3825 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 3828 BlockedContentContainer* content_container = | 3826 BlockedContentTabHelper* blocked_content = |
| 3829 tab_contents->blocked_content_container(); | 3827 tab_contents->blocked_content_tab_helper(); |
| 3830 if (!content_container || | 3828 if (popup_index >= (int)blocked_content->GetBlockedContentsCount()) { |
| 3831 popup_index >= (int)content_container->GetBlockedContentsCount()) { | |
| 3832 reply.SendError(StringPrintf("No popup at index %d", popup_index)); | 3829 reply.SendError(StringPrintf("No popup at index %d", popup_index)); |
| 3833 return; | 3830 return; |
| 3834 } | 3831 } |
| 3835 std::vector<TabContents*> blocked_contents; | 3832 std::vector<TabContentsWrapper*> blocked_contents; |
| 3836 content_container->GetBlockedContents(&blocked_contents); | 3833 blocked_content->GetBlockedContents(&blocked_contents); |
| 3837 content_container->LaunchForContents(blocked_contents[popup_index]); | 3834 blocked_content->LaunchForContents(blocked_contents[popup_index]); |
| 3838 reply.SendSuccess(NULL); | 3835 reply.SendSuccess(NULL); |
| 3839 } | 3836 } |
| 3840 | 3837 |
| 3841 // Sample json input: { "command": "GetThemeInfo" } | 3838 // Sample json input: { "command": "GetThemeInfo" } |
| 3842 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. | 3839 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. |
| 3843 void TestingAutomationProvider::GetThemeInfo( | 3840 void TestingAutomationProvider::GetThemeInfo( |
| 3844 Browser* browser, | 3841 Browser* browser, |
| 3845 DictionaryValue* args, | 3842 DictionaryValue* args, |
| 3846 IPC::Message* reply_message) { | 3843 IPC::Message* reply_message) { |
| 3847 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3844 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5524 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); | 5521 IPC::ParamTraits<std::vector<GURL> >::Write(reply_message_, redirects_gurl); |
| 5525 | 5522 |
| 5526 Send(reply_message_); | 5523 Send(reply_message_); |
| 5527 redirect_query_ = 0; | 5524 redirect_query_ = 0; |
| 5528 reply_message_ = NULL; | 5525 reply_message_ = NULL; |
| 5529 } | 5526 } |
| 5530 | 5527 |
| 5531 void TestingAutomationProvider::OnRemoveProvider() { | 5528 void TestingAutomationProvider::OnRemoveProvider() { |
| 5532 AutomationProviderList::GetInstance()->RemoveProvider(this); | 5529 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 5533 } | 5530 } |
| OLD | NEW |