| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 #include "chrome/browser/ui/browser_window.h" | 106 #include "chrome/browser/ui/browser_window.h" |
| 107 #include "chrome/browser/ui/extensions/application_launch.h" | 107 #include "chrome/browser/ui/extensions/application_launch.h" |
| 108 #include "chrome/browser/ui/find_bar/find_bar.h" | 108 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 109 #include "chrome/browser/ui/fullscreen_controller.h" | 109 #include "chrome/browser/ui/fullscreen_controller.h" |
| 110 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" | 110 #include "chrome/browser/ui/fullscreen_exit_bubble_type.h" |
| 111 #include "chrome/browser/ui/login/login_prompt.h" | 111 #include "chrome/browser/ui/login/login_prompt.h" |
| 112 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 112 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
| 113 #include "chrome/browser/ui/omnibox/location_bar.h" | 113 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 114 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 114 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 115 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 115 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" |
| 116 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 116 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 117 #include "chrome/browser/view_type_utils.h" | 117 #include "chrome/browser/view_type_utils.h" |
| 118 #include "chrome/common/automation_constants.h" | 118 #include "chrome/common/automation_constants.h" |
| 119 #include "chrome/common/automation_events.h" | 119 #include "chrome/common/automation_events.h" |
| 120 #include "chrome/common/automation_id.h" | 120 #include "chrome/common/automation_id.h" |
| 121 #include "chrome/common/automation_messages.h" | 121 #include "chrome/common/automation_messages.h" |
| 122 #include "chrome/common/chrome_constants.h" | 122 #include "chrome/common/chrome_constants.h" |
| 123 #include "chrome/common/chrome_notification_types.h" | 123 #include "chrome/common/chrome_notification_types.h" |
| 124 #include "chrome/common/chrome_paths.h" | 124 #include "chrome/common/chrome_paths.h" |
| 125 #include "chrome/common/chrome_switches.h" | 125 #include "chrome/common/chrome_switches.h" |
| 126 #include "chrome/common/extensions/extension.h" | 126 #include "chrome/common/extensions/extension.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 void TestingAutomationProvider::AppendTab(int handle, | 491 void TestingAutomationProvider::AppendTab(int handle, |
| 492 const GURL& url, | 492 const GURL& url, |
| 493 IPC::Message* reply_message) { | 493 IPC::Message* reply_message) { |
| 494 int append_tab_response = -1; // -1 is the error code | 494 int append_tab_response = -1; // -1 is the error code |
| 495 TabAppendedNotificationObserver* observer = NULL; | 495 TabAppendedNotificationObserver* observer = NULL; |
| 496 | 496 |
| 497 if (browser_tracker_->ContainsHandle(handle)) { | 497 if (browser_tracker_->ContainsHandle(handle)) { |
| 498 Browser* browser = browser_tracker_->GetResource(handle); | 498 Browser* browser = browser_tracker_->GetResource(handle); |
| 499 observer = new TabAppendedNotificationObserver(browser, this, | 499 observer = new TabAppendedNotificationObserver(browser, this, |
| 500 reply_message); | 500 reply_message); |
| 501 TabContentsWrapper* contents = | 501 TabContents* contents = |
| 502 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); | 502 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); |
| 503 if (contents) { | 503 if (contents) { |
| 504 append_tab_response = GetIndexForNavigationController( | 504 append_tab_response = GetIndexForNavigationController( |
| 505 &contents->web_contents()->GetController(), browser); | 505 &contents->web_contents()->GetController(), browser); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 if (append_tab_response < 0) { | 509 if (append_tab_response < 0) { |
| 510 // Appending tab failed. Clean up and send failure response. | 510 // Appending tab failed. Clean up and send failure response. |
| 511 | 511 |
| (...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 if (args->GetInteger("height", &height)) | 2086 if (args->GetInteger("height", &height)) |
| 2087 rect.set_height(height); | 2087 rect.set_height(height); |
| 2088 browser->window()->SetBounds(rect); | 2088 browser->window()->SetBounds(rect); |
| 2089 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 2089 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { | 2092 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { |
| 2093 // Each infobar may have different properties depending on the type. | 2093 // Each infobar may have different properties depending on the type. |
| 2094 ListValue* infobars = new ListValue; | 2094 ListValue* infobars = new ListValue; |
| 2095 InfoBarTabHelper* infobar_helper = | 2095 InfoBarTabHelper* infobar_helper = |
| 2096 TabContentsWrapper::GetCurrentWrapperForContents(wc)-> | 2096 TabContents::GetOwningTabContentsForWebContents(wc)-> |
| 2097 infobar_tab_helper(); | 2097 infobar_tab_helper(); |
| 2098 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 2098 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
| 2099 DictionaryValue* infobar_item = new DictionaryValue; | 2099 DictionaryValue* infobar_item = new DictionaryValue; |
| 2100 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); | 2100 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); |
| 2101 switch (infobar->GetInfoBarAutomationType()) { | 2101 switch (infobar->GetInfoBarAutomationType()) { |
| 2102 case InfoBarDelegate::CONFIRM_INFOBAR: | 2102 case InfoBarDelegate::CONFIRM_INFOBAR: |
| 2103 infobar_item->SetString("type", "confirm_infobar"); | 2103 infobar_item->SetString("type", "confirm_infobar"); |
| 2104 break; | 2104 break; |
| 2105 case InfoBarDelegate::ONE_CLICK_LOGIN_INFOBAR: | 2105 case InfoBarDelegate::ONE_CLICK_LOGIN_INFOBAR: |
| 2106 infobar_item->SetString("type", "oneclicklogin_infobar"); | 2106 infobar_item->SetString("type", "oneclicklogin_infobar"); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 int tab_index; | 2171 int tab_index; |
| 2172 int infobar_index_int; | 2172 int infobar_index_int; |
| 2173 std::string action; | 2173 std::string action; |
| 2174 if (!args->GetInteger("tab_index", &tab_index) || | 2174 if (!args->GetInteger("tab_index", &tab_index) || |
| 2175 !args->GetInteger("infobar_index", &infobar_index_int) || | 2175 !args->GetInteger("infobar_index", &infobar_index_int) || |
| 2176 !args->GetString("action", &action)) { | 2176 !args->GetString("action", &action)) { |
| 2177 reply.SendError("Invalid or missing args"); | 2177 reply.SendError("Invalid or missing args"); |
| 2178 return; | 2178 return; |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 TabContentsWrapper* tab_contents = | 2181 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); |
| 2182 browser->GetTabContentsWrapperAt(tab_index); | |
| 2183 if (!tab_contents) { | 2182 if (!tab_contents) { |
| 2184 reply.SendError(StringPrintf("No such tab at index %d", tab_index)); | 2183 reply.SendError(StringPrintf("No such tab at index %d", tab_index)); |
| 2185 return; | 2184 return; |
| 2186 } | 2185 } |
| 2187 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 2186 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
| 2188 | 2187 |
| 2189 InfoBarDelegate* infobar = NULL; | 2188 InfoBarDelegate* infobar = NULL; |
| 2190 size_t infobar_index = static_cast<size_t>(infobar_index_int); | 2189 size_t infobar_index = static_cast<size_t>(infobar_index_int); |
| 2191 if (infobar_index >= infobar_helper->infobar_count()) { | 2190 if (infobar_index >= infobar_helper->infobar_count()) { |
| 2192 reply.SendError(StringPrintf("No such infobar at index %" PRIuS, | 2191 reply.SendError(StringPrintf("No such infobar at index %" PRIuS, |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3141 model->OnUpOrDownKeyPressed(count); | 3140 model->OnUpOrDownKeyPressed(count); |
| 3142 reply.SendSuccess(NULL); | 3141 reply.SendSuccess(NULL); |
| 3143 } | 3142 } |
| 3144 | 3143 |
| 3145 // Sample json input: { "command": "OmniboxAcceptInput" } | 3144 // Sample json input: { "command": "OmniboxAcceptInput" } |
| 3146 void TestingAutomationProvider::OmniboxAcceptInput( | 3145 void TestingAutomationProvider::OmniboxAcceptInput( |
| 3147 Browser* browser, | 3146 Browser* browser, |
| 3148 DictionaryValue* args, | 3147 DictionaryValue* args, |
| 3149 IPC::Message* reply_message) { | 3148 IPC::Message* reply_message) { |
| 3150 NavigationController& controller = | 3149 NavigationController& controller = |
| 3151 browser->GetSelectedWebContents()->GetController(); | 3150 browser->GetActiveWebContents()->GetController(); |
| 3152 LocationBar* loc_bar = browser->window()->GetLocationBar(); | 3151 LocationBar* loc_bar = browser->window()->GetLocationBar(); |
| 3153 if (!loc_bar) { | 3152 if (!loc_bar) { |
| 3154 AutomationJSONReply(this, reply_message).SendError( | 3153 AutomationJSONReply(this, reply_message).SendError( |
| 3155 "The specified browser does not have a location bar."); | 3154 "The specified browser does not have a location bar."); |
| 3156 return; | 3155 return; |
| 3157 } | 3156 } |
| 3158 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); | 3157 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); |
| 3159 loc_bar->AcceptInput(); | 3158 loc_bar->AcceptInput(); |
| 3160 } | 3159 } |
| 3161 | 3160 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3619 | 3618 |
| 3620 remover->AddObserver( | 3619 remover->AddObserver( |
| 3621 new AutomationProviderBrowsingDataObserver(this, reply_message)); | 3620 new AutomationProviderBrowsingDataObserver(this, reply_message)); |
| 3622 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); | 3621 remover->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB); |
| 3623 // BrowsingDataRemover deletes itself using DeleteTask. | 3622 // BrowsingDataRemover deletes itself using DeleteTask. |
| 3624 // The observer also deletes itself after sending the reply. | 3623 // The observer also deletes itself after sending the reply. |
| 3625 } | 3624 } |
| 3626 | 3625 |
| 3627 namespace { | 3626 namespace { |
| 3628 | 3627 |
| 3629 // Get the TabContentsWrapper from a dictionary of arguments. | 3628 // Get the TabContents from a dictionary of arguments. |
| 3630 TabContentsWrapper* GetTabContentsWrapperFromDict(const Browser* browser, | 3629 TabContents* GetTabContentsFromDict(const Browser* browser, |
| 3631 const DictionaryValue* args, | 3630 const DictionaryValue* args, |
| 3632 std::string* error_message) { | 3631 std::string* error_message) { |
| 3633 int tab_index; | 3632 int tab_index; |
| 3634 if (!args->GetInteger("tab_index", &tab_index)) { | 3633 if (!args->GetInteger("tab_index", &tab_index)) { |
| 3635 *error_message = "Must include tab_index."; | 3634 *error_message = "Must include tab_index."; |
| 3636 return NULL; | 3635 return NULL; |
| 3637 } | 3636 } |
| 3638 | 3637 |
| 3639 TabContentsWrapper* tab_contents = | 3638 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); |
| 3640 browser->GetTabContentsWrapperAt(tab_index); | |
| 3641 if (!tab_contents) { | 3639 if (!tab_contents) { |
| 3642 *error_message = StringPrintf("No tab at index %d.", tab_index); | 3640 *error_message = StringPrintf("No tab at index %d.", tab_index); |
| 3643 return NULL; | 3641 return NULL; |
| 3644 } | 3642 } |
| 3645 return tab_contents; | 3643 return tab_contents; |
| 3646 } | 3644 } |
| 3647 | 3645 |
| 3648 // Get the TranslateInfoBarDelegate from WebContents. | 3646 // Get the TranslateInfoBarDelegate from WebContents. |
| 3649 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( | 3647 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( |
| 3650 WebContents* web_contents) { | 3648 WebContents* web_contents) { |
| 3651 InfoBarTabHelper* infobar_helper = | 3649 InfoBarTabHelper* infobar_helper = |
| 3652 TabContentsWrapper::GetCurrentWrapperForContents(web_contents)-> | 3650 TabContents::GetOwningTabContentsForWebContents(web_contents)-> |
| 3653 infobar_tab_helper(); | 3651 infobar_tab_helper(); |
| 3654 for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { | 3652 for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { |
| 3655 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); | 3653 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); |
| 3656 if (infobar->AsTranslateInfoBarDelegate()) | 3654 if (infobar->AsTranslateInfoBarDelegate()) |
| 3657 return infobar->AsTranslateInfoBarDelegate(); | 3655 return infobar->AsTranslateInfoBarDelegate(); |
| 3658 } | 3656 } |
| 3659 // No translate infobar. | 3657 // No translate infobar. |
| 3660 return NULL; | 3658 return NULL; |
| 3661 } | 3659 } |
| 3662 | 3660 |
| 3663 } // namespace | 3661 } // namespace |
| 3664 | 3662 |
| 3665 void TestingAutomationProvider::FindInPage( | 3663 void TestingAutomationProvider::FindInPage( |
| 3666 Browser* browser, | 3664 Browser* browser, |
| 3667 DictionaryValue* args, | 3665 DictionaryValue* args, |
| 3668 IPC::Message* reply_message) { | 3666 IPC::Message* reply_message) { |
| 3669 std::string error_message; | 3667 std::string error_message; |
| 3670 TabContentsWrapper* tab_contents = | 3668 TabContents* tab_contents = |
| 3671 GetTabContentsWrapperFromDict(browser, args, &error_message); | 3669 GetTabContentsFromDict(browser, args, &error_message); |
| 3672 if (!tab_contents) { | 3670 if (!tab_contents) { |
| 3673 AutomationJSONReply(this, reply_message).SendError(error_message); | 3671 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3674 return; | 3672 return; |
| 3675 } | 3673 } |
| 3676 string16 search_string; | 3674 string16 search_string; |
| 3677 bool forward; | 3675 bool forward; |
| 3678 bool match_case; | 3676 bool match_case; |
| 3679 bool find_next; | 3677 bool find_next; |
| 3680 if (!args->GetString("search_string", &search_string)) { | 3678 if (!args->GetString("search_string", &search_string)) { |
| 3681 AutomationJSONReply(this, reply_message). | 3679 AutomationJSONReply(this, reply_message). |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3706 reply_message); | 3704 reply_message); |
| 3707 } | 3705 } |
| 3708 | 3706 |
| 3709 // See GetTranslateInfo() in chrome/test/pyautolib/pyauto.py for sample json | 3707 // See GetTranslateInfo() in chrome/test/pyautolib/pyauto.py for sample json |
| 3710 // input and output. | 3708 // input and output. |
| 3711 void TestingAutomationProvider::GetTranslateInfo( | 3709 void TestingAutomationProvider::GetTranslateInfo( |
| 3712 Browser* browser, | 3710 Browser* browser, |
| 3713 DictionaryValue* args, | 3711 DictionaryValue* args, |
| 3714 IPC::Message* reply_message) { | 3712 IPC::Message* reply_message) { |
| 3715 std::string error_message; | 3713 std::string error_message; |
| 3716 TabContentsWrapper* tab_contents_wrapper = | 3714 TabContents* tab_contents = |
| 3717 GetTabContentsWrapperFromDict(browser, args, &error_message); | 3715 GetTabContentsFromDict(browser, args, &error_message); |
| 3718 if (!tab_contents_wrapper) { | 3716 if (!tab_contents) { |
| 3719 AutomationJSONReply(this, reply_message).SendError(error_message); | 3717 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3720 return; | 3718 return; |
| 3721 } | 3719 } |
| 3722 | 3720 |
| 3723 WebContents* web_contents = tab_contents_wrapper->web_contents(); | 3721 WebContents* web_contents = tab_contents->web_contents(); |
| 3724 // Get the translate bar if there is one and pass it to the observer. | 3722 // Get the translate bar if there is one and pass it to the observer. |
| 3725 // The observer will check for null and populate the information accordingly. | 3723 // The observer will check for null and populate the information accordingly. |
| 3726 TranslateInfoBarDelegate* translate_bar = | 3724 TranslateInfoBarDelegate* translate_bar = |
| 3727 GetTranslateInfoBarDelegate(web_contents); | 3725 GetTranslateInfoBarDelegate(web_contents); |
| 3728 | 3726 |
| 3729 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver( | 3727 TabLanguageDeterminedObserver* observer = new TabLanguageDeterminedObserver( |
| 3730 this, reply_message, web_contents, translate_bar); | 3728 this, reply_message, web_contents, translate_bar); |
| 3731 // If the language for the page hasn't been loaded yet, then just make | 3729 // If the language for the page hasn't been loaded yet, then just make |
| 3732 // the observer, otherwise call observe directly. | 3730 // the observer, otherwise call observe directly. |
| 3733 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( | 3731 TranslateTabHelper* helper = TabContents::GetOwningTabContentsForWebContents( |
| 3734 web_contents)->translate_tab_helper(); | 3732 web_contents)->translate_tab_helper(); |
| 3735 std::string language = helper->language_state().original_language(); | 3733 std::string language = helper->language_state().original_language(); |
| 3736 if (!language.empty()) { | 3734 if (!language.empty()) { |
| 3737 observer->Observe(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 3735 observer->Observe(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 3738 content::Source<WebContents>(web_contents), | 3736 content::Source<WebContents>(web_contents), |
| 3739 content::Details<std::string>(&language)); | 3737 content::Details<std::string>(&language)); |
| 3740 } | 3738 } |
| 3741 } | 3739 } |
| 3742 | 3740 |
| 3743 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample | 3741 // See SelectTranslateOption() in chrome/test/pyautolib/pyauto.py for sample |
| 3744 // json input. | 3742 // json input. |
| 3745 // Sample json output: {} | 3743 // Sample json output: {} |
| 3746 void TestingAutomationProvider::SelectTranslateOption( | 3744 void TestingAutomationProvider::SelectTranslateOption( |
| 3747 Browser* browser, | 3745 Browser* browser, |
| 3748 DictionaryValue* args, | 3746 DictionaryValue* args, |
| 3749 IPC::Message* reply_message) { | 3747 IPC::Message* reply_message) { |
| 3750 std::string option; | 3748 std::string option; |
| 3751 std::string error_message; | 3749 std::string error_message; |
| 3752 TabContentsWrapper* tab_contents_wrapper = | 3750 TabContents* tab_contents = |
| 3753 GetTabContentsWrapperFromDict(browser, args, &error_message); | 3751 GetTabContentsFromDict(browser, args, &error_message); |
| 3754 if (!tab_contents_wrapper) { | 3752 if (!tab_contents) { |
| 3755 AutomationJSONReply(this, reply_message).SendError(error_message); | 3753 AutomationJSONReply(this, reply_message).SendError(error_message); |
| 3756 return; | 3754 return; |
| 3757 } | 3755 } |
| 3758 | 3756 |
| 3759 WebContents* web_contents = tab_contents_wrapper->web_contents(); | 3757 WebContents* web_contents = tab_contents->web_contents(); |
| 3760 TranslateInfoBarDelegate* translate_bar = | 3758 TranslateInfoBarDelegate* translate_bar = |
| 3761 GetTranslateInfoBarDelegate(web_contents); | 3759 GetTranslateInfoBarDelegate(web_contents); |
| 3762 if (!translate_bar) { | 3760 if (!translate_bar) { |
| 3763 AutomationJSONReply(this, reply_message) | 3761 AutomationJSONReply(this, reply_message) |
| 3764 .SendError("There is no translate bar open."); | 3762 .SendError("There is no translate bar open."); |
| 3765 return; | 3763 return; |
| 3766 } | 3764 } |
| 3767 | 3765 |
| 3768 if (!args->GetString("option", &option)) { | 3766 if (!args->GetString("option", &option)) { |
| 3769 AutomationJSONReply(this, reply_message).SendError("Must include option"); | 3767 AutomationJSONReply(this, reply_message).SendError("Must include option"); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3847 if (!translate_bar->ShouldShowNeverTranslateButton()) { | 3845 if (!translate_bar->ShouldShowNeverTranslateButton()) { |
| 3848 reply.SendError("Always translate button not showing."); | 3846 reply.SendError("Always translate button not showing."); |
| 3849 return; | 3847 return; |
| 3850 } | 3848 } |
| 3851 translate_bar->NeverTranslatePageLanguage(); | 3849 translate_bar->NeverTranslatePageLanguage(); |
| 3852 reply.SendSuccess(NULL); | 3850 reply.SendSuccess(NULL); |
| 3853 } else if (option == "decline_translation") { | 3851 } else if (option == "decline_translation") { |
| 3854 // This is the function called when an infobar is dismissed or when the | 3852 // This is the function called when an infobar is dismissed or when the |
| 3855 // user clicks the 'Nope' translate button. | 3853 // user clicks the 'Nope' translate button. |
| 3856 translate_bar->TranslationDeclined(); | 3854 translate_bar->TranslationDeclined(); |
| 3857 tab_contents_wrapper->infobar_tab_helper()->RemoveInfoBar(translate_bar); | 3855 tab_contents->infobar_tab_helper()->RemoveInfoBar(translate_bar); |
| 3858 reply.SendSuccess(NULL); | 3856 reply.SendSuccess(NULL); |
| 3859 } else { | 3857 } else { |
| 3860 reply.SendError("Invalid string found for option."); | 3858 reply.SendError("Invalid string found for option."); |
| 3861 } | 3859 } |
| 3862 } | 3860 } |
| 3863 | 3861 |
| 3864 // Sample json input: { "command": "GetBlockedPopupsInfo", | 3862 // Sample json input: { "command": "GetBlockedPopupsInfo", |
| 3865 // "tab_index": 1 } | 3863 // "tab_index": 1 } |
| 3866 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output. | 3864 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output. |
| 3867 void TestingAutomationProvider::GetBlockedPopupsInfo( | 3865 void TestingAutomationProvider::GetBlockedPopupsInfo( |
| 3868 Browser* browser, | 3866 Browser* browser, |
| 3869 DictionaryValue* args, | 3867 DictionaryValue* args, |
| 3870 IPC::Message* reply_message) { | 3868 IPC::Message* reply_message) { |
| 3871 AutomationJSONReply reply(this, reply_message); | 3869 AutomationJSONReply reply(this, reply_message); |
| 3872 std::string error_message; | 3870 std::string error_message; |
| 3873 TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict( | 3871 TabContents* tab_contents = GetTabContentsFromDict( |
| 3874 browser, args, &error_message); | 3872 browser, args, &error_message); |
| 3875 if (!tab_contents) { | 3873 if (!tab_contents) { |
| 3876 reply.SendError(error_message); | 3874 reply.SendError(error_message); |
| 3877 return; | 3875 return; |
| 3878 } | 3876 } |
| 3879 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3877 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 3880 BlockedContentTabHelper* blocked_content = | 3878 BlockedContentTabHelper* blocked_content = |
| 3881 tab_contents->blocked_content_tab_helper(); | 3879 tab_contents->blocked_content_tab_helper(); |
| 3882 ListValue* blocked_popups_list = new ListValue; | 3880 ListValue* blocked_popups_list = new ListValue; |
| 3883 std::vector<TabContentsWrapper*> blocked_contents; | 3881 std::vector<TabContents*> blocked_contents; |
| 3884 blocked_content->GetBlockedContents(&blocked_contents); | 3882 blocked_content->GetBlockedContents(&blocked_contents); |
| 3885 for (std::vector<TabContentsWrapper*>::const_iterator it = | 3883 for (std::vector<TabContents*>::const_iterator it = |
| 3886 blocked_contents.begin(); it != blocked_contents.end(); ++it) { | 3884 blocked_contents.begin(); it != blocked_contents.end(); ++it) { |
| 3887 DictionaryValue* item = new DictionaryValue; | 3885 DictionaryValue* item = new DictionaryValue; |
| 3888 item->SetString("url", (*it)->web_contents()->GetURL().spec()); | 3886 item->SetString("url", (*it)->web_contents()->GetURL().spec()); |
| 3889 item->SetString("title", (*it)->web_contents()->GetTitle()); | 3887 item->SetString("title", (*it)->web_contents()->GetTitle()); |
| 3890 blocked_popups_list->Append(item); | 3888 blocked_popups_list->Append(item); |
| 3891 } | 3889 } |
| 3892 return_value->Set("blocked_popups", blocked_popups_list); | 3890 return_value->Set("blocked_popups", blocked_popups_list); |
| 3893 reply.SendSuccess(return_value.get()); | 3891 reply.SendSuccess(return_value.get()); |
| 3894 } | 3892 } |
| 3895 | 3893 |
| 3896 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input. | 3894 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input. |
| 3897 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup( | 3895 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup( |
| 3898 Browser* browser, | 3896 Browser* browser, |
| 3899 DictionaryValue* args, | 3897 DictionaryValue* args, |
| 3900 IPC::Message* reply_message) { | 3898 IPC::Message* reply_message) { |
| 3901 AutomationJSONReply reply(this, reply_message); | 3899 AutomationJSONReply reply(this, reply_message); |
| 3902 std::string error_message; | 3900 std::string error_message; |
| 3903 TabContentsWrapper* tab_contents = GetTabContentsWrapperFromDict( | 3901 TabContents* tab_contents = GetTabContentsFromDict( |
| 3904 browser, args, &error_message); | 3902 browser, args, &error_message); |
| 3905 if (!tab_contents) { | 3903 if (!tab_contents) { |
| 3906 reply.SendError(error_message); | 3904 reply.SendError(error_message); |
| 3907 return; | 3905 return; |
| 3908 } | 3906 } |
| 3909 int popup_index; | 3907 int popup_index; |
| 3910 if (!args->GetInteger("popup_index", &popup_index)) { | 3908 if (!args->GetInteger("popup_index", &popup_index)) { |
| 3911 reply.SendError("Need popup_index arg"); | 3909 reply.SendError("Need popup_index arg"); |
| 3912 return; | 3910 return; |
| 3913 } | 3911 } |
| 3914 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 3912 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 3915 BlockedContentTabHelper* blocked_content = | 3913 BlockedContentTabHelper* blocked_content = |
| 3916 tab_contents->blocked_content_tab_helper(); | 3914 tab_contents->blocked_content_tab_helper(); |
| 3917 if (popup_index >= (int)blocked_content->GetBlockedContentsCount()) { | 3915 if (popup_index >= (int)blocked_content->GetBlockedContentsCount()) { |
| 3918 reply.SendError(StringPrintf("No popup at index %d", popup_index)); | 3916 reply.SendError(StringPrintf("No popup at index %d", popup_index)); |
| 3919 return; | 3917 return; |
| 3920 } | 3918 } |
| 3921 std::vector<TabContentsWrapper*> blocked_contents; | 3919 std::vector<TabContents*> blocked_contents; |
| 3922 blocked_content->GetBlockedContents(&blocked_contents); | 3920 blocked_content->GetBlockedContents(&blocked_contents); |
| 3923 blocked_content->LaunchForContents(blocked_contents[popup_index]); | 3921 blocked_content->LaunchForContents(blocked_contents[popup_index]); |
| 3924 reply.SendSuccess(NULL); | 3922 reply.SendSuccess(NULL); |
| 3925 } | 3923 } |
| 3926 | 3924 |
| 3927 // Sample json input: { "command": "GetThemeInfo" } | 3925 // Sample json input: { "command": "GetThemeInfo" } |
| 3928 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. | 3926 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. |
| 3929 void TestingAutomationProvider::GetThemeInfo( | 3927 void TestingAutomationProvider::GetThemeInfo( |
| 3930 Browser* browser, | 3928 Browser* browser, |
| 3931 DictionaryValue* args, | 3929 DictionaryValue* args, |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4390 reply.SendError(error); | 4388 reply.SendError(error); |
| 4391 return; | 4389 return; |
| 4392 } | 4390 } |
| 4393 | 4391 |
| 4394 RenderViewHost* render_view = web_contents->GetRenderViewHost(); | 4392 RenderViewHost* render_view = web_contents->GetRenderViewHost(); |
| 4395 if (!render_view) { | 4393 if (!render_view) { |
| 4396 reply.SendError("Tab has no associated RenderViewHost"); | 4394 reply.SendError("Tab has no associated RenderViewHost"); |
| 4397 return; | 4395 return; |
| 4398 } | 4396 } |
| 4399 | 4397 |
| 4400 TabContentsWrapper* tab_contents = | 4398 TabContents* tab_contents = |
| 4401 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 4399 TabContents::GetOwningTabContentsForWebContents(web_contents); |
| 4402 tab_contents->automation_tab_helper()->HeapProfilerDump(reason_string); | 4400 tab_contents->automation_tab_helper()->HeapProfilerDump(reason_string); |
| 4403 reply.SendSuccess(NULL); | 4401 reply.SendSuccess(NULL); |
| 4404 return; | 4402 return; |
| 4405 } | 4403 } |
| 4406 | 4404 |
| 4407 reply.SendError("Process type is not supported"); | 4405 reply.SendError("Process type is not supported"); |
| 4408 } | 4406 } |
| 4409 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) | 4407 #endif // !defined(NO_TCMALLOC) && (defined(OS_LINUX) || defined(OS_CHROMEOS)) |
| 4410 | 4408 |
| 4411 namespace { | 4409 namespace { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4468 DictionaryValue* args, | 4466 DictionaryValue* args, |
| 4469 IPC::Message* reply_message) { | 4467 IPC::Message* reply_message) { |
| 4470 AutomationJSONReply reply(this, reply_message); | 4468 AutomationJSONReply reply(this, reply_message); |
| 4471 // Get the AutofillProfiles currently in the database. | 4469 // Get the AutofillProfiles currently in the database. |
| 4472 int tab_index = 0; | 4470 int tab_index = 0; |
| 4473 if (!args->GetInteger("tab_index", &tab_index)) { | 4471 if (!args->GetInteger("tab_index", &tab_index)) { |
| 4474 reply.SendError("Invalid or missing tab_index integer value."); | 4472 reply.SendError("Invalid or missing tab_index integer value."); |
| 4475 return; | 4473 return; |
| 4476 } | 4474 } |
| 4477 | 4475 |
| 4478 TabContentsWrapper* tab_contents = | 4476 TabContents* tab_contents = |
| 4479 browser->GetTabContentsWrapperAt(tab_index); | 4477 browser->GetTabContentsAt(tab_index); |
| 4480 if (tab_contents) { | 4478 if (tab_contents) { |
| 4481 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( | 4479 PersonalDataManager* pdm = PersonalDataManagerFactory::GetForProfile( |
| 4482 tab_contents->profile()->GetOriginalProfile()); | 4480 tab_contents->profile()->GetOriginalProfile()); |
| 4483 if (pdm) { | 4481 if (pdm) { |
| 4484 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); | 4482 std::vector<AutofillProfile*> autofill_profiles = pdm->profiles(); |
| 4485 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); | 4483 std::vector<CreditCard*> credit_cards = pdm->credit_cards(); |
| 4486 | 4484 |
| 4487 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); | 4485 ListValue* profiles = GetListFromAutofillProfiles(autofill_profiles); |
| 4488 ListValue* cards = GetListFromCreditCards(credit_cards); | 4486 ListValue* cards = GetListFromCreditCards(credit_cards); |
| 4489 | 4487 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4534 } | 4532 } |
| 4535 | 4533 |
| 4536 // Save the AutofillProfiles. | 4534 // Save the AutofillProfiles. |
| 4537 int tab_index = 0; | 4535 int tab_index = 0; |
| 4538 if (!args->GetInteger("tab_index", &tab_index)) { | 4536 if (!args->GetInteger("tab_index", &tab_index)) { |
| 4539 AutomationJSONReply(this, reply_message).SendError( | 4537 AutomationJSONReply(this, reply_message).SendError( |
| 4540 "Invalid or missing tab_index integer"); | 4538 "Invalid or missing tab_index integer"); |
| 4541 return; | 4539 return; |
| 4542 } | 4540 } |
| 4543 | 4541 |
| 4544 TabContentsWrapper* tab_contents = | 4542 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); |
| 4545 browser->GetTabContentsWrapperAt(tab_index); | |
| 4546 | 4543 |
| 4547 if (tab_contents) { | 4544 if (tab_contents) { |
| 4548 PersonalDataManager* pdm = | 4545 PersonalDataManager* pdm = |
| 4549 PersonalDataManagerFactory::GetForProfile(tab_contents->profile()); | 4546 PersonalDataManagerFactory::GetForProfile(tab_contents->profile()); |
| 4550 if (pdm) { | 4547 if (pdm) { |
| 4551 if (profiles || cards) { | 4548 if (profiles || cards) { |
| 4552 // This observer will delete itself. | 4549 // This observer will delete itself. |
| 4553 AutofillChangedObserver* observer = new AutofillChangedObserver( | 4550 AutofillChangedObserver* observer = new AutofillChangedObserver( |
| 4554 this, reply_message, autofill_profiles.size(), credit_cards.size()); | 4551 this, reply_message, autofill_profiles.size(), credit_cards.size()); |
| 4555 observer->Init(); | 4552 observer->Init(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4579 IPC::Message* reply_message) { | 4576 IPC::Message* reply_message) { |
| 4580 if (SendErrorIfModalDialogActive(this, reply_message)) | 4577 if (SendErrorIfModalDialogActive(this, reply_message)) |
| 4581 return; | 4578 return; |
| 4582 | 4579 |
| 4583 int tab_index; | 4580 int tab_index; |
| 4584 if (!args->GetInteger("tab_index", &tab_index)) { | 4581 if (!args->GetInteger("tab_index", &tab_index)) { |
| 4585 AutomationJSONReply(this, reply_message) | 4582 AutomationJSONReply(this, reply_message) |
| 4586 .SendError("'tab_index' missing or invalid."); | 4583 .SendError("'tab_index' missing or invalid."); |
| 4587 return; | 4584 return; |
| 4588 } | 4585 } |
| 4589 TabContentsWrapper* tab_contents = | 4586 TabContents* tab_contents = browser->GetTabContentsAt(tab_index); |
| 4590 browser->GetTabContentsWrapperAt(tab_index); | |
| 4591 if (!tab_contents) { | 4587 if (!tab_contents) { |
| 4592 AutomationJSONReply(this, reply_message).SendError( | 4588 AutomationJSONReply(this, reply_message).SendError( |
| 4593 StringPrintf("No such tab at index %d", tab_index)); | 4589 StringPrintf("No such tab at index %d", tab_index)); |
| 4594 return; | 4590 return; |
| 4595 } | 4591 } |
| 4596 | 4592 |
| 4597 string16 frame_xpath, javascript; | 4593 string16 frame_xpath, javascript; |
| 4598 if (!args->GetString("frame_xpath", &frame_xpath)) { | 4594 if (!args->GetString("frame_xpath", &frame_xpath)) { |
| 4599 AutomationJSONReply(this, reply_message) | 4595 AutomationJSONReply(this, reply_message) |
| 4600 .SendError("'frame_xpath' missing or invalid."); | 4596 .SendError("'frame_xpath' missing or invalid."); |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5658 id.c_str())); | 5654 id.c_str())); |
| 5659 return; | 5655 return; |
| 5660 } | 5656 } |
| 5661 | 5657 |
| 5662 // Look at preferences to find the right launch container. If no preference | 5658 // Look at preferences to find the right launch container. If no preference |
| 5663 // is set, launch as a regular tab. | 5659 // is set, launch as a regular tab. |
| 5664 extension_misc::LaunchContainer launch_container = | 5660 extension_misc::LaunchContainer launch_container = |
| 5665 service->extension_prefs()->GetLaunchContainer( | 5661 service->extension_prefs()->GetLaunchContainer( |
| 5666 extension, ExtensionPrefs::LAUNCH_REGULAR); | 5662 extension, ExtensionPrefs::LAUNCH_REGULAR); |
| 5667 | 5663 |
| 5668 WebContents* old_contents = browser->GetSelectedWebContents(); | 5664 WebContents* old_contents = browser->GetActiveWebContents(); |
| 5669 if (!old_contents) { | 5665 if (!old_contents) { |
| 5670 AutomationJSONReply(this, reply_message).SendError( | 5666 AutomationJSONReply(this, reply_message).SendError( |
| 5671 "Cannot identify selected tab contents."); | 5667 "Cannot identify selected tab contents."); |
| 5672 return; | 5668 return; |
| 5673 } | 5669 } |
| 5674 | 5670 |
| 5675 // This observer will delete itself. | 5671 // This observer will delete itself. |
| 5676 new AppLaunchObserver(&old_contents->GetController(), this, reply_message, | 5672 new AppLaunchObserver(&old_contents->GetController(), this, reply_message, |
| 5677 launch_container); | 5673 launch_container); |
| 5678 application_launch::OpenApplication(profile(), extension, launch_container, | 5674 application_launch::OpenApplication(profile(), extension, launch_container, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5818 IPC::Message* reply_message) { | 5814 IPC::Message* reply_message) { |
| 5819 DictionaryValue dict; | 5815 DictionaryValue dict; |
| 5820 dict.SetBoolean("result", browser->IsFullscreenForTabOrPending()); | 5816 dict.SetBoolean("result", browser->IsFullscreenForTabOrPending()); |
| 5821 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5817 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 5822 } | 5818 } |
| 5823 | 5819 |
| 5824 void TestingAutomationProvider::IsMouseLocked(Browser* browser, | 5820 void TestingAutomationProvider::IsMouseLocked(Browser* browser, |
| 5825 base::DictionaryValue* args, | 5821 base::DictionaryValue* args, |
| 5826 IPC::Message* reply_message) { | 5822 IPC::Message* reply_message) { |
| 5827 DictionaryValue dict; | 5823 DictionaryValue dict; |
| 5828 dict.SetBoolean("result", browser->GetSelectedWebContents()-> | 5824 dict.SetBoolean("result", browser->GetActiveWebContents()-> |
| 5829 GetRenderViewHost()->GetView()->IsMouseLocked()); | 5825 GetRenderViewHost()->GetView()->IsMouseLocked()); |
| 5830 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5826 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 5831 } | 5827 } |
| 5832 | 5828 |
| 5833 void TestingAutomationProvider::IsMouseLockPermissionRequested( | 5829 void TestingAutomationProvider::IsMouseLockPermissionRequested( |
| 5834 Browser* browser, | 5830 Browser* browser, |
| 5835 base::DictionaryValue* args, | 5831 base::DictionaryValue* args, |
| 5836 IPC::Message* reply_message) { | 5832 IPC::Message* reply_message) { |
| 5837 FullscreenExitBubbleType type = | 5833 FullscreenExitBubbleType type = |
| 5838 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); | 5834 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5875 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); | 5871 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); |
| 5876 DictionaryValue dict; | 5872 DictionaryValue dict; |
| 5877 dict.SetBoolean("result", fullscreen_bubble::ShowButtonsForType(type)); | 5873 dict.SetBoolean("result", fullscreen_bubble::ShowButtonsForType(type)); |
| 5878 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 5874 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 5879 } | 5875 } |
| 5880 | 5876 |
| 5881 void TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest( | 5877 void TestingAutomationProvider::AcceptCurrentFullscreenOrMouseLockRequest( |
| 5882 Browser* browser, | 5878 Browser* browser, |
| 5883 base::DictionaryValue* args, | 5879 base::DictionaryValue* args, |
| 5884 IPC::Message* reply_message) { | 5880 IPC::Message* reply_message) { |
| 5885 WebContents* fullscreen_tab = browser->GetSelectedWebContents(); | 5881 WebContents* fullscreen_tab = browser->GetActiveWebContents(); |
| 5886 FullscreenExitBubbleType type = | 5882 FullscreenExitBubbleType type = |
| 5887 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); | 5883 browser->fullscreen_controller_->GetFullscreenExitBubbleType(); |
| 5888 browser->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); | 5884 browser->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); |
| 5889 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 5885 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 5890 } | 5886 } |
| 5891 | 5887 |
| 5892 void TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest( | 5888 void TestingAutomationProvider::DenyCurrentFullscreenOrMouseLockRequest( |
| 5893 Browser* browser, | 5889 Browser* browser, |
| 5894 base::DictionaryValue* args, | 5890 base::DictionaryValue* args, |
| 5895 IPC::Message* reply_message) { | 5891 IPC::Message* reply_message) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6009 reply.SendError("'tab_id' is invalid"); | 6005 reply.SendError("'tab_id' is invalid"); |
| 6010 return; | 6006 return; |
| 6011 } | 6007 } |
| 6012 if (has_handle && (!args->GetInteger("tab_handle", &id_or_handle) || | 6008 if (has_handle && (!args->GetInteger("tab_handle", &id_or_handle) || |
| 6013 !tab_tracker_->ContainsHandle(id_or_handle))) { | 6009 !tab_tracker_->ContainsHandle(id_or_handle))) { |
| 6014 reply.SendError("'tab_handle' is invalid"); | 6010 reply.SendError("'tab_handle' is invalid"); |
| 6015 return; | 6011 return; |
| 6016 } | 6012 } |
| 6017 int id = id_or_handle; | 6013 int id = id_or_handle; |
| 6018 if (has_handle) { | 6014 if (has_handle) { |
| 6019 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( | 6015 TabContents* tab = TabContents::GetOwningTabContentsForWebContents( |
| 6020 tab_tracker_->GetResource(id_or_handle)->GetWebContents()); | 6016 tab_tracker_->GetResource(id_or_handle)->GetWebContents()); |
| 6021 id = tab->restore_tab_helper()->session_id().id(); | 6017 id = tab->restore_tab_helper()->session_id().id(); |
| 6022 } | 6018 } |
| 6023 BrowserList::const_iterator iter = BrowserList::begin(); | 6019 BrowserList::const_iterator iter = BrowserList::begin(); |
| 6024 int browser_index = 0; | 6020 int browser_index = 0; |
| 6025 for (; iter != BrowserList::end(); ++iter, ++browser_index) { | 6021 for (; iter != BrowserList::end(); ++iter, ++browser_index) { |
| 6026 Browser* browser = *iter; | 6022 Browser* browser = *iter; |
| 6027 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { | 6023 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { |
| 6028 TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(tab_index); | 6024 TabContents* tab = browser->GetTabContentsAt(tab_index); |
| 6029 if (tab->restore_tab_helper()->session_id().id() == id) { | 6025 if (tab->restore_tab_helper()->session_id().id() == id) { |
| 6030 DictionaryValue dict; | 6026 DictionaryValue dict; |
| 6031 dict.SetInteger("windex", browser_index); | 6027 dict.SetInteger("windex", browser_index); |
| 6032 dict.SetInteger("tab_index", tab_index); | 6028 dict.SetInteger("tab_index", tab_index); |
| 6033 reply.SendSuccess(&dict); | 6029 reply.SendSuccess(&dict); |
| 6034 return; | 6030 return; |
| 6035 } | 6031 } |
| 6036 } | 6032 } |
| 6037 } | 6033 } |
| 6038 reply.SendError("Could not find tab among current browser windows"); | 6034 reply.SendError("Could not find tab among current browser windows"); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6336 .SendError("'path' missing or invalid"); | 6332 .SendError("'path' missing or invalid"); |
| 6337 return; | 6333 return; |
| 6338 } | 6334 } |
| 6339 | 6335 |
| 6340 RenderViewHost* render_view = web_contents->GetRenderViewHost(); | 6336 RenderViewHost* render_view = web_contents->GetRenderViewHost(); |
| 6341 if (render_view) { | 6337 if (render_view) { |
| 6342 FilePath path(path_str); | 6338 FilePath path(path_str); |
| 6343 // This will delete itself when finished. | 6339 // This will delete itself when finished. |
| 6344 PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker( | 6340 PageSnapshotTaker* snapshot_taker = new PageSnapshotTaker( |
| 6345 this, reply_message, | 6341 this, reply_message, |
| 6346 TabContentsWrapper::GetCurrentWrapperForContents(web_contents), path); | 6342 TabContents::GetOwningTabContentsForWebContents(web_contents), path); |
| 6347 snapshot_taker->Start(); | 6343 snapshot_taker->Start(); |
| 6348 } else { | 6344 } else { |
| 6349 AutomationJSONReply(this, reply_message) | 6345 AutomationJSONReply(this, reply_message) |
| 6350 .SendError("Tab has no associated RenderViewHost"); | 6346 .SendError("Tab has no associated RenderViewHost"); |
| 6351 } | 6347 } |
| 6352 } | 6348 } |
| 6353 | 6349 |
| 6354 void TestingAutomationProvider::GetCookiesJSON( | 6350 void TestingAutomationProvider::GetCookiesJSON( |
| 6355 DictionaryValue* args, IPC::Message* reply_message) { | 6351 DictionaryValue* args, IPC::Message* reply_message) { |
| 6356 automation_util::GetCookiesJSON(this, args, reply_message); | 6352 automation_util::GetCookiesJSON(this, args, reply_message); |
| 6357 } | 6353 } |
| 6358 | 6354 |
| 6359 void TestingAutomationProvider::DeleteCookieJSON( | 6355 void TestingAutomationProvider::DeleteCookieJSON( |
| 6360 DictionaryValue* args, IPC::Message* reply_message) { | 6356 DictionaryValue* args, IPC::Message* reply_message) { |
| 6361 automation_util::DeleteCookieJSON(this, args, reply_message); | 6357 automation_util::DeleteCookieJSON(this, args, reply_message); |
| 6362 } | 6358 } |
| 6363 | 6359 |
| 6364 void TestingAutomationProvider::SetCookieJSON( | 6360 void TestingAutomationProvider::SetCookieJSON( |
| 6365 DictionaryValue* args, IPC::Message* reply_message) { | 6361 DictionaryValue* args, IPC::Message* reply_message) { |
| 6366 automation_util::SetCookieJSON(this, args, reply_message); | 6362 automation_util::SetCookieJSON(this, args, reply_message); |
| 6367 } | 6363 } |
| 6368 | 6364 |
| 6369 void TestingAutomationProvider::GetTabIds( | 6365 void TestingAutomationProvider::GetTabIds( |
| 6370 DictionaryValue* args, IPC::Message* reply_message) { | 6366 DictionaryValue* args, IPC::Message* reply_message) { |
| 6371 ListValue* id_list = new ListValue(); | 6367 ListValue* id_list = new ListValue(); |
| 6372 BrowserList::const_iterator iter = BrowserList::begin(); | 6368 BrowserList::const_iterator iter = BrowserList::begin(); |
| 6373 for (; iter != BrowserList::end(); ++iter) { | 6369 for (; iter != BrowserList::end(); ++iter) { |
| 6374 Browser* browser = *iter; | 6370 Browser* browser = *iter; |
| 6375 for (int i = 0; i < browser->tab_count(); ++i) { | 6371 for (int i = 0; i < browser->tab_count(); ++i) { |
| 6376 int id = browser->GetTabContentsWrapperAt(i)->restore_tab_helper()-> | 6372 int id = browser->GetTabContentsAt(i)->restore_tab_helper()-> |
| 6377 session_id().id(); | 6373 session_id().id(); |
| 6378 id_list->Append(Value::CreateIntegerValue(id)); | 6374 id_list->Append(Value::CreateIntegerValue(id)); |
| 6379 } | 6375 } |
| 6380 } | 6376 } |
| 6381 DictionaryValue dict; | 6377 DictionaryValue dict; |
| 6382 dict.Set("ids", id_list); | 6378 dict.Set("ids", id_list); |
| 6383 AutomationJSONReply(this, reply_message).SendSuccess(&dict); | 6379 AutomationJSONReply(this, reply_message).SendSuccess(&dict); |
| 6384 } | 6380 } |
| 6385 | 6381 |
| 6386 void TestingAutomationProvider::GetViews( | 6382 void TestingAutomationProvider::GetViews( |
| 6387 DictionaryValue* args, IPC::Message* reply_message) { | 6383 DictionaryValue* args, IPC::Message* reply_message) { |
| 6388 ListValue* view_list = new ListValue(); | 6384 ListValue* view_list = new ListValue(); |
| 6389 printing::PrintPreviewTabController* preview_controller = | 6385 printing::PrintPreviewTabController* preview_controller = |
| 6390 printing::PrintPreviewTabController::GetInstance(); | 6386 printing::PrintPreviewTabController::GetInstance(); |
| 6391 BrowserList::const_iterator browser_iter = BrowserList::begin(); | 6387 BrowserList::const_iterator browser_iter = BrowserList::begin(); |
| 6392 for (; browser_iter != BrowserList::end(); ++browser_iter) { | 6388 for (; browser_iter != BrowserList::end(); ++browser_iter) { |
| 6393 Browser* browser = *browser_iter; | 6389 Browser* browser = *browser_iter; |
| 6394 for (int i = 0; i < browser->tab_count(); ++i) { | 6390 for (int i = 0; i < browser->tab_count(); ++i) { |
| 6395 TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(i); | 6391 TabContents* tab = browser->GetTabContentsAt(i); |
| 6396 DictionaryValue* dict = new DictionaryValue(); | 6392 DictionaryValue* dict = new DictionaryValue(); |
| 6397 AutomationId id = automation_util::GetIdForTab(tab); | 6393 AutomationId id = automation_util::GetIdForTab(tab); |
| 6398 dict->Set("auto_id", id.ToValue()); | 6394 dict->Set("auto_id", id.ToValue()); |
| 6399 view_list->Append(dict); | 6395 view_list->Append(dict); |
| 6400 if (preview_controller) { | 6396 if (preview_controller) { |
| 6401 TabContentsWrapper* preview_tab = | 6397 TabContents* preview_tab = |
| 6402 preview_controller->GetPrintPreviewForTab(tab); | 6398 preview_controller->GetPrintPreviewForTab(tab); |
| 6403 if (preview_tab) { | 6399 if (preview_tab) { |
| 6404 DictionaryValue* dict = new DictionaryValue(); | 6400 DictionaryValue* dict = new DictionaryValue(); |
| 6405 AutomationId id = automation_util::GetIdForTab(preview_tab); | 6401 AutomationId id = automation_util::GetIdForTab(preview_tab); |
| 6406 dict->Set("auto_id", id.ToValue()); | 6402 dict->Set("auto_id", id.ToValue()); |
| 6407 view_list->Append(dict); | 6403 view_list->Append(dict); |
| 6408 } | 6404 } |
| 6409 } | 6405 } |
| 6410 } | 6406 } |
| 6411 } | 6407 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6438 int id; | 6434 int id; |
| 6439 if (!args->GetInteger("id", &id)) { | 6435 if (!args->GetInteger("id", &id)) { |
| 6440 reply.SendError("'id' missing or invalid"); | 6436 reply.SendError("'id' missing or invalid"); |
| 6441 return; | 6437 return; |
| 6442 } | 6438 } |
| 6443 bool is_valid = false; | 6439 bool is_valid = false; |
| 6444 BrowserList::const_iterator iter = BrowserList::begin(); | 6440 BrowserList::const_iterator iter = BrowserList::begin(); |
| 6445 for (; iter != BrowserList::end(); ++iter) { | 6441 for (; iter != BrowserList::end(); ++iter) { |
| 6446 Browser* browser = *iter; | 6442 Browser* browser = *iter; |
| 6447 for (int i = 0; i < browser->tab_count(); ++i) { | 6443 for (int i = 0; i < browser->tab_count(); ++i) { |
| 6448 TabContentsWrapper* tab = browser->GetTabContentsWrapperAt(i); | 6444 TabContents* tab = browser->GetTabContentsAt(i); |
| 6449 if (tab->restore_tab_helper()->session_id().id() == id) { | 6445 if (tab->restore_tab_helper()->session_id().id() == id) { |
| 6450 is_valid = true; | 6446 is_valid = true; |
| 6451 break; | 6447 break; |
| 6452 } | 6448 } |
| 6453 } | 6449 } |
| 6454 } | 6450 } |
| 6455 DictionaryValue dict; | 6451 DictionaryValue dict; |
| 6456 dict.SetBoolean("is_valid", is_valid); | 6452 dict.SetBoolean("is_valid", is_valid); |
| 6457 reply.SendSuccess(&dict); | 6453 reply.SendSuccess(&dict); |
| 6458 } | 6454 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6645 | 6641 |
| 6646 NavigationController* controller = tab_tracker_->GetResource(tab_handle); | 6642 NavigationController* controller = tab_tracker_->GetResource(tab_handle); |
| 6647 if (!controller) { | 6643 if (!controller) { |
| 6648 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_, false); | 6644 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_, false); |
| 6649 Send(reply_message_); | 6645 Send(reply_message_); |
| 6650 return; | 6646 return; |
| 6651 } | 6647 } |
| 6652 | 6648 |
| 6653 // The delegate will delete itself. | 6649 // The delegate will delete itself. |
| 6654 new InfoBarCountObserver(this, reply_message, | 6650 new InfoBarCountObserver(this, reply_message, |
| 6655 TabContentsWrapper::GetCurrentWrapperForContents( | 6651 TabContents::GetOwningTabContentsForWebContents( |
| 6656 controller->GetWebContents()), target_count); | 6652 controller->GetWebContents()), target_count); |
| 6657 } | 6653 } |
| 6658 | 6654 |
| 6659 void TestingAutomationProvider::ResetToDefaultTheme() { | 6655 void TestingAutomationProvider::ResetToDefaultTheme() { |
| 6660 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); | 6656 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); |
| 6661 } | 6657 } |
| 6662 | 6658 |
| 6663 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( | 6659 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( |
| 6664 IPC::Message* reply_message) { | 6660 IPC::Message* reply_message) { |
| 6665 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); | 6661 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); |
| 6666 } | 6662 } |
| 6667 | 6663 |
| 6668 void TestingAutomationProvider::OnRemoveProvider() { | 6664 void TestingAutomationProvider::OnRemoveProvider() { |
| 6669 if (g_browser_process) | 6665 if (g_browser_process) |
| 6670 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6666 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6671 } | 6667 } |
| 6672 | 6668 |
| 6673 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 6669 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 6674 WebContents* tab) { | 6670 WebContents* tab) { |
| 6675 if (browser->GetSelectedWebContents() != tab || | 6671 if (browser->GetActiveWebContents() != tab || |
| 6676 browser != BrowserList::GetLastActive()) { | 6672 browser != BrowserList::GetLastActive()) { |
| 6677 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), | 6673 browser->ActivateTabAt(browser->GetIndexOfController(&tab->GetController()), |
| 6678 true /* user_gesture */); | 6674 true /* user_gesture */); |
| 6679 } | 6675 } |
| 6680 } | 6676 } |
| OLD | NEW |