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

Unified Diff: ios/chrome/browser/passwords/password_controller.mm

Issue 2106353003: Enable Update Password UI on iOS behind a flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_controller
Patch Set: Remove heuristics changes Created 4 years, 5 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
Index: ios/chrome/browser/passwords/password_controller.mm
diff --git a/ios/chrome/browser/passwords/password_controller.mm b/ios/chrome/browser/passwords/password_controller.mm
index fc5d885b3bc2553709c48354ab7457b59e3033a7..3d66ccf8957cf03a9799350e8d0705f9031ab1a7 100644
--- a/ios/chrome/browser/passwords/password_controller.mm
+++ b/ios/chrome/browser/passwords/password_controller.mm
@@ -34,6 +34,7 @@
#include "ios/chrome/browser/experimental_flags.h"
#include "ios/chrome/browser/infobars/infobar_manager_impl.h"
#import "ios/chrome/browser/passwords/ios_chrome_save_password_infobar_delegate.h"
+#import "ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delegate.h"
sdefresne 2016/07/05 13:29:55 I don't see this file in this CL nor in the reposi
Jackie Quinn 2016/07/05 13:52:35 It just landed earlier today: https://codereview.c
#import "ios/chrome/browser/passwords/js_password_manager.h"
#import "ios/chrome/browser/passwords/password_generation_agent.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
@@ -42,6 +43,10 @@
#import "ios/web/public/web_state/web_state.h"
#include "url/gurl.h"
+namespace {
sdefresne 2016/07/05 13:29:55 Please move this after the "using" statements, and
Jackie Quinn 2016/07/05 13:52:35 Done.
+// Types of password infobars to display.
+typedef NS_ENUM(BOOL, PasswordInfoBarType) { SAVE, UPDATE };
sdefresne 2016/07/05 13:29:55 Since this is internal only and in an anonymous na
Jackie Quinn 2016/07/05 13:52:34 Done.
+}
using password_manager::PasswordFormManager;
using password_manager::PasswordGenerationManager;
using password_manager::PasswordManager;
@@ -106,6 +111,12 @@ using password_manager::PasswordManagerDriver;
fromDictionary:(const base::DictionaryValue*)dictionary
pageURL:(const GURL&)pageLocation;
+// Displays infobar for |form| with |type|. If |type| is UPDATE, the user
+// is prompted to update the password. If |type| is SAVE, the user is prompted
+// to save the password.
+- (void)showInfoBarForForm:(std::unique_ptr<PasswordFormManager>)form
+ infoBarType:(PasswordInfoBarType)type;
+
@end
namespace {
@@ -616,6 +627,18 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
}
}
+#pragma mark - PasswordManagerClientDelegate
+
+- (void)showSavePasswordInfoBar:
+ (std::unique_ptr<PasswordFormManager>)formToSave {
+ [self showInfoBarForForm:std::move(formToSave) infoBarType:SAVE];
+}
+
+- (void)showUpdatePasswordInfoBar:
+ (std::unique_ptr<PasswordFormManager>)formToUpdate {
+ [self showInfoBarForForm:std::move(formToUpdate) infoBarType:UPDATE];
+}
+
#pragma mark -
#pragma mark WebPasswordFormData Adaptation
@@ -754,26 +777,6 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
return YES;
}
-- (void)showSavePasswordInfoBar:
- (std::unique_ptr<PasswordFormManager>)formToSave {
- if (!webStateObserverBridge_ || !webStateObserverBridge_->web_state())
- return;
-
- bool isSmartLockBrandingEnabled = false;
- if (self.browserState) {
- sync_driver::SyncService* sync_service =
- IOSChromeProfileSyncServiceFactory::GetForBrowserState(
- self.browserState);
- isSmartLockBrandingEnabled =
- password_bubble_experiment::IsSmartLockBrandingSavePromptEnabled(
- sync_service);
- }
- infobars::InfoBarManager* infoBarManager =
- InfoBarManagerImpl::FromWebState(webStateObserverBridge_->web_state());
- IOSChromeSavePasswordInfoBarDelegate::Create(
- isSmartLockBrandingEnabled, infoBarManager, std::move(formToSave));
-}
-
- (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData
withUsername:(const base::string16&)username
password:(const base::string16&)password
@@ -829,4 +832,40 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
return passwordJsManager_;
}
+#pragma mark - Private methods
+
+- (void)showInfoBarForForm:(std::unique_ptr<PasswordFormManager>)form
+ infoBarType:(PasswordInfoBarType)type {
+ if (!webStateObserverBridge_ || !webStateObserverBridge_->web_state())
+ return;
+
+ bool isSmartLockBrandingEnabled = false;
+ if (self.browserState) {
+ sync_driver::SyncService* sync_service =
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(
+ self.browserState);
+ isSmartLockBrandingEnabled =
+ password_bubble_experiment::IsSmartLockBrandingSavePromptEnabled(
+ sync_service);
+ }
+ infobars::InfoBarManager* infoBarManager =
+ InfoBarManagerImpl::FromWebState(webStateObserverBridge_->web_state());
+
+ switch (type) {
+ case SAVE:
+ IOSChromeSavePasswordInfoBarDelegate::Create(
+ isSmartLockBrandingEnabled, infoBarManager, std::move(form));
+ break;
+
+ case UPDATE:
+ IOSChromeUpdatePasswordInfoBarDelegate::Create(
+ isSmartLockBrandingEnabled, infoBarManager, std::move(form));
+ break;
+
+ default:
sdefresne 2016/07/05 13:29:55 If you use C++ enum or enum class, then you should
Jackie Quinn 2016/07/05 13:52:34 Done.
+ NOTREACHED();
+ break;
+ }
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698