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

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

Issue 2588263003: Reland: Remove Finch support for PasswordBranding (Closed)
Patch Set: Rebased only Created 4 years 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 "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h" 5 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h" 12 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "chrome/browser/ui/android/infobars/update_password_infobar.h" 13 #include "chrome/browser/ui/android/infobars/update_password_infobar.h"
14 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 14 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
15 #include "chrome/grit/chromium_strings.h" 15 #include "chrome/grit/chromium_strings.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "components/browser_sync/profile_sync_service.h" 17 #include "components/browser_sync/profile_sync_service.h"
18 #include "components/infobars/core/infobar.h" 18 #include "components/infobars/core/infobar.h"
19 #include "components/password_manager/core/browser/password_bubble_experiment.h" 19 #include "components/password_manager/core/browser/password_bubble_experiment.h"
20 #include "components/strings/grit/components_strings.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 23
23 // static 24 // static
24 void UpdatePasswordInfoBarDelegate::Create( 25 void UpdatePasswordInfoBarDelegate::Create(
25 content::WebContents* web_contents, 26 content::WebContents* web_contents,
26 std::unique_ptr<password_manager::PasswordFormManager> form_to_save) { 27 std::unique_ptr<password_manager::PasswordFormManager> form_to_save) {
27 const bool is_smartlock_branding_enabled = 28 const bool is_smartlock_branding_enabled =
28 password_bubble_experiment::IsSmartLockBrandingSavePromptEnabled( 29 password_bubble_experiment::IsSmartLockUser(
29 ProfileSyncServiceFactory::GetForProfile( 30 ProfileSyncServiceFactory::GetForProfile(
30 Profile::FromBrowserContext(web_contents->GetBrowserContext()))); 31 Profile::FromBrowserContext(web_contents->GetBrowserContext())));
31 InfoBarService::FromWebContents(web_contents) 32 InfoBarService::FromWebContents(web_contents)
32 ->AddInfoBar(base::MakeUnique<UpdatePasswordInfoBar>( 33 ->AddInfoBar(base::MakeUnique<UpdatePasswordInfoBar>(
33 base::WrapUnique(new UpdatePasswordInfoBarDelegate( 34 base::WrapUnique(new UpdatePasswordInfoBarDelegate(
34 web_contents, std::move(form_to_save), 35 web_contents, std::move(form_to_save),
35 is_smartlock_branding_enabled)))); 36 is_smartlock_branding_enabled))));
36 } 37 }
37 38
38 UpdatePasswordInfoBarDelegate::~UpdatePasswordInfoBarDelegate() {} 39 UpdatePasswordInfoBarDelegate::~UpdatePasswordInfoBarDelegate() {}
39 40
40 base::string16 UpdatePasswordInfoBarDelegate::GetBranding() const { 41 base::string16 UpdatePasswordInfoBarDelegate::GetBranding() const {
41 return l10n_util::GetStringUTF16( 42 return l10n_util::GetStringUTF16(is_smartlock_branding_enabled_
42 is_smartlock_branding_enabled_ 43 ? IDS_PASSWORD_MANAGER_SMART_LOCK
43 ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS 44 : IDS_PASSWORD_MANAGER_TITLE_BRAND);
44 : IDS_PASSWORD_MANAGER_TITLE_BRAND);
45 } 45 }
46 46
47 bool UpdatePasswordInfoBarDelegate::ShowMultipleAccounts() const { 47 bool UpdatePasswordInfoBarDelegate::ShowMultipleAccounts() const {
48 const password_manager::PasswordFormManager* form_manager = 48 const password_manager::PasswordFormManager* form_manager =
49 passwords_state_.form_manager(); 49 passwords_state_.form_manager();
50 bool is_password_overriden = 50 bool is_password_overriden =
51 form_manager && form_manager->password_overridden(); 51 form_manager && form_manager->password_overridden();
52 return GetCurrentForms().size() > 1 && !is_password_overriden; 52 return GetCurrentForms().size() > 1 && !is_password_overriden;
53 } 53 }
54 54
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (ShowMultipleAccounts()) { 99 if (ShowMultipleAccounts()) {
100 int form_index = update_password_infobar->GetIdOfSelectedUsername(); 100 int form_index = update_password_infobar->GetIdOfSelectedUsername();
101 DCHECK_GE(form_index, 0); 101 DCHECK_GE(form_index, 0);
102 DCHECK_LT(static_cast<size_t>(form_index), GetCurrentForms().size()); 102 DCHECK_LT(static_cast<size_t>(form_index), GetCurrentForms().size());
103 form_manager->Update(*GetCurrentForms()[form_index]); 103 form_manager->Update(*GetCurrentForms()[form_index]);
104 } else { 104 } else {
105 form_manager->Update(form_manager->pending_credentials()); 105 form_manager->Update(form_manager->pending_credentials());
106 } 106 }
107 return true; 107 return true;
108 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698