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

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

Issue 4694008: Make pink's TabContentsWrapper change compile on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/password_manager_delegate_impl.h"
6
7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h"
9 #include "base/metrics/histogram.h"
10 #include "base/singleton.h"
11 #include "chrome/browser/password_manager/password_form_manager.h"
12 #include "chrome/browser/password_manager/password_manager.h"
13 #include "chrome/browser/renderer_host/render_view_host.h"
14 #include "chrome/browser/tab_contents/infobar_delegate.h"
15 #include "chrome/browser/tab_contents/tab_contents.h"
16 #include "grit/chromium_strings.h"
17 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h"
19 #include "webkit/glue/password_form.h"
20
21 // After a successful *new* login attempt, we take the PasswordFormManager in
22 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while
23 // the user makes up their mind with the "save password" infobar. Note if the
24 // login is one we already know about, the end of the line is
25 // provisional_save_manager_ because we just update it on success and so such
26 // forms never end up in an infobar.
27 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
28 public:
29 SavePasswordInfoBarDelegate(TabContents* tab_contents,
30 PasswordFormManager* form_to_save)
31 : ConfirmInfoBarDelegate(tab_contents),
32 form_to_save_(form_to_save),
33 infobar_response_(NO_RESPONSE) {}
34
35 virtual ~SavePasswordInfoBarDelegate() {}
36
37 // Begin ConfirmInfoBarDelegate implementation.
38 virtual void InfoBarClosed() {
39 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse",
40 infobar_response_, NUM_RESPONSE_TYPES);
41 delete this;
42 }
43
44 virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; }
45
46 virtual string16 GetMessageText() const {
47 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT);
48 }
49
50 virtual SkBitmap* GetIcon() const {
51 return ResourceBundle::GetSharedInstance().GetBitmapNamed(
52 IDR_INFOBAR_SAVE_PASSWORD);
53 }
54
55 virtual int GetButtons() const {
56 return BUTTON_OK | BUTTON_CANCEL;
57 }
58
59 virtual string16 GetButtonLabel(InfoBarButton button) const {
60 if (button == BUTTON_OK)
61 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON);
62 if (button == BUTTON_CANCEL)
63 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON);
64 NOTREACHED();
65 return string16();
66 }
67
68 virtual bool Accept() {
69 DCHECK(form_to_save_.get());
70 form_to_save_->Save();
71 infobar_response_ = REMEMBER_PASSWORD;
72 return true;
73 }
74
75 virtual bool Cancel() {
76 DCHECK(form_to_save_.get());
77 form_to_save_->PermanentlyBlacklist();
78 infobar_response_ = DONT_REMEMBER_PASSWORD;
79 return true;
80 }
81 // End ConfirmInfoBarDelegate implementation.
82
83 private:
84 // The PasswordFormManager managing the form we're asking the user about,
85 // and should update as per her decision.
86 scoped_ptr<PasswordFormManager> form_to_save_;
87
88 // Used to track the results we get from the info bar.
89 enum ResponseType {
90 NO_RESPONSE = 0,
91 REMEMBER_PASSWORD,
92 DONT_REMEMBER_PASSWORD,
93 NUM_RESPONSE_TYPES,
94 };
95 ResponseType infobar_response_;
96
97 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate);
98 };
99
100 //----------------------------------------------------------------------------
101
102 void PasswordManagerDelegateImpl::FillPasswordForm(
103 const webkit_glue::PasswordFormFillData& form_data) {
104 tab_contents_->render_view_host()->FillPasswordForm(form_data);
105 }
106
107 void PasswordManagerDelegateImpl::AddSavePasswordInfoBar(
108 PasswordFormManager* form_to_save) {
109 tab_contents_->AddInfoBar(
110 new SavePasswordInfoBarDelegate(tab_contents_, form_to_save));
111 }
112
113 Profile* PasswordManagerDelegateImpl::GetProfileForPasswordManager() {
114 return tab_contents_->profile();
115 }
116
117 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() {
118 return tab_contents_->controller().ssl_manager()->
119 ProcessedSSLErrorFromRequest();
120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698