Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
56 #include "chrome/browser/extensions/extension_host.h" 56 #include "chrome/browser/extensions/extension_host.h"
57 #include "chrome/browser/extensions/extension_process_manager.h" 57 #include "chrome/browser/extensions/extension_process_manager.h"
58 #include "chrome/browser/extensions/extension_service.h" 58 #include "chrome/browser/extensions/extension_service.h"
59 #include "chrome/browser/extensions/extension_system.h" 59 #include "chrome/browser/extensions/extension_system.h"
60 #include "chrome/browser/extensions/extension_tab_util.h" 60 #include "chrome/browser/extensions/extension_tab_util.h"
61 #include "chrome/browser/extensions/unpacked_installer.h" 61 #include "chrome/browser/extensions/unpacked_installer.h"
62 #include "chrome/browser/extensions/updater/extension_updater.h" 62 #include "chrome/browser/extensions/updater/extension_updater.h"
63 #include "chrome/browser/history/history_service_factory.h" 63 #include "chrome/browser/history/history_service_factory.h"
64 #include "chrome/browser/history/top_sites.h" 64 #include "chrome/browser/history/top_sites.h"
65 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 65 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
66 #include "chrome/browser/infobars/infobar.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/balloon_notification_ui_manager.h" 71 #include "chrome/browser/notifications/balloon_notification_ui_manager.h"
71 #include "chrome/browser/notifications/notification.h" 72 #include "chrome/browser/notifications/notification.h"
72 #include "chrome/browser/password_manager/password_store.h" 73 #include "chrome/browser/password_manager/password_store.h"
73 #include "chrome/browser/password_manager/password_store_change.h" 74 #include "chrome/browser/password_manager/password_store_change.h"
74 #include "chrome/browser/password_manager/password_store_factory.h" 75 #include "chrome/browser/password_manager/password_store_factory.h"
75 #include "chrome/browser/platform_util.h" 76 #include "chrome/browser/platform_util.h"
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 browser->window()->SetBounds(rect); 1995 browser->window()->SetBounds(rect);
1995 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 1996 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
1996 } 1997 }
1997 1998
1998 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { 1999 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) {
1999 // Each infobar may have different properties depending on the type. 2000 // Each infobar may have different properties depending on the type.
2000 ListValue* infobars = new ListValue; 2001 ListValue* infobars = new ListValue;
2001 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc); 2002 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc);
2002 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { 2003 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
2003 DictionaryValue* infobar_item = new DictionaryValue; 2004 DictionaryValue* infobar_item = new DictionaryValue;
2004 InfoBarDelegate* infobar = infobar_service->infobar_at(i); 2005 InfoBarDelegate* infobar = infobar_service->infobar_at(i)->delegate();
2005 switch (infobar->GetInfoBarAutomationType()) { 2006 switch (infobar->GetInfoBarAutomationType()) {
2006 case InfoBarDelegate::CONFIRM_INFOBAR: 2007 case InfoBarDelegate::CONFIRM_INFOBAR:
2007 infobar_item->SetString("type", "confirm_infobar"); 2008 infobar_item->SetString("type", "confirm_infobar");
2008 break; 2009 break;
2009 case InfoBarDelegate::PASSWORD_INFOBAR: 2010 case InfoBarDelegate::PASSWORD_INFOBAR:
2010 infobar_item->SetString("type", "password_infobar"); 2011 infobar_item->SetString("type", "password_infobar");
2011 break; 2012 break;
2012 case InfoBarDelegate::RPH_INFOBAR: 2013 case InfoBarDelegate::RPH_INFOBAR:
2013 infobar_item->SetString("type", "rph_infobar"); 2014 infobar_item->SetString("type", "rph_infobar");
2014 break; 2015 break;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 return; 2076 return;
2076 } 2077 }
2077 2078
2078 InfoBarService* infobar_service = 2079 InfoBarService* infobar_service =
2079 InfoBarService::FromWebContents(web_contents); 2080 InfoBarService::FromWebContents(web_contents);
2080 if (infobar_index >= infobar_service->infobar_count()) { 2081 if (infobar_index >= infobar_service->infobar_count()) {
2081 reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS, 2082 reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS,
2082 infobar_index)); 2083 infobar_index));
2083 return; 2084 return;
2084 } 2085 }
2085 InfoBarDelegate* infobar_delegate = 2086 InfoBar* infobar = infobar_service->infobar_at(infobar_index);
2086 infobar_service->infobar_at(infobar_index); 2087 InfoBarDelegate* infobar_delegate = infobar->delegate();
2087 2088
2088 if (action == "dismiss") { 2089 if (action == "dismiss") {
2089 infobar_delegate->InfoBarDismissed(); 2090 infobar_delegate->InfoBarDismissed();
2090 infobar_service->RemoveInfoBar(infobar_delegate); 2091 infobar_service->RemoveInfoBar(infobar);
2091 reply.SendSuccess(NULL); 2092 reply.SendSuccess(NULL);
2092 return; 2093 return;
2093 } 2094 }
2094 if ((action == "accept") || (action == "cancel")) { 2095 if ((action == "accept") || (action == "cancel")) {
2095 ConfirmInfoBarDelegate* confirm_infobar_delegate = 2096 ConfirmInfoBarDelegate* confirm_infobar_delegate =
2096 infobar_delegate->AsConfirmInfoBarDelegate(); 2097 infobar_delegate->AsConfirmInfoBarDelegate();
2097 if (!confirm_infobar_delegate) { 2098 if (!confirm_infobar_delegate) {
2098 reply.SendError("Not a confirm infobar"); 2099 reply.SendError("Not a confirm infobar");
2099 return; 2100 return;
2100 } 2101 }
2101 if ((action == "accept") ? 2102 if ((action == "accept") ?
2102 confirm_infobar_delegate->Accept() : confirm_infobar_delegate->Cancel()) 2103 confirm_infobar_delegate->Accept() : confirm_infobar_delegate->Cancel())
2103 infobar_service->RemoveInfoBar(infobar_delegate); 2104 infobar_service->RemoveInfoBar(infobar);
2104 reply.SendSuccess(NULL); 2105 reply.SendSuccess(NULL);
2105 return; 2106 return;
2106 } 2107 }
2107 2108
2108 reply.SendError("Invalid action"); 2109 reply.SendError("Invalid action");
2109 } 2110 }
2110 2111
2111 namespace { 2112 namespace {
2112 2113
2113 // Gets info about BrowserChildProcessHost. Must run on IO thread to 2114 // Gets info about BrowserChildProcessHost. Must run on IO thread to
(...skipping 3340 matching lines...) Expand 10 before | Expand all | Expand 10 after
5454 if (g_browser_process) 5455 if (g_browser_process)
5455 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 5456 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
5456 } 5457 }
5457 5458
5458 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 5459 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
5459 WebContents* tab) { 5460 WebContents* tab) {
5460 TabStripModel* tab_strip = browser->tab_strip_model(); 5461 TabStripModel* tab_strip = browser->tab_strip_model();
5461 if (tab_strip->GetActiveWebContents() != tab) 5462 if (tab_strip->GetActiveWebContents() != tab)
5462 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); 5463 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true);
5463 } 5464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698