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

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

Issue 1181623004: [Password Manager] Replace "this site" in save password prompt with password's origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/save_password_infobar_delegate.h" 5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/profile_sync_service.h" 10 #include "chrome/browser/sync/profile_sync_service.h"
11 #include "chrome/browser/sync/profile_sync_service_factory.h" 11 #include "chrome/browser/sync/profile_sync_service_factory.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
12 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
13 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
14 #include "components/infobars/core/infobar.h" 15 #include "components/infobars/core/infobar.h"
15 #include "components/password_manager/core/browser/password_bubble_experiment.h" 16 #include "components/password_manager/core/browser/password_bubble_experiment.h"
16 #include "components/password_manager/core/browser/password_manager_client.h" 17 #include "components/password_manager/core/browser/password_manager_client.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 21
21 #if defined(OS_ANDROID) 22 #if defined(OS_ANDROID)
(...skipping 22 matching lines...) Expand all
44 const std::string& uma_histogram_suffix, 45 const std::string& uma_histogram_suffix,
45 password_manager::CredentialSourceType source_type) { 46 password_manager::CredentialSourceType source_type) {
46 InfoBarService* infobar_service = 47 InfoBarService* infobar_service =
47 InfoBarService::FromWebContents(web_contents); 48 InfoBarService::FromWebContents(web_contents);
48 Profile* profile = 49 Profile* profile =
49 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 50 Profile::FromBrowserContext(web_contents->GetBrowserContext());
50 const ProfileSyncService* sync_service = 51 const ProfileSyncService* sync_service =
51 ProfileSyncServiceFactory::GetForProfile(profile); 52 ProfileSyncServiceFactory::GetForProfile(profile);
52 SavePasswordInfoBarDelegate* infobar_delegate = 53 SavePasswordInfoBarDelegate* infobar_delegate =
53 new SavePasswordInfoBarDelegate( 54 new SavePasswordInfoBarDelegate(
54 form_to_save.Pass(), uma_histogram_suffix, source_type, 55 web_contents, form_to_save.Pass(), uma_histogram_suffix, source_type,
55 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service)); 56 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service));
56 #if defined(OS_ANDROID) 57 #if defined(OS_ANDROID)
57 // For Android in case of smart lock we need different appearance of infobar. 58 // For Android in case of smart lock we need different appearance of infobar.
58 scoped_ptr<infobars::InfoBar> infobar = 59 scoped_ptr<infobars::InfoBar> infobar =
59 make_scoped_ptr(new SavePasswordInfoBar( 60 make_scoped_ptr(new SavePasswordInfoBar(
60 scoped_ptr<SavePasswordInfoBarDelegate>(infobar_delegate))); 61 scoped_ptr<SavePasswordInfoBarDelegate>(infobar_delegate)));
61 #elif defined(OS_MACOSX) 62 #elif defined(OS_MACOSX)
62 scoped_ptr<infobars::InfoBar> infobar( 63 scoped_ptr<infobars::InfoBar> infobar(
63 CreateSavePasswordInfoBar(make_scoped_ptr(infobar_delegate))); 64 CreateSavePasswordInfoBar(make_scoped_ptr(infobar_delegate)));
64 #else 65 #else
(...skipping 23 matching lines...) Expand all
88 infobar_response_, 89 infobar_response_,
89 password_manager::metrics_util::NUM_RESPONSE_TYPES); 90 password_manager::metrics_util::NUM_RESPONSE_TYPES);
90 password_manager::metrics_util::LogUMAHistogramBoolean( 91 password_manager::metrics_util::LogUMAHistogramBoolean(
91 "PasswordManager.SavePasswordPromptDisappearedQuickly_" + 92 "PasswordManager.SavePasswordPromptDisappearedQuickly_" +
92 uma_histogram_suffix_, 93 uma_histogram_suffix_,
93 timer_.Elapsed() < kMinimumPromptDisplayTime); 94 timer_.Elapsed() < kMinimumPromptDisplayTime);
94 } 95 }
95 } 96 }
96 97
97 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( 98 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
99 content::WebContents* web_contents,
98 scoped_ptr<password_manager::PasswordFormManager> form_to_save, 100 scoped_ptr<password_manager::PasswordFormManager> form_to_save,
99 const std::string& uma_histogram_suffix, 101 const std::string& uma_histogram_suffix,
100 password_manager::CredentialSourceType source_type, 102 password_manager::CredentialSourceType source_type,
101 bool is_smartlock_branding_enabled) 103 bool is_smartlock_branding_enabled)
102 : ConfirmInfoBarDelegate(), 104 : ConfirmInfoBarDelegate(),
103 form_to_save_(form_to_save.Pass()), 105 form_to_save_(form_to_save.Pass()),
104 infobar_response_(password_manager::metrics_util::NO_RESPONSE), 106 infobar_response_(password_manager::metrics_util::NO_RESPONSE),
105 uma_histogram_suffix_(uma_histogram_suffix), 107 uma_histogram_suffix_(uma_histogram_suffix),
106 source_type_(source_type) { 108 source_type_(source_type) {
107 if (!uma_histogram_suffix_.empty()) { 109 if (!uma_histogram_suffix_.empty()) {
108 password_manager::metrics_util::LogUMAHistogramBoolean( 110 password_manager::metrics_util::LogUMAHistogramBoolean(
109 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, 111 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_,
110 true); 112 true);
111 } 113 }
112 title_link_range_ = gfx::Range(); 114 title_link_range_ = gfx::Range();
113 if (is_smartlock_branding_enabled) { 115 GetSavePasswordTitleTextAndLinkRange(
114 size_t offset = 0; 116 web_contents, form_to_save->observed_form().origin,
115 base::string16 title_link = 117 is_smartlock_branding_enabled, &title_, &title_link_range_);
116 l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK);
117 title_ = l10n_util::GetStringFUTF16(IDS_SAVE_PASSWORD, title_link, &offset);
118 title_link_range_ = gfx::Range(offset, offset + title_link.length());
119 } else {
120 title_ = l10n_util::GetStringFUTF16(
121 IDS_SAVE_PASSWORD,
122 l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_TITLE_BRAND));
123 }
124 } 118 }
125 119
126 bool SavePasswordInfoBarDelegate::ShouldShowMoreButton() { 120 bool SavePasswordInfoBarDelegate::ShouldShowMoreButton() {
127 return source_type_ == 121 return source_type_ ==
128 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API; 122 password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API;
129 } 123 }
130 124
131 infobars::InfoBarDelegate::Type 125 infobars::InfoBarDelegate::Type
132 SavePasswordInfoBarDelegate::GetInfoBarType() const { 126 SavePasswordInfoBarDelegate::GetInfoBarType() const {
133 return PAGE_ACTION_TYPE; 127 return PAGE_ACTION_TYPE;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 WindowOpenDisposition disposition) { 180 WindowOpenDisposition disposition) {
187 InfoBarService::WebContentsFromInfoBar(infobar()) 181 InfoBarService::WebContentsFromInfoBar(infobar())
188 ->OpenURL(content::OpenURLParams( 182 ->OpenURL(content::OpenURLParams(
189 GURL(l10n_util::GetStringUTF16( 183 GURL(l10n_util::GetStringUTF16(
190 IDS_PASSWORD_MANAGER_SMART_LOCK_ARTICLE)), 184 IDS_PASSWORD_MANAGER_SMART_LOCK_ARTICLE)),
191 content::Referrer(), 185 content::Referrer(),
192 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 186 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
193 ui::PAGE_TRANSITION_LINK, false)); 187 ui::PAGE_TRANSITION_LINK, false));
194 return true; 188 return true;
195 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698