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

Side by Side Diff: ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delegate.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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delega te.h" 5 #include "ios/chrome/browser/passwords/ios_chrome_update_password_infobar_delega te.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/infobars/core/infobar.h" 13 #include "components/infobars/core/infobar.h"
14 #include "components/infobars/core/infobar_manager.h" 14 #include "components/infobars/core/infobar_manager.h"
15 #include "components/password_manager/core/browser/password_form_manager.h" 15 #include "components/password_manager/core/browser/password_form_manager.h"
16 #include "components/password_manager/core/browser/password_manager_constants.h" 16 #include "components/password_manager/core/browser/password_manager_constants.h"
17 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
18 #include "ios/chrome/browser/infobars/infobar.h" 18 #include "ios/chrome/browser/infobars/infobar.h"
19 #import "ios/chrome/browser/passwords/update_password_infobar_controller.h" 19 #import "ios/chrome/browser/passwords/update_password_infobar_controller.h"
20 #include "ios/chrome/grit/ios_chromium_strings.h" 20 #include "ios/chrome/grit/ios_chromium_strings.h"
21 #include "ios/chrome/grit/ios_strings.h" 21 #include "ios/chrome/grit/ios_strings.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 23
24 using password_manager::PasswordFormManager; 24 using password_manager::PasswordFormManager;
25 25
26 // static 26 // static
27 void IOSChromeUpdatePasswordInfoBarDelegate::Create( 27 void IOSChromeUpdatePasswordInfoBarDelegate::Create(
28 bool is_smart_lock_branding_enabled, 28 bool is_smart_lock_branding_enabled,
29 infobars::InfoBarManager* infobar_manager, 29 infobars::InfoBarManager* infobar_manager,
30 std::unique_ptr<PasswordFormManager> form_manager) { 30 scoped_refptr<PasswordFormManager> form_manager) {
31 DCHECK(infobar_manager); 31 DCHECK(infobar_manager);
32 auto delegate = base::WrapUnique(new IOSChromeUpdatePasswordInfoBarDelegate( 32 auto delegate = base::WrapUnique(new IOSChromeUpdatePasswordInfoBarDelegate(
33 is_smart_lock_branding_enabled, std::move(form_manager))); 33 is_smart_lock_branding_enabled, std::move(form_manager)));
34 std::unique_ptr<InfoBarIOS> infobar(new InfoBarIOS(std::move(delegate))); 34 std::unique_ptr<InfoBarIOS> infobar(new InfoBarIOS(std::move(delegate)));
35 base::scoped_nsobject<UpdatePasswordInfoBarController> controller( 35 base::scoped_nsobject<UpdatePasswordInfoBarController> controller(
36 [[UpdatePasswordInfoBarController alloc] initWithDelegate:infobar.get()]); 36 [[UpdatePasswordInfoBarController alloc] initWithDelegate:infobar.get()]);
37 infobar->SetController(controller); 37 infobar->SetController(controller);
38 infobar_manager->AddInfoBar(std::move(infobar)); 38 infobar_manager->AddInfoBar(std::move(infobar));
39 } 39 }
40 40
41 IOSChromeUpdatePasswordInfoBarDelegate:: 41 IOSChromeUpdatePasswordInfoBarDelegate::
42 ~IOSChromeUpdatePasswordInfoBarDelegate() {} 42 ~IOSChromeUpdatePasswordInfoBarDelegate() {}
43 43
44 IOSChromeUpdatePasswordInfoBarDelegate::IOSChromeUpdatePasswordInfoBarDelegate( 44 IOSChromeUpdatePasswordInfoBarDelegate::IOSChromeUpdatePasswordInfoBarDelegate(
45 bool is_smart_lock_branding_enabled, 45 bool is_smart_lock_branding_enabled,
46 std::unique_ptr<PasswordFormManager> form_manager) 46 scoped_refptr<PasswordFormManager> form_manager)
47 : IOSChromePasswordManagerInfoBarDelegate(is_smart_lock_branding_enabled, 47 : IOSChromePasswordManagerInfoBarDelegate(is_smart_lock_branding_enabled,
48 std::move(form_manager)) { 48 std::move(form_manager)) {
49 selected_account_ = form_to_save()->preferred_match()->username_value; 49 selected_account_ = form_to_save()->preferred_match()->username_value;
50 } 50 }
51 51
52 bool IOSChromeUpdatePasswordInfoBarDelegate::ShowMultipleAccounts() const { 52 bool IOSChromeUpdatePasswordInfoBarDelegate::ShowMultipleAccounts() const {
53 // If a password is overriden, we know that the preferred match account is 53 // If a password is overriden, we know that the preferred match account is
54 // correct, so should not provide the option to choose a different account. 54 // correct, so should not provide the option to choose a different account.
55 return form_to_save()->best_matches().size() > 1 && 55 return form_to_save()->best_matches().size() > 1 &&
56 !form_to_save()->password_overridden(); 56 !form_to_save()->password_overridden();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool IOSChromeUpdatePasswordInfoBarDelegate::Accept() { 98 bool IOSChromeUpdatePasswordInfoBarDelegate::Accept() {
99 DCHECK(form_to_save()); 99 DCHECK(form_to_save());
100 if (ShowMultipleAccounts()) { 100 if (ShowMultipleAccounts()) {
101 form_to_save()->Update( 101 form_to_save()->Update(
102 *form_to_save()->best_matches().at(selected_account_)); 102 *form_to_save()->best_matches().at(selected_account_));
103 } else { 103 } else {
104 form_to_save()->Update(form_to_save()->pending_credentials()); 104 form_to_save()->Update(form_to_save()->pending_credentials());
105 } 105 }
106 return true; 106 return true;
107 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698