| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #include "chrome/browser/extensions/extension_service.h" | 56 #include "chrome/browser/extensions/extension_service.h" |
| 57 #include "chrome/browser/extensions/extension_tab_util.h" | 57 #include "chrome/browser/extensions/extension_tab_util.h" |
| 58 #include "chrome/browser/extensions/extension_util.h" | 58 #include "chrome/browser/extensions/extension_util.h" |
| 59 #include "chrome/browser/extensions/launch_util.h" | 59 #include "chrome/browser/extensions/launch_util.h" |
| 60 #include "chrome/browser/extensions/unpacked_installer.h" | 60 #include "chrome/browser/extensions/unpacked_installer.h" |
| 61 #include "chrome/browser/extensions/updater/extension_updater.h" | 61 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 62 #include "chrome/browser/history/history_service_factory.h" | 62 #include "chrome/browser/history/history_service_factory.h" |
| 63 #include "chrome/browser/history/top_sites.h" | 63 #include "chrome/browser/history/top_sites.h" |
| 64 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 64 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 65 #include "chrome/browser/infobars/infobar.h" | 65 #include "chrome/browser/infobars/infobar.h" |
| 66 #include "chrome/browser/infobars/infobar_manager.h" |
| 66 #include "chrome/browser/infobars/infobar_service.h" | 67 #include "chrome/browser/infobars/infobar_service.h" |
| 67 #include "chrome/browser/lifetime/application_lifetime.h" | 68 #include "chrome/browser/lifetime/application_lifetime.h" |
| 68 #include "chrome/browser/notifications/balloon.h" | 69 #include "chrome/browser/notifications/balloon.h" |
| 69 #include "chrome/browser/notifications/balloon_collection.h" | 70 #include "chrome/browser/notifications/balloon_collection.h" |
| 70 #include "chrome/browser/notifications/notification.h" | 71 #include "chrome/browser/notifications/notification.h" |
| 71 #include "chrome/browser/password_manager/password_store_factory.h" | 72 #include "chrome/browser/password_manager/password_store_factory.h" |
| 72 #include "chrome/browser/platform_util.h" | 73 #include "chrome/browser/platform_util.h" |
| 73 #include "chrome/browser/plugins/plugin_prefs.h" | 74 #include "chrome/browser/plugins/plugin_prefs.h" |
| 74 #include "chrome/browser/profiles/profile.h" | 75 #include "chrome/browser/profiles/profile.h" |
| 75 #include "chrome/browser/profiles/profile_info_cache.h" | 76 #include "chrome/browser/profiles/profile_info_cache.h" |
| (...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 rect.set_width(width); | 1989 rect.set_width(width); |
| 1989 if (args->GetInteger("height", &height)) | 1990 if (args->GetInteger("height", &height)) |
| 1990 rect.set_height(height); | 1991 rect.set_height(height); |
| 1991 browser->window()->SetBounds(rect); | 1992 browser->window()->SetBounds(rect); |
| 1992 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 1993 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 1993 } | 1994 } |
| 1994 | 1995 |
| 1995 base::ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { | 1996 base::ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { |
| 1996 // Each infobar may have different properties depending on the type. | 1997 // Each infobar may have different properties depending on the type. |
| 1997 base::ListValue* infobars = new base::ListValue; | 1998 base::ListValue* infobars = new base::ListValue; |
| 1998 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc); | 1999 InfoBarManager* infobar_manager = |
| 1999 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 2000 InfoBarService::FromWebContents(wc)->infobar_manager(); |
| 2001 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { |
| 2000 base::DictionaryValue* infobar_item = new base::DictionaryValue; | 2002 base::DictionaryValue* infobar_item = new base::DictionaryValue; |
| 2001 InfoBarDelegate* infobar = infobar_service->infobar_at(i)->delegate(); | 2003 InfoBarDelegate* infobar = infobar_manager->infobar_at(i)->delegate(); |
| 2002 switch (infobar->GetInfoBarAutomationType()) { | 2004 switch (infobar->GetInfoBarAutomationType()) { |
| 2003 case InfoBarDelegate::CONFIRM_INFOBAR: | 2005 case InfoBarDelegate::CONFIRM_INFOBAR: |
| 2004 infobar_item->SetString("type", "confirm_infobar"); | 2006 infobar_item->SetString("type", "confirm_infobar"); |
| 2005 break; | 2007 break; |
| 2006 case InfoBarDelegate::PASSWORD_INFOBAR: | 2008 case InfoBarDelegate::PASSWORD_INFOBAR: |
| 2007 infobar_item->SetString("type", "password_infobar"); | 2009 infobar_item->SetString("type", "password_infobar"); |
| 2008 break; | 2010 break; |
| 2009 case InfoBarDelegate::RPH_INFOBAR: | 2011 case InfoBarDelegate::RPH_INFOBAR: |
| 2010 infobar_item->SetString("type", "rph_infobar"); | 2012 infobar_item->SetString("type", "rph_infobar"); |
| 2011 break; | 2013 break; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2065 } | 2067 } |
| 2066 size_t infobar_index = static_cast<size_t>(infobar_index_int); | 2068 size_t infobar_index = static_cast<size_t>(infobar_index_int); |
| 2067 | 2069 |
| 2068 WebContents* web_contents = | 2070 WebContents* web_contents = |
| 2069 browser->tab_strip_model()->GetWebContentsAt(tab_index); | 2071 browser->tab_strip_model()->GetWebContentsAt(tab_index); |
| 2070 if (!web_contents) { | 2072 if (!web_contents) { |
| 2071 reply.SendError(base::StringPrintf("No such tab at index %d", tab_index)); | 2073 reply.SendError(base::StringPrintf("No such tab at index %d", tab_index)); |
| 2072 return; | 2074 return; |
| 2073 } | 2075 } |
| 2074 | 2076 |
| 2075 InfoBarService* infobar_service = | 2077 InfoBarManager* infobar_manager = |
| 2076 InfoBarService::FromWebContents(web_contents); | 2078 InfoBarService::FromWebContents(web_contents)->infobar_manager(); |
| 2077 if (infobar_index >= infobar_service->infobar_count()) { | 2079 if (infobar_index >= infobar_manager->infobar_count()) { |
| 2078 reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS, | 2080 reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS, |
| 2079 infobar_index)); | 2081 infobar_index)); |
| 2080 return; | 2082 return; |
| 2081 } | 2083 } |
| 2082 InfoBar* infobar = infobar_service->infobar_at(infobar_index); | 2084 InfoBar* infobar = infobar_manager->infobar_at(infobar_index); |
| 2083 InfoBarDelegate* infobar_delegate = infobar->delegate(); | 2085 InfoBarDelegate* infobar_delegate = infobar->delegate(); |
| 2084 | 2086 |
| 2085 if (action == "dismiss") { | 2087 if (action == "dismiss") { |
| 2086 infobar_delegate->InfoBarDismissed(); | 2088 infobar_delegate->InfoBarDismissed(); |
| 2087 infobar_service->RemoveInfoBar(infobar); | 2089 infobar_manager->RemoveInfoBar(infobar); |
| 2088 reply.SendSuccess(NULL); | 2090 reply.SendSuccess(NULL); |
| 2089 return; | 2091 return; |
| 2090 } | 2092 } |
| 2091 if ((action == "accept") || (action == "cancel")) { | 2093 if ((action == "accept") || (action == "cancel")) { |
| 2092 ConfirmInfoBarDelegate* confirm_infobar_delegate = | 2094 ConfirmInfoBarDelegate* confirm_infobar_delegate = |
| 2093 infobar_delegate->AsConfirmInfoBarDelegate(); | 2095 infobar_delegate->AsConfirmInfoBarDelegate(); |
| 2094 if (!confirm_infobar_delegate) { | 2096 if (!confirm_infobar_delegate) { |
| 2095 reply.SendError("Not a confirm infobar"); | 2097 reply.SendError("Not a confirm infobar"); |
| 2096 return; | 2098 return; |
| 2097 } | 2099 } |
| 2098 if ((action == "accept") ? | 2100 if ((action == "accept") ? |
| 2099 confirm_infobar_delegate->Accept() : confirm_infobar_delegate->Cancel()) | 2101 confirm_infobar_delegate->Accept() : confirm_infobar_delegate->Cancel()) |
| 2100 infobar_service->RemoveInfoBar(infobar); | 2102 infobar_manager->RemoveInfoBar(infobar); |
| 2101 reply.SendSuccess(NULL); | 2103 reply.SendSuccess(NULL); |
| 2102 return; | 2104 return; |
| 2103 } | 2105 } |
| 2104 | 2106 |
| 2105 reply.SendError("Invalid action"); | 2107 reply.SendError("Invalid action"); |
| 2106 } | 2108 } |
| 2107 | 2109 |
| 2108 namespace { | 2110 namespace { |
| 2109 | 2111 |
| 2110 // Gets info about BrowserChildProcessHost. Must run on IO thread to | 2112 // Gets info about BrowserChildProcessHost. Must run on IO thread to |
| (...skipping 3129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5240 if (g_browser_process) | 5242 if (g_browser_process) |
| 5241 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 5243 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 5242 } | 5244 } |
| 5243 | 5245 |
| 5244 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 5246 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
| 5245 WebContents* tab) { | 5247 WebContents* tab) { |
| 5246 TabStripModel* tab_strip = browser->tab_strip_model(); | 5248 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 5247 if (tab_strip->GetActiveWebContents() != tab) | 5249 if (tab_strip->GetActiveWebContents() != tab) |
| 5248 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); | 5250 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); |
| 5249 } | 5251 } |
| OLD | NEW |