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

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

Issue 127973004: Persist "Save password" infobars across redirects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed + trybot compilation fixed Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/password_manager_delegate_impl.h" 5 #include "chrome/browser/password_manager/password_manager_delegate_impl.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/timer/elapsed_timer.h" 10 #include "base/timer/elapsed_timer.h"
11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
12 #include "chrome/browser/infobars/infobar.h" 12 #include "chrome/browser/infobars/infobar.h"
13 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/password_manager/password_form_manager.h" 14 #include "chrome/browser/password_manager/password_form_manager.h"
15 #include "chrome/browser/password_manager/password_manager.h" 15 #include "chrome/browser/password_manager/password_manager.h"
16 #include "chrome/browser/password_manager/password_manager_metrics_util.h" 16 #include "chrome/browser/password_manager/password_manager_metrics_util.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 18 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
19 #include "components/autofill/content/browser/autofill_driver_impl.h" 19 #include "components/autofill/content/browser/autofill_driver_impl.h"
20 #include "components/autofill/content/common/autofill_messages.h" 20 #include "components/autofill/content/common/autofill_messages.h"
21 #include "components/autofill/core/browser/autofill_manager.h" 21 #include "components/autofill/core/browser/autofill_manager.h"
22 #include "components/autofill/core/common/password_form.h" 22 #include "components/autofill/core/common/password_form.h"
23 #include "content/public/browser/navigation_details.h"
23 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/common/page_transition_types.h"
26 #include "content/public/common/ssl_status.h" 28 #include "content/public/common/ssl_status.h"
27 #include "google_apis/gaia/gaia_urls.h" 29 #include "google_apis/gaia/gaia_urls.h"
28 #include "grit/chromium_strings.h" 30 #include "grit/chromium_strings.h"
29 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
30 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
31 #include "net/cert/cert_status_flags.h" 33 #include "net/cert/cert_status_flags.h"
32 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
33 35
34 36
35 // SavePasswordInfoBarDelegate ------------------------------------------------ 37 // SavePasswordInfoBarDelegate ------------------------------------------------
(...skipping 22 matching lines...) Expand all
58 REMEMBER_PASSWORD, 60 REMEMBER_PASSWORD,
59 NEVER_REMEMBER_PASSWORD, 61 NEVER_REMEMBER_PASSWORD,
60 INFOBAR_DISMISSED, 62 INFOBAR_DISMISSED,
61 NUM_RESPONSE_TYPES, 63 NUM_RESPONSE_TYPES,
62 }; 64 };
63 65
64 SavePasswordInfoBarDelegate(PasswordFormManager* form_to_save, 66 SavePasswordInfoBarDelegate(PasswordFormManager* form_to_save,
65 const std::string& uma_histogram_suffix); 67 const std::string& uma_histogram_suffix);
66 virtual ~SavePasswordInfoBarDelegate(); 68 virtual ~SavePasswordInfoBarDelegate();
67 69
70 // InfoBarDelegate
71 virtual bool ShouldExpire(const content::LoadCommittedDetails& details)
72 const OVERRIDE;
73
68 // ConfirmInfoBarDelegate 74 // ConfirmInfoBarDelegate
69 virtual int GetIconID() const OVERRIDE; 75 virtual int GetIconID() const OVERRIDE;
70 virtual Type GetInfoBarType() const OVERRIDE; 76 virtual Type GetInfoBarType() const OVERRIDE;
71 virtual base::string16 GetMessageText() const OVERRIDE; 77 virtual base::string16 GetMessageText() const OVERRIDE;
72 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 78 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
73 virtual bool Accept() OVERRIDE; 79 virtual bool Accept() OVERRIDE;
74 virtual bool Cancel() OVERRIDE; 80 virtual bool Cancel() OVERRIDE;
75 virtual void InfoBarDismissed() OVERRIDE; 81 virtual void InfoBarDismissed() OVERRIDE;
76 82
77 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; 83 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 password_manager_metrics_util::LogUMAHistogramEnumeration( 153 password_manager_metrics_util::LogUMAHistogramEnumeration(
148 "PasswordManager.SavePasswordPromptResponse_" + uma_histogram_suffix_, 154 "PasswordManager.SavePasswordPromptResponse_" + uma_histogram_suffix_,
149 infobar_response_, NUM_RESPONSE_TYPES); 155 infobar_response_, NUM_RESPONSE_TYPES);
150 password_manager_metrics_util::LogUMAHistogramBoolean( 156 password_manager_metrics_util::LogUMAHistogramBoolean(
151 "PasswordManager.SavePasswordPromptDisappearedQuickly_" + 157 "PasswordManager.SavePasswordPromptDisappearedQuickly_" +
152 uma_histogram_suffix_, 158 uma_histogram_suffix_,
153 timer_.Elapsed() < kMinimumPromptDisplayTime); 159 timer_.Elapsed() < kMinimumPromptDisplayTime);
154 } 160 }
155 } 161 }
156 162
163 bool SavePasswordInfoBarDelegate::ShouldExpire(
164 const content::LoadCommittedDetails& details) const {
165 bool is_not_redirect = !(details.entry->GetTransitionType() &
vabr (Chromium) 2014/01/09 11:39:38 This change is to get rid of the C4800 warning of
166 content::PAGE_TRANSITION_IS_REDIRECT_MASK);
167 return is_not_redirect && InfoBarDelegate::ShouldExpire(details);
168 }
169
157 int SavePasswordInfoBarDelegate::GetIconID() const { 170 int SavePasswordInfoBarDelegate::GetIconID() const {
158 return IDR_INFOBAR_SAVE_PASSWORD; 171 return IDR_INFOBAR_SAVE_PASSWORD;
159 } 172 }
160 173
161 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { 174 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const {
162 return PAGE_ACTION_TYPE; 175 return PAGE_ACTION_TYPE;
163 } 176 }
164 177
165 base::string16 SavePasswordInfoBarDelegate::GetMessageText() const { 178 base::string16 SavePasswordInfoBarDelegate::GetMessageText() const {
166 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); 179 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { 247 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() {
235 content::NavigationEntry* entry = 248 content::NavigationEntry* entry =
236 web_contents_->GetController().GetActiveEntry(); 249 web_contents_->GetController().GetActiveEntry();
237 if (!entry) { 250 if (!entry) {
238 NOTREACHED(); 251 NOTREACHED();
239 return false; 252 return false;
240 } 253 }
241 254
242 return net::IsCertStatusError(entry->GetSSL().cert_status); 255 return net::IsCertStatusError(entry->GetSSL().cert_status);
243 } 256 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_browsertest.cc ('k') | chrome/test/data/password/password_form.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698