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

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 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_service.h" 57 #include "chrome/browser/extensions/extension_service.h"
58 #include "chrome/browser/extensions/extension_system.h" 58 #include "chrome/browser/extensions/extension_system.h"
59 #include "chrome/browser/extensions/extension_tab_util.h" 59 #include "chrome/browser/extensions/extension_tab_util.h"
60 #include "chrome/browser/extensions/extension_util.h" 60 #include "chrome/browser/extensions/extension_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 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ListValue* TestingAutomationProvider::GetInfobarsInfo(WebContents* wc) { 1996 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 ListValue* infobars = new ListValue; 1998 ListValue* infobars = new ListValue;
1998 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc); 1999 InfoBarService* infobar_service = InfoBarService::FromWebContents(wc);
1999 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { 2000 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
2000 DictionaryValue* infobar_item = new DictionaryValue; 2001 DictionaryValue* infobar_item = new DictionaryValue;
2001 InfoBarDelegate* infobar = infobar_service->infobar_at(i); 2002 InfoBarDelegate* infobar = infobar_service->infobar_at(i)->delegate();
2002 switch (infobar->GetInfoBarAutomationType()) { 2003 switch (infobar->GetInfoBarAutomationType()) {
2003 case InfoBarDelegate::CONFIRM_INFOBAR: 2004 case InfoBarDelegate::CONFIRM_INFOBAR:
2004 infobar_item->SetString("type", "confirm_infobar"); 2005 infobar_item->SetString("type", "confirm_infobar");
2005 break; 2006 break;
2006 case InfoBarDelegate::PASSWORD_INFOBAR: 2007 case InfoBarDelegate::PASSWORD_INFOBAR:
2007 infobar_item->SetString("type", "password_infobar"); 2008 infobar_item->SetString("type", "password_infobar");
2008 break; 2009 break;
2009 case InfoBarDelegate::RPH_INFOBAR: 2010 case InfoBarDelegate::RPH_INFOBAR:
2010 infobar_item->SetString("type", "rph_infobar"); 2011 infobar_item->SetString("type", "rph_infobar");
2011 break; 2012 break;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 return; 2073 return;
2073 } 2074 }
2074 2075
2075 InfoBarService* infobar_service = 2076 InfoBarService* infobar_service =
2076 InfoBarService::FromWebContents(web_contents); 2077 InfoBarService::FromWebContents(web_contents);
2077 if (infobar_index >= infobar_service->infobar_count()) { 2078 if (infobar_index >= infobar_service->infobar_count()) {
2078 reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS, 2079 reply.SendError(base::StringPrintf("No such infobar at index %" PRIuS,
2079 infobar_index)); 2080 infobar_index));
2080 return; 2081 return;
2081 } 2082 }
2082 InfoBarDelegate* infobar_delegate = 2083 InfoBar* infobar = infobar_service->infobar_at(infobar_index);
2083 infobar_service->infobar_at(infobar_index); 2084 InfoBarDelegate* infobar_delegate = infobar->delegate();
2084 2085
2085 if (action == "dismiss") { 2086 if (action == "dismiss") {
2086 infobar_delegate->InfoBarDismissed(); 2087 infobar_delegate->InfoBarDismissed();
2087 infobar_service->RemoveInfoBar(infobar_delegate); 2088 infobar_service->RemoveInfoBar(infobar);
2088 reply.SendSuccess(NULL); 2089 reply.SendSuccess(NULL);
2089 return; 2090 return;
2090 } 2091 }
2091 if ((action == "accept") || (action == "cancel")) { 2092 if ((action == "accept") || (action == "cancel")) {
2092 ConfirmInfoBarDelegate* confirm_infobar_delegate = 2093 ConfirmInfoBarDelegate* confirm_infobar_delegate =
2093 infobar_delegate->AsConfirmInfoBarDelegate(); 2094 infobar_delegate->AsConfirmInfoBarDelegate();
2094 if (!confirm_infobar_delegate) { 2095 if (!confirm_infobar_delegate) {
2095 reply.SendError("Not a confirm infobar"); 2096 reply.SendError("Not a confirm infobar");
2096 return; 2097 return;
2097 } 2098 }
2098 if ((action == "accept") ? 2099 if ((action == "accept") ?
2099 confirm_infobar_delegate->Accept() : confirm_infobar_delegate->Cancel()) 2100 confirm_infobar_delegate->Accept() : confirm_infobar_delegate->Cancel())
2100 infobar_service->RemoveInfoBar(infobar_delegate); 2101 infobar_service->RemoveInfoBar(infobar);
2101 reply.SendSuccess(NULL); 2102 reply.SendSuccess(NULL);
2102 return; 2103 return;
2103 } 2104 }
2104 2105
2105 reply.SendError("Invalid action"); 2106 reply.SendError("Invalid action");
2106 } 2107 }
2107 2108
2108 namespace { 2109 namespace {
2109 2110
2110 // Gets info about BrowserChildProcessHost. Must run on IO thread to 2111 // Gets info about BrowserChildProcessHost. Must run on IO thread to
(...skipping 3341 matching lines...) Expand 10 before | Expand all | Expand 10 after
5452 if (g_browser_process) 5453 if (g_browser_process)
5453 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 5454 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
5454 } 5455 }
5455 5456
5456 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 5457 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
5457 WebContents* tab) { 5458 WebContents* tab) {
5458 TabStripModel* tab_strip = browser->tab_strip_model(); 5459 TabStripModel* tab_strip = browser->tab_strip_model();
5459 if (tab_strip->GetActiveWebContents() != tab) 5460 if (tab_strip->GetActiveWebContents() != tab)
5460 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true); 5461 tab_strip->ActivateTabAt(tab_strip->GetIndexOfWebContents(tab), true);
5461 } 5462 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_interactive_uitest.cc ('k') | chrome/browser/chrome_quota_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698