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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h

Issue 228593002: Password bubble: Keep the bubble in sync with the password store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: vabr's feedback. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_
7 7
8 #include "components/password_manager/core/browser/password_form_manager.h" 8 #include "components/password_manager/core/browser/password_form_manager.h"
9 #include "components/password_manager/core/browser/password_store.h"
10 #include "components/password_manager/core/browser/password_store_change.h"
9 #include "content/public/browser/navigation_details.h" 11 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h" 13 #include "content/public/browser/web_contents_user_data.h"
12 14
13 namespace content { 15 namespace content {
14 class WebContents; 16 class WebContents;
15 } 17 }
16 18
17 // Per-tab class to control the Omnibox password icon and bubble. 19 // Per-tab class to control the Omnibox password icon and bubble.
18 class ManagePasswordsBubbleUIController 20 class ManagePasswordsBubbleUIController
19 : public content::WebContentsObserver, 21 : public content::WebContentsObserver,
20 public content::WebContentsUserData<ManagePasswordsBubbleUIController> { 22 public content::WebContentsUserData<ManagePasswordsBubbleUIController>,
23 public PasswordStore::Observer {
21 public: 24 public:
22 virtual ~ManagePasswordsBubbleUIController(); 25 virtual ~ManagePasswordsBubbleUIController();
23 26
24 // Called when the user submits a form containing login information, so we 27 // Called when the user submits a form containing login information, so we
25 // can handle later requests to save or blacklist that login information. 28 // can handle later requests to save or blacklist that login information.
26 // This stores the provided object in form_manager_ and triggers the UI to 29 // This stores the provided object in form_manager_ and triggers the UI to
27 // prompt the user about whether they would like to save the password. 30 // prompt the user about whether they would like to save the password.
28 void OnPasswordSubmitted(PasswordFormManager* form_manager); 31 void OnPasswordSubmitted(PasswordFormManager* form_manager);
29 32
30 // Called when a form is autofilled with login information, so we can manage 33 // Called when a form is autofilled with login information, so we can manage
31 // password credentials for the current site which are stored in 34 // password credentials for the current site which are stored in
32 // |password_form_map|. This stores a copy of |password_form_map| and shows 35 // |password_form_map|. This stores a copy of |password_form_map| and shows
33 // the manage password icon. 36 // the manage password icon.
34 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map); 37 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map);
35 38
36 // Called when a form is _not_ autofilled due to user blacklisting. 39 // Called when a form is _not_ autofilled due to user blacklisting.
37 void OnBlacklistBlockedAutofill(); 40 void OnBlacklistBlockedAutofill();
38 41
39 // TODO(npentrel) This ought to be changed. Best matches should be newly 42 // PasswordStore::Observer implementation.
40 // made when opening the ManagePasswordsBubble because there may have been 43 virtual void OnLoginsChanged(const PasswordStoreChangeList& changes) OVERRIDE;
41 // changes to the best matches via the settings page. At the moment this also
42 // fails if one deletes a password when they are autofilled, as it still shows
43 // up after logging in and saving a password.
44 void RemoveFromBestMatches(autofill::PasswordForm password_form);
45 44
46 void SavePassword(); 45 void SavePassword();
47 46
48 void NeverSavePassword(); 47 void NeverSavePassword();
49 48
50 // Called when the bubble is opened after the icon gets displayed. We change 49 // Called when the bubble is opened after the icon gets displayed. We change
51 // the state to know that we do not need to pop up the bubble again. 50 // the state to know that we do not need to pop up the bubble again.
52 void OnBubbleShown(); 51 void OnBubbleShown();
53 52
54 bool manage_passwords_icon_to_be_shown() const { 53 bool manage_passwords_icon_to_be_shown() const {
(...skipping 17 matching lines...) Expand all
72 } 71 }
73 72
74 const autofill::PasswordForm pending_credentials() const { 73 const autofill::PasswordForm pending_credentials() const {
75 return form_manager_->pending_credentials(); 74 return form_manager_->pending_credentials();
76 } 75 }
77 76
78 const autofill::PasswordFormMap best_matches() const { 77 const autofill::PasswordFormMap best_matches() const {
79 return password_form_map_; 78 return password_form_map_;
80 } 79 }
81 80
82 bool password_submitted() const {
83 return password_submitted_;
84 }
85
86 void set_password_submitted(bool password_submitted) {
87 password_submitted_ = password_submitted;
88 }
89
90 bool autofill_blocked() const { return autofill_blocked_; } 81 bool autofill_blocked() const { return autofill_blocked_; }
91 void set_autofill_blocked(bool autofill_blocked) { 82 void set_autofill_blocked(bool autofill_blocked) {
92 autofill_blocked_ = autofill_blocked; 83 autofill_blocked_ = autofill_blocked;
93 } 84 }
94 85
95 private: 86 private:
96 friend class content::WebContentsUserData<ManagePasswordsBubbleUIController>; 87 friend class content::WebContentsUserData<ManagePasswordsBubbleUIController>;
97 88
98 explicit ManagePasswordsBubbleUIController( 89 explicit ManagePasswordsBubbleUIController(
99 content::WebContents* web_contents); 90 content::WebContents* web_contents);
100 91
101 // Called when a passwordform is autofilled, when a new passwordform is 92 // Called when a passwordform is autofilled, when a new passwordform is
102 // submitted, or when a navigation occurs to update the visibility of the 93 // submitted, or when a navigation occurs to update the visibility of the
103 // manage passwords icon and bubble. 94 // manage passwords icon and bubble.
104 void UpdateBubbleAndIconVisibility(); 95 void UpdateBubbleAndIconVisibility();
105 96
106 // content::WebContentsObserver: 97 // content::WebContentsObserver:
107 virtual void DidNavigateMainFrame( 98 virtual void DidNavigateMainFrame(
108 const content::LoadCommittedDetails& details, 99 const content::LoadCommittedDetails& details,
109 const content::FrameNavigateParams& params) OVERRIDE; 100 const content::FrameNavigateParams& params) OVERRIDE;
101 virtual void WebContentsDestroyed(
102 content::WebContents* web_contents) OVERRIDE;
110 103
111 // Set by OnPasswordSubmitted() when the user submits a form containing login 104 // Set by OnPasswordSubmitted() when the user submits a form containing login
112 // information. If the user responds to a subsequent "Do you want to save 105 // information. If the user responds to a subsequent "Do you want to save
113 // this password?" prompt, we ask this object to save or blacklist the 106 // this password?" prompt, we ask this object to save or blacklist the
114 // associated login information in Chrome's password store. 107 // associated login information in Chrome's password store.
115 scoped_ptr<PasswordFormManager> form_manager_; 108 scoped_ptr<PasswordFormManager> form_manager_;
116 109
117 // All previously stored credentials for a specific site. Set by 110 // All previously stored credentials for a specific site. Set by
118 // OnPasswordSubmitted() or OnPasswordAutofilled(). 111 // OnPasswordSubmitted() or OnPasswordAutofilled().
119 autofill::PasswordFormMap password_form_map_; 112 autofill::PasswordFormMap password_form_map_;
120 113
121 bool manage_passwords_icon_to_be_shown_; 114 bool manage_passwords_icon_to_be_shown_;
122 bool password_to_be_saved_; 115 bool password_to_be_saved_;
123 bool manage_passwords_bubble_needs_showing_; 116 bool manage_passwords_bubble_needs_showing_;
124 // Stores whether a new password has been submitted, if so we have
125 // |pending_credentials|.
126 bool password_submitted_;
127 117
128 // Stores whether autofill was blocked due to a user's decision to blacklist 118 // Stores whether autofill was blocked due to a user's decision to blacklist
129 // the current site ("Never save passwords for this site"). 119 // the current site ("Never save passwords for this site").
130 bool autofill_blocked_; 120 bool autofill_blocked_;
131 121
122 // The origin of the form we're currently dealing with; we'll use this to
123 // determine which PasswordStore changes we should care about when updating
124 // |password_form_map_|.
125 GURL origin_;
126
132 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController); 127 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController);
133 }; 128 };
134 129
135 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_ 130 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698