OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ios_chrome_save_password_infobar_delegate.
h" | 5 #import "ios/chrome/browser/passwords/ios_chrome_save_password_infobar_delegate.
h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
11 #include "components/infobars/core/infobar_manager.h" | 11 #include "components/infobars/core/infobar_manager.h" |
12 #include "components/password_manager/core/browser/password_form_manager.h" | 12 #include "components/password_manager/core/browser/password_form_manager.h" |
13 #include "components/password_manager/core/browser/password_manager_constants.h" | 13 #include "components/password_manager/core/browser/password_manager_constants.h" |
14 #include "components/strings/grit/components_strings.h" | 14 #include "components/strings/grit/components_strings.h" |
15 #include "ios/chrome/grit/ios_chromium_strings.h" | 15 #include "ios/chrome/grit/ios_chromium_strings.h" |
16 #include "ios/chrome/grit/ios_strings.h" | 16 #include "ios/chrome/grit/ios_strings.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 | 18 |
19 using password_manager::PasswordFormManager; | 19 using password_manager::PasswordFormManager; |
20 | 20 |
21 // static | 21 // static |
22 void IOSChromeSavePasswordInfoBarDelegate::Create( | 22 void IOSChromeSavePasswordInfoBarDelegate::Create( |
23 bool is_smart_lock_branding_enabled, | 23 bool is_smart_lock_branding_enabled, |
24 infobars::InfoBarManager* infobar_manager, | 24 infobars::InfoBarManager* infobar_manager, |
25 std::unique_ptr<PasswordFormManager> form_to_save) { | 25 scoped_refptr<PasswordFormManager> form_to_save) { |
26 DCHECK(infobar_manager); | 26 DCHECK(infobar_manager); |
27 auto delegate = base::WrapUnique(new IOSChromeSavePasswordInfoBarDelegate( | 27 auto delegate = base::WrapUnique(new IOSChromeSavePasswordInfoBarDelegate( |
28 is_smart_lock_branding_enabled, std::move(form_to_save))); | 28 is_smart_lock_branding_enabled, std::move(form_to_save))); |
29 infobar_manager->AddInfoBar( | 29 infobar_manager->AddInfoBar( |
30 infobar_manager->CreateConfirmInfoBar(std::move(delegate))); | 30 infobar_manager->CreateConfirmInfoBar(std::move(delegate))); |
31 } | 31 } |
32 | 32 |
33 IOSChromeSavePasswordInfoBarDelegate::~IOSChromeSavePasswordInfoBarDelegate() {} | 33 IOSChromeSavePasswordInfoBarDelegate::~IOSChromeSavePasswordInfoBarDelegate() {} |
34 | 34 |
35 IOSChromeSavePasswordInfoBarDelegate::IOSChromeSavePasswordInfoBarDelegate( | 35 IOSChromeSavePasswordInfoBarDelegate::IOSChromeSavePasswordInfoBarDelegate( |
36 bool is_smart_lock_branding_enabled, | 36 bool is_smart_lock_branding_enabled, |
37 std::unique_ptr<PasswordFormManager> form_to_save) | 37 scoped_refptr<PasswordFormManager> form_to_save) |
38 : IOSChromePasswordManagerInfoBarDelegate(is_smart_lock_branding_enabled, | 38 : IOSChromePasswordManagerInfoBarDelegate(is_smart_lock_branding_enabled, |
39 std::move(form_to_save)) {} | 39 std::move(form_to_save)) {} |
40 | 40 |
41 infobars::InfoBarDelegate::InfoBarIdentifier | 41 infobars::InfoBarDelegate::InfoBarIdentifier |
42 IOSChromeSavePasswordInfoBarDelegate::GetIdentifier() const { | 42 IOSChromeSavePasswordInfoBarDelegate::GetIdentifier() const { |
43 return IOS_CHROME_SAVE_PASSWORD_INFOBAR_DELEGATE; | 43 return IOS_CHROME_SAVE_PASSWORD_INFOBAR_DELEGATE; |
44 } | 44 } |
45 | 45 |
46 base::string16 IOSChromeSavePasswordInfoBarDelegate::GetMessageText() const { | 46 base::string16 IOSChromeSavePasswordInfoBarDelegate::GetMessageText() const { |
47 if (is_smart_lock_branding_enabled()) { | 47 if (is_smart_lock_branding_enabled()) { |
(...skipping 17 matching lines...) Expand all Loading... |
65 set_infobar_response(password_manager::metrics_util::CLICKED_SAVE); | 65 set_infobar_response(password_manager::metrics_util::CLICKED_SAVE); |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 bool IOSChromeSavePasswordInfoBarDelegate::Cancel() { | 69 bool IOSChromeSavePasswordInfoBarDelegate::Cancel() { |
70 DCHECK(form_to_save()); | 70 DCHECK(form_to_save()); |
71 form_to_save()->PermanentlyBlacklist(); | 71 form_to_save()->PermanentlyBlacklist(); |
72 set_infobar_response(password_manager::metrics_util::CLICKED_NEVER); | 72 set_infobar_response(password_manager::metrics_util::CLICKED_NEVER); |
73 return true; | 73 return true; |
74 } | 74 } |
OLD | NEW |