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 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 rect.set_height(height); | 2168 rect.set_height(height); |
2169 browser->window()->SetBounds(rect); | 2169 browser->window()->SetBounds(rect); |
2170 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 2170 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
2171 } | 2171 } |
2172 | 2172 |
2173 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { | 2173 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { |
2174 // Each infobar may have different properties depending on the type. | 2174 // Each infobar may have different properties depending on the type. |
2175 ListValue* infobars = new ListValue; | 2175 ListValue* infobars = new ListValue; |
2176 InfoBarTabHelper* infobar_helper = | 2176 InfoBarTabHelper* infobar_helper = |
2177 TabContents::FromWebContents(wc)->infobar_tab_helper(); | 2177 TabContents::FromWebContents(wc)->infobar_tab_helper(); |
2178 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 2178 for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); ++i) { |
2179 DictionaryValue* infobar_item = new DictionaryValue; | 2179 DictionaryValue* infobar_item = new DictionaryValue; |
2180 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); | 2180 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); |
2181 switch (infobar->GetInfoBarAutomationType()) { | 2181 switch (infobar->GetInfoBarAutomationType()) { |
2182 case InfoBarDelegate::CONFIRM_INFOBAR: | 2182 case InfoBarDelegate::CONFIRM_INFOBAR: |
2183 infobar_item->SetString("type", "confirm_infobar"); | 2183 infobar_item->SetString("type", "confirm_infobar"); |
2184 break; | 2184 break; |
2185 case InfoBarDelegate::ONE_CLICK_LOGIN_INFOBAR: | 2185 case InfoBarDelegate::ONE_CLICK_LOGIN_INFOBAR: |
2186 infobar_item->SetString("type", "oneclicklogin_infobar"); | 2186 infobar_item->SetString("type", "oneclicklogin_infobar"); |
2187 break; | 2187 break; |
2188 case InfoBarDelegate::PASSWORD_INFOBAR: | 2188 case InfoBarDelegate::PASSWORD_INFOBAR: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 | 2260 |
2261 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); | 2261 TabContents* tab_contents = chrome::GetTabContentsAt(browser, tab_index); |
2262 if (!tab_contents) { | 2262 if (!tab_contents) { |
2263 reply.SendError(StringPrintf("No such tab at index %d", tab_index)); | 2263 reply.SendError(StringPrintf("No such tab at index %d", tab_index)); |
2264 return; | 2264 return; |
2265 } | 2265 } |
2266 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 2266 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
2267 | 2267 |
2268 InfoBarDelegate* infobar = NULL; | 2268 InfoBarDelegate* infobar = NULL; |
2269 size_t infobar_index = static_cast<size_t>(infobar_index_int); | 2269 size_t infobar_index = static_cast<size_t>(infobar_index_int); |
2270 if (infobar_index >= infobar_helper->infobar_count()) { | 2270 if (infobar_index >= infobar_helper->GetInfoBarCount()) { |
2271 reply.SendError(StringPrintf("No such infobar at index %" PRIuS, | 2271 reply.SendError(StringPrintf("No such infobar at index %" PRIuS, |
2272 infobar_index)); | 2272 infobar_index)); |
2273 return; | 2273 return; |
2274 } | 2274 } |
2275 infobar = infobar_helper->GetInfoBarDelegateAt(infobar_index); | 2275 infobar = infobar_helper->GetInfoBarDelegateAt(infobar_index); |
2276 | 2276 |
2277 if ("dismiss" == action) { | 2277 if ("dismiss" == action) { |
2278 infobar->InfoBarDismissed(); | 2278 infobar->InfoBarDismissed(); |
2279 infobar_helper->RemoveInfoBar(infobar); | 2279 infobar_helper->RemoveInfoBar(infobar); |
2280 reply.SendSuccess(NULL); | 2280 reply.SendSuccess(NULL); |
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3779 return NULL; | 3779 return NULL; |
3780 } | 3780 } |
3781 return tab_contents; | 3781 return tab_contents; |
3782 } | 3782 } |
3783 | 3783 |
3784 // Get the TranslateInfoBarDelegate from WebContents. | 3784 // Get the TranslateInfoBarDelegate from WebContents. |
3785 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( | 3785 TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( |
3786 WebContents* web_contents) { | 3786 WebContents* web_contents) { |
3787 InfoBarTabHelper* infobar_helper = | 3787 InfoBarTabHelper* infobar_helper = |
3788 TabContents::FromWebContents(web_contents)->infobar_tab_helper(); | 3788 TabContents::FromWebContents(web_contents)->infobar_tab_helper(); |
3789 for (size_t i = 0; i < infobar_helper->infobar_count(); i++) { | 3789 for (size_t i = 0; i < infobar_helper->GetInfoBarCount(); i++) { |
3790 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); | 3790 InfoBarDelegate* infobar = infobar_helper->GetInfoBarDelegateAt(i); |
3791 if (infobar->AsTranslateInfoBarDelegate()) | 3791 if (infobar->AsTranslateInfoBarDelegate()) |
3792 return infobar->AsTranslateInfoBarDelegate(); | 3792 return infobar->AsTranslateInfoBarDelegate(); |
3793 } | 3793 } |
3794 // No translate infobar. | 3794 // No translate infobar. |
3795 return NULL; | 3795 return NULL; |
3796 } | 3796 } |
3797 | 3797 |
3798 } // namespace | 3798 } // namespace |
3799 | 3799 |
(...skipping 3447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7247 void TestingAutomationProvider::OnRemoveProvider() { | 7247 void TestingAutomationProvider::OnRemoveProvider() { |
7248 if (g_browser_process) | 7248 if (g_browser_process) |
7249 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7249 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
7250 } | 7250 } |
7251 | 7251 |
7252 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 7252 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
7253 WebContents* tab) { | 7253 WebContents* tab) { |
7254 if (chrome::GetActiveWebContents(browser) != tab) | 7254 if (chrome::GetActiveWebContents(browser) != tab) |
7255 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 7255 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
7256 } | 7256 } |
OLD | NEW |