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

Side by Side Diff: ios/chrome/browser/passwords/password_controller.mm

Issue 2900693002: [Password Manager] Convert |pending_login_managers_| to an array of scoped_refptr (Closed)
Patch Set: Rebase Created 3 years, 6 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
« no previous file with comments | « ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delegate.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/chrome/browser/passwords/password_controller.h" 5 #import "ios/chrome/browser/passwords/password_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #import "base/ios/weak_nsobject.h" 15 #import "base/ios/weak_nsobject.h"
16 #include "base/json/json_reader.h" 16 #include "base/json/json_reader.h"
17 #include "base/json/json_writer.h" 17 #include "base/json/json_writer.h"
18 #include "base/mac/foundation_util.h" 18 #include "base/mac/foundation_util.h"
19 #include "base/mac/scoped_nsobject.h" 19 #include "base/mac/scoped_nsobject.h"
20 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
21 #include "base/memory/ref_counted.h"
21 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
22 #include "base/strings/sys_string_conversions.h" 23 #include "base/strings/sys_string_conversions.h"
23 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
24 #include "base/values.h" 25 #include "base/values.h"
25 #include "components/autofill/core/common/password_form.h" 26 #include "components/autofill/core/common/password_form.h"
26 #include "components/autofill/core/common/password_form_fill_data.h" 27 #include "components/autofill/core/common/password_form_fill_data.h"
27 #include "components/browser_sync/profile_sync_service.h" 28 #include "components/browser_sync/profile_sync_service.h"
28 #include "components/infobars/core/infobar_manager.h" 29 #include "components/infobars/core/infobar_manager.h"
29 #include "components/password_manager/core/browser/password_bubble_experiment.h" 30 #include "components/password_manager/core/browser/password_bubble_experiment.h"
30 #include "components/password_manager/core/browser/password_generation_manager.h " 31 #include "components/password_manager/core/browser/password_generation_manager.h "
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Takes values from a JSON |dictionary| and populates the |form|. 112 // Takes values from a JSON |dictionary| and populates the |form|.
112 // The |pageLocation| is the URL of the current page. 113 // The |pageLocation| is the URL of the current page.
113 // Returns YES if the form was correctly populated, NO otherwise. 114 // Returns YES if the form was correctly populated, NO otherwise.
114 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form 115 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form
115 fromDictionary:(const base::DictionaryValue*)dictionary 116 fromDictionary:(const base::DictionaryValue*)dictionary
116 pageURL:(const GURL&)pageLocation; 117 pageURL:(const GURL&)pageLocation;
117 118
118 // Displays infobar for |form| with |type|. If |type| is UPDATE, the user 119 // Displays infobar for |form| with |type|. If |type| is UPDATE, the user
119 // is prompted to update the password. If |type| is SAVE, the user is prompted 120 // is prompted to update the password. If |type| is SAVE, the user is prompted
120 // to save the password. 121 // to save the password.
121 - (void)showInfoBarForForm:(std::unique_ptr<PasswordFormManager>)form 122 - (void)showInfoBarForForm:(scoped_refptr<PasswordFormManager>)form
122 infoBarType:(PasswordInfoBarType)type; 123 infoBarType:(PasswordInfoBarType)type;
123 124
124 @end 125 @end
125 126
126 namespace { 127 namespace {
127 128
128 // Constructs an array of FormSuggestions, each corresponding to a username/ 129 // Constructs an array of FormSuggestions, each corresponding to a username/
129 // password pair in |formFillData|, such that |prefix| is a prefix of the 130 // password pair in |formFillData|, such that |prefix| is a prefix of the
130 // username of each suggestion. 131 // username of each suggestion.
131 NSArray* BuildSuggestions(const autofill::PasswordFormFillData& formFillData, 132 NSArray* BuildSuggestions(const autofill::PasswordFormFillData& formFillData,
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 completionHandler:^(BOOL success) { 636 completionHandler:^(BOOL success) {
636 completion(); 637 completion();
637 }]; 638 }];
638 } else { 639 } else {
639 completion(); 640 completion();
640 } 641 }
641 } 642 }
642 643
643 #pragma mark - PasswordManagerClientDelegate 644 #pragma mark - PasswordManagerClientDelegate
644 645
645 - (void)showSavePasswordInfoBar: 646 - (void)showSavePasswordInfoBar:(scoped_refptr<PasswordFormManager>)formToSave {
646 (std::unique_ptr<PasswordFormManager>)formToSave {
647 [self showInfoBarForForm:std::move(formToSave) 647 [self showInfoBarForForm:std::move(formToSave)
648 infoBarType:PasswordInfoBarType::SAVE]; 648 infoBarType:PasswordInfoBarType::SAVE];
649 } 649 }
650 650
651 - (void)showUpdatePasswordInfoBar: 651 - (void)showUpdatePasswordInfoBar:
652 (std::unique_ptr<PasswordFormManager>)formToUpdate { 652 (scoped_refptr<PasswordFormManager>)formToUpdate {
653 [self showInfoBarForForm:std::move(formToUpdate) 653 [self showInfoBarForForm:std::move(formToUpdate)
654 infoBarType:PasswordInfoBarType::UPDATE]; 654 infoBarType:PasswordInfoBarType::UPDATE];
655 } 655 }
656 656
657 #pragma mark - 657 #pragma mark -
658 #pragma mark WebPasswordFormData Adaptation 658 #pragma mark WebPasswordFormData Adaptation
659 659
660 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form 660 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form
661 fromDictionary:(const base::DictionaryValue*)dictionary 661 fromDictionary:(const base::DictionaryValue*)dictionary
662 pageURL:(const GURL&)pageLocation { 662 pageURL:(const GURL&)pageLocation {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 - (PasswordManager*)passwordManager { 845 - (PasswordManager*)passwordManager {
846 return passwordManager_.get(); 846 return passwordManager_.get();
847 } 847 }
848 848
849 - (JsPasswordManager*)passwordJsManager { 849 - (JsPasswordManager*)passwordJsManager {
850 return passwordJsManager_; 850 return passwordJsManager_;
851 } 851 }
852 852
853 #pragma mark - Private methods 853 #pragma mark - Private methods
854 854
855 - (void)showInfoBarForForm:(std::unique_ptr<PasswordFormManager>)form 855 - (void)showInfoBarForForm:(scoped_refptr<PasswordFormManager>)form
856 infoBarType:(PasswordInfoBarType)type { 856 infoBarType:(PasswordInfoBarType)type {
857 if (!webStateObserverBridge_ || !webStateObserverBridge_->web_state()) 857 if (!webStateObserverBridge_ || !webStateObserverBridge_->web_state())
858 return; 858 return;
859 859
860 bool isSmartLockBrandingEnabled = false; 860 bool isSmartLockBrandingEnabled = false;
861 if (self.browserState) { 861 if (self.browserState) {
862 syncer::SyncService* sync_service = 862 syncer::SyncService* sync_service =
863 IOSChromeProfileSyncServiceFactory::GetForBrowserState( 863 IOSChromeProfileSyncServiceFactory::GetForBrowserState(
864 self.browserState); 864 self.browserState);
865 isSmartLockBrandingEnabled = 865 isSmartLockBrandingEnabled =
866 password_bubble_experiment::IsSmartLockUser(sync_service); 866 password_bubble_experiment::IsSmartLockUser(sync_service);
867 } 867 }
868 infobars::InfoBarManager* infoBarManager = 868 infobars::InfoBarManager* infoBarManager =
869 InfoBarManagerImpl::FromWebState(webStateObserverBridge_->web_state()); 869 InfoBarManagerImpl::FromWebState(webStateObserverBridge_->web_state());
870 870
871 switch (type) { 871 switch (type) {
872 case PasswordInfoBarType::SAVE: 872 case PasswordInfoBarType::SAVE:
873 IOSChromeSavePasswordInfoBarDelegate::Create( 873 IOSChromeSavePasswordInfoBarDelegate::Create(
874 isSmartLockBrandingEnabled, infoBarManager, std::move(form)); 874 isSmartLockBrandingEnabled, infoBarManager, std::move(form));
875 break; 875 break;
876 876
877 case PasswordInfoBarType::UPDATE: 877 case PasswordInfoBarType::UPDATE:
878 IOSChromeUpdatePasswordInfoBarDelegate::Create( 878 IOSChromeUpdatePasswordInfoBarDelegate::Create(
879 isSmartLockBrandingEnabled, infoBarManager, std::move(form)); 879 isSmartLockBrandingEnabled, infoBarManager, std::move(form));
880 break; 880 break;
881 } 881 }
882 } 882 }
883 883
884 @end 884 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delegate.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698