| OLD | NEW |
| 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> |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Takes values from a JSON |dictionary| and populates the |form|. | 111 // Takes values from a JSON |dictionary| and populates the |form|. |
| 112 // The |pageLocation| is the URL of the current page. | 112 // The |pageLocation| is the URL of the current page. |
| 113 // Returns YES if the form was correctly populated, NO otherwise. | 113 // Returns YES if the form was correctly populated, NO otherwise. |
| 114 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form | 114 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form |
| 115 fromDictionary:(const base::DictionaryValue*)dictionary | 115 fromDictionary:(const base::DictionaryValue*)dictionary |
| 116 pageURL:(const GURL&)pageLocation; | 116 pageURL:(const GURL&)pageLocation; |
| 117 | 117 |
| 118 // Displays infobar for |form| with |type|. If |type| is UPDATE, the user | 118 // 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 | 119 // is prompted to update the password. If |type| is SAVE, the user is prompted |
| 120 // to save the password. | 120 // to save the password. |
| 121 - (void)showInfoBarForForm:(std::unique_ptr<PasswordFormManager>)form | 121 - (void)showInfoBarForForm:(scoped_refptr<PasswordFormManager>)form |
| 122 infoBarType:(PasswordInfoBarType)type; | 122 infoBarType:(PasswordInfoBarType)type; |
| 123 | 123 |
| 124 @end | 124 @end |
| 125 | 125 |
| 126 namespace { | 126 namespace { |
| 127 | 127 |
| 128 // Constructs an array of FormSuggestions, each corresponding to a username/ | 128 // Constructs an array of FormSuggestions, each corresponding to a username/ |
| 129 // password pair in |formFillData|, such that |prefix| is a prefix of the | 129 // password pair in |formFillData|, such that |prefix| is a prefix of the |
| 130 // username of each suggestion. | 130 // username of each suggestion. |
| 131 NSArray* BuildSuggestions(const autofill::PasswordFormFillData& formFillData, | 131 NSArray* BuildSuggestions(const autofill::PasswordFormFillData& formFillData, |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 completionHandler:^(BOOL success) { | 635 completionHandler:^(BOOL success) { |
| 636 completion(); | 636 completion(); |
| 637 }]; | 637 }]; |
| 638 } else { | 638 } else { |
| 639 completion(); | 639 completion(); |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 | 642 |
| 643 #pragma mark - PasswordManagerClientDelegate | 643 #pragma mark - PasswordManagerClientDelegate |
| 644 | 644 |
| 645 - (void)showSavePasswordInfoBar: | 645 - (void)showSavePasswordInfoBar:(scoped_refptr<PasswordFormManager>)formToSave { |
| 646 (std::unique_ptr<PasswordFormManager>)formToSave { | |
| 647 [self showInfoBarForForm:std::move(formToSave) | 646 [self showInfoBarForForm:std::move(formToSave) |
| 648 infoBarType:PasswordInfoBarType::SAVE]; | 647 infoBarType:PasswordInfoBarType::SAVE]; |
| 649 } | 648 } |
| 650 | 649 |
| 651 - (void)showUpdatePasswordInfoBar: | 650 - (void)showUpdatePasswordInfoBar: |
| 652 (std::unique_ptr<PasswordFormManager>)formToUpdate { | 651 (scoped_refptr<PasswordFormManager>)formToUpdate { |
| 653 [self showInfoBarForForm:std::move(formToUpdate) | 652 [self showInfoBarForForm:std::move(formToUpdate) |
| 654 infoBarType:PasswordInfoBarType::UPDATE]; | 653 infoBarType:PasswordInfoBarType::UPDATE]; |
| 655 } | 654 } |
| 656 | 655 |
| 657 #pragma mark - | 656 #pragma mark - |
| 658 #pragma mark WebPasswordFormData Adaptation | 657 #pragma mark WebPasswordFormData Adaptation |
| 659 | 658 |
| 660 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form | 659 - (BOOL)getPasswordForm:(autofill::PasswordForm*)form |
| 661 fromDictionary:(const base::DictionaryValue*)dictionary | 660 fromDictionary:(const base::DictionaryValue*)dictionary |
| 662 pageURL:(const GURL&)pageLocation { | 661 pageURL:(const GURL&)pageLocation { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 - (PasswordManager*)passwordManager { | 844 - (PasswordManager*)passwordManager { |
| 846 return passwordManager_.get(); | 845 return passwordManager_.get(); |
| 847 } | 846 } |
| 848 | 847 |
| 849 - (JsPasswordManager*)passwordJsManager { | 848 - (JsPasswordManager*)passwordJsManager { |
| 850 return passwordJsManager_; | 849 return passwordJsManager_; |
| 851 } | 850 } |
| 852 | 851 |
| 853 #pragma mark - Private methods | 852 #pragma mark - Private methods |
| 854 | 853 |
| 855 - (void)showInfoBarForForm:(std::unique_ptr<PasswordFormManager>)form | 854 - (void)showInfoBarForForm:(scoped_refptr<PasswordFormManager>)form |
| 856 infoBarType:(PasswordInfoBarType)type { | 855 infoBarType:(PasswordInfoBarType)type { |
| 857 if (!webStateObserverBridge_ || !webStateObserverBridge_->web_state()) | 856 if (!webStateObserverBridge_ || !webStateObserverBridge_->web_state()) |
| 858 return; | 857 return; |
| 859 | 858 |
| 860 bool isSmartLockBrandingEnabled = false; | 859 bool isSmartLockBrandingEnabled = false; |
| 861 if (self.browserState) { | 860 if (self.browserState) { |
| 862 syncer::SyncService* sync_service = | 861 syncer::SyncService* sync_service = |
| 863 IOSChromeProfileSyncServiceFactory::GetForBrowserState( | 862 IOSChromeProfileSyncServiceFactory::GetForBrowserState( |
| 864 self.browserState); | 863 self.browserState); |
| 865 isSmartLockBrandingEnabled = | 864 isSmartLockBrandingEnabled = |
| 866 password_bubble_experiment::IsSmartLockUser(sync_service); | 865 password_bubble_experiment::IsSmartLockUser(sync_service); |
| 867 } | 866 } |
| 868 infobars::InfoBarManager* infoBarManager = | 867 infobars::InfoBarManager* infoBarManager = |
| 869 InfoBarManagerImpl::FromWebState(webStateObserverBridge_->web_state()); | 868 InfoBarManagerImpl::FromWebState(webStateObserverBridge_->web_state()); |
| 870 | 869 |
| 871 switch (type) { | 870 switch (type) { |
| 872 case PasswordInfoBarType::SAVE: | 871 case PasswordInfoBarType::SAVE: |
| 873 IOSChromeSavePasswordInfoBarDelegate::Create( | 872 IOSChromeSavePasswordInfoBarDelegate::Create( |
| 874 isSmartLockBrandingEnabled, infoBarManager, std::move(form)); | 873 isSmartLockBrandingEnabled, infoBarManager, std::move(form)); |
| 875 break; | 874 break; |
| 876 | 875 |
| 877 case PasswordInfoBarType::UPDATE: | 876 case PasswordInfoBarType::UPDATE: |
| 878 IOSChromeUpdatePasswordInfoBarDelegate::Create( | 877 IOSChromeUpdatePasswordInfoBarDelegate::Create( |
| 879 isSmartLockBrandingEnabled, infoBarManager, std::move(form)); | 878 isSmartLockBrandingEnabled, infoBarManager, std::move(form)); |
| 880 break; | 879 break; |
| 881 } | 880 } |
| 882 } | 881 } |
| 883 | 882 |
| 884 @end | 883 @end |
| OLD | NEW |