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

Unified Diff: chrome/browser/password_manager/password_manager_delegate_impl.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/omnibox_search_hint.cc ('k') | chrome/browser/pepper_broker_infobar_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/password_manager_delegate_impl.cc
===================================================================
--- chrome/browser/password_manager/password_manager_delegate_impl.cc (revision 175396)
+++ chrome/browser/password_manager/password_manager_delegate_impl.cc (working copy)
@@ -38,8 +38,10 @@
// forms never end up in an infobar.
class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- SavePasswordInfoBarDelegate(InfoBarService* infobar_service,
- PasswordFormManager* form_to_save);
+ // If we won't be showing the one-click signin infobar, creates a save
+ // password delegate and adds it to the InfoBarService for |web_contents|.
+ static void Create(content::WebContents* web_contents,
+ PasswordFormManager* form_to_save);
private:
enum ResponseType {
@@ -49,6 +51,8 @@
NUM_RESPONSE_TYPES,
};
+ SavePasswordInfoBarDelegate(InfoBarService* infobar_service,
+ PasswordFormManager* form_to_save);
virtual ~SavePasswordInfoBarDelegate();
// ConfirmInfoBarDelegate
@@ -71,6 +75,32 @@
DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate);
};
+// static
+void SavePasswordInfoBarDelegate::Create(content::WebContents* web_contents,
+ PasswordFormManager* form_to_save) {
+#if defined(ENABLE_ONE_CLICK_SIGNIN)
+ // Don't show the password manager infobar if this form is for a google
+ // account and we are going to show the one-click singin infobar.
+ // For now, one-click signin is fully implemented only on windows.
+ GURL realm(form_to_save->realm());
+ // TODO(mathp): Checking only against associated_username() causes a bug
+ // referenced here: crbug.com/133275
+ if ((realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm()) ||
+ realm == GURL("https://www.google.com/")) &&
+ OneClickSigninHelper::CanOffer(
+ web_contents,
+ OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY,
+ UTF16ToUTF8(form_to_save->associated_username()), NULL)) {
+ return;
+ }
+#endif
+
+ InfoBarService* infobar_service =
+ InfoBarService::FromWebContents(web_contents);
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
+ new SavePasswordInfoBarDelegate(infobar_service, form_to_save)));
+}
+
SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
InfoBarService* infobar_service,
PasswordFormManager* form_to_save)
@@ -147,26 +177,7 @@
void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted(
PasswordFormManager* form_to_save) {
- // Don't show the password manager infobar if this form is for a google
- // account and we are going to show the one-click singin infobar.
- // For now, one-click signin is fully implemented only on windows.
-#if defined(ENABLE_ONE_CLICK_SIGNIN)
- GURL realm(form_to_save->realm());
- // TODO(mathp): Checking only against associated_username() causes a bug
- // referenced here: crbug.com/133275
- if ((realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm()) ||
- realm == GURL("https://www.google.com/")) &&
- OneClickSigninHelper::CanOffer(web_contents_,
- OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY,
- UTF16ToUTF8(form_to_save->associated_username()), NULL)) {
- return;
- }
-#endif
-
- InfoBarService* infobar_service =
- InfoBarService::FromWebContents(web_contents_);
- infobar_service->AddInfoBar(
- new SavePasswordInfoBarDelegate(infobar_service, form_to_save));
+ SavePasswordInfoBarDelegate::Create(web_contents_, form_to_save);
}
Profile* PasswordManagerDelegateImpl::GetProfile() {
« no previous file with comments | « chrome/browser/omnibox_search_hint.cc ('k') | chrome/browser/pepper_broker_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698