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

Side by Side Diff: chrome/browser/password_manager/update_password_infobar_delegate.cc

Issue 1858513002: chrome/browser/password_manager: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows -- revert unwanted change Created 4 years, 8 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 | « chrome/browser/password_manager/update_password_infobar_delegate.h ('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 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 "chrome/browser/password_manager/update_password_infobar_delegate.h" 5 #include "chrome/browser/password_manager/update_password_infobar_delegate.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
8 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/profile_sync_service_factory.h" 12 #include "chrome/browser/sync/profile_sync_service_factory.h"
12 #include "chrome/browser/ui/android/infobars/update_password_infobar.h" 13 #include "chrome/browser/ui/android/infobars/update_password_infobar.h"
13 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 14 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
14 #include "chrome/grit/chromium_strings.h" 15 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
16 #include "components/browser_sync/browser/profile_sync_service.h" 17 #include "components/browser_sync/browser/profile_sync_service.h"
17 #include "components/infobars/core/infobar.h" 18 #include "components/infobars/core/infobar.h"
18 #include "components/password_manager/core/browser/password_bubble_experiment.h" 19 #include "components/password_manager/core/browser/password_bubble_experiment.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 22
22 // static 23 // static
23 void UpdatePasswordInfoBarDelegate::Create( 24 void UpdatePasswordInfoBarDelegate::Create(
24 content::WebContents* web_contents, 25 content::WebContents* web_contents,
25 scoped_ptr<password_manager::PasswordFormManager> form_to_save) { 26 std::unique_ptr<password_manager::PasswordFormManager> form_to_save) {
26 const bool is_smartlock_branding_enabled = 27 const bool is_smartlock_branding_enabled =
27 password_bubble_experiment::IsSmartLockBrandingEnabled( 28 password_bubble_experiment::IsSmartLockBrandingEnabled(
28 ProfileSyncServiceFactory::GetForProfile( 29 ProfileSyncServiceFactory::GetForProfile(
29 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); 30 Profile::FromBrowserContext(web_contents->GetBrowserContext())));
30 InfoBarService::FromWebContents(web_contents) 31 InfoBarService::FromWebContents(web_contents)
31 ->AddInfoBar(make_scoped_ptr(new UpdatePasswordInfoBar( 32 ->AddInfoBar(base::WrapUnique(new UpdatePasswordInfoBar(
32 make_scoped_ptr(new UpdatePasswordInfoBarDelegate( 33 base::WrapUnique(new UpdatePasswordInfoBarDelegate(
33 web_contents, std::move(form_to_save), 34 web_contents, std::move(form_to_save),
34 is_smartlock_branding_enabled))))); 35 is_smartlock_branding_enabled)))));
35 } 36 }
36 37
37 UpdatePasswordInfoBarDelegate::~UpdatePasswordInfoBarDelegate() {} 38 UpdatePasswordInfoBarDelegate::~UpdatePasswordInfoBarDelegate() {}
38 39
39 base::string16 UpdatePasswordInfoBarDelegate::GetBranding() const { 40 base::string16 UpdatePasswordInfoBarDelegate::GetBranding() const {
40 return l10n_util::GetStringUTF16( 41 return l10n_util::GetStringUTF16(
41 is_smartlock_branding_enabled_ 42 is_smartlock_branding_enabled_
42 ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS 43 ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS
43 : IDS_PASSWORD_MANAGER_TITLE_BRAND); 44 : IDS_PASSWORD_MANAGER_TITLE_BRAND);
44 } 45 }
45 46
46 bool UpdatePasswordInfoBarDelegate::ShowMultipleAccounts() const { 47 bool UpdatePasswordInfoBarDelegate::ShowMultipleAccounts() const {
47 const password_manager::PasswordFormManager* form_manager = 48 const password_manager::PasswordFormManager* form_manager =
48 passwords_state_.form_manager(); 49 passwords_state_.form_manager();
49 bool is_password_overriden = 50 bool is_password_overriden =
50 form_manager && form_manager->password_overridden(); 51 form_manager && form_manager->password_overridden();
51 return GetCurrentForms().size() > 1 && !is_password_overriden; 52 return GetCurrentForms().size() > 1 && !is_password_overriden;
52 } 53 }
53 54
54 const std::vector<const autofill::PasswordForm*>& 55 const std::vector<const autofill::PasswordForm*>&
55 UpdatePasswordInfoBarDelegate::GetCurrentForms() const { 56 UpdatePasswordInfoBarDelegate::GetCurrentForms() const {
56 return passwords_state_.GetCurrentForms(); 57 return passwords_state_.GetCurrentForms();
57 } 58 }
58 59
59 UpdatePasswordInfoBarDelegate::UpdatePasswordInfoBarDelegate( 60 UpdatePasswordInfoBarDelegate::UpdatePasswordInfoBarDelegate(
60 content::WebContents* web_contents, 61 content::WebContents* web_contents,
61 scoped_ptr<password_manager::PasswordFormManager> form_to_update, 62 std::unique_ptr<password_manager::PasswordFormManager> form_to_update,
62 bool is_smartlock_branding_enabled) 63 bool is_smartlock_branding_enabled)
63 : is_smartlock_branding_enabled_(is_smartlock_branding_enabled) { 64 : is_smartlock_branding_enabled_(is_smartlock_branding_enabled) {
64 // TODO(melandory): Add histograms, crbug.com/577129 65 // TODO(melandory): Add histograms, crbug.com/577129
65 passwords_state_.set_client( 66 passwords_state_.set_client(
66 ChromePasswordManagerClient::FromWebContents(web_contents)); 67 ChromePasswordManagerClient::FromWebContents(web_contents));
67 passwords_state_.OnUpdatePassword(std::move(form_to_update)); 68 passwords_state_.OnUpdatePassword(std::move(form_to_update));
68 } 69 }
69 70
70 infobars::InfoBarDelegate::InfoBarIdentifier 71 infobars::InfoBarDelegate::InfoBarIdentifier
71 UpdatePasswordInfoBarDelegate::GetIdentifier() const { 72 UpdatePasswordInfoBarDelegate::GetIdentifier() const {
(...skipping 19 matching lines...) Expand all
91 form_manager->Update(*GetCurrentForms()[form_index]); 92 form_manager->Update(*GetCurrentForms()[form_index]);
92 } else { 93 } else {
93 form_manager->Update(form_manager->pending_credentials()); 94 form_manager->Update(form_manager->pending_credentials());
94 } 95 }
95 return true; 96 return true;
96 } 97 }
97 98
98 bool UpdatePasswordInfoBarDelegate::Cancel() { 99 bool UpdatePasswordInfoBarDelegate::Cancel() {
99 return true; 100 return true;
100 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/update_password_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698