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

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: Rebase. 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 password_manager::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(password_manager::PasswordFormManager* form_manager); 31 void OnPasswordSubmitted(password_manager::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(
41 // changes to the best matches via the settings page. At the moment this also 44 const password_manager::PasswordStoreChangeList& changes) OVERRIDE;
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 45
46 void SavePassword(); 46 void SavePassword();
47 47
48 void NeverSavePassword(); 48 void NeverSavePassword();
49 49
50 // Called when the bubble is opened after the icon gets displayed. We change 50 // 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. 51 // the state to know that we do not need to pop up the bubble again.
52 void OnBubbleShown(); 52 void OnBubbleShown();
53 53
54 bool manage_passwords_icon_to_be_shown() const { 54 bool manage_passwords_icon_to_be_shown() const {
(...skipping 17 matching lines...) Expand all
72 } 72 }
73 73
74 const autofill::PasswordForm pending_credentials() const { 74 const autofill::PasswordForm pending_credentials() const {
75 return form_manager_->pending_credentials(); 75 return form_manager_->pending_credentials();
76 } 76 }
77 77
78 const autofill::PasswordFormMap best_matches() const { 78 const autofill::PasswordFormMap best_matches() const {
79 return password_form_map_; 79 return password_form_map_;
80 } 80 }
81 81
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_; } 82 bool autofill_blocked() const { return autofill_blocked_; }
91 void set_autofill_blocked(bool autofill_blocked) { 83 void set_autofill_blocked(bool autofill_blocked) {
92 autofill_blocked_ = autofill_blocked; 84 autofill_blocked_ = autofill_blocked;
93 } 85 }
94 86
95 private: 87 private:
96 friend class content::WebContentsUserData<ManagePasswordsBubbleUIController>; 88 friend class content::WebContentsUserData<ManagePasswordsBubbleUIController>;
97 89
98 explicit ManagePasswordsBubbleUIController( 90 explicit ManagePasswordsBubbleUIController(
99 content::WebContents* web_contents); 91 content::WebContents* web_contents);
100 92
101 // Called when a passwordform is autofilled, when a new passwordform is 93 // Called when a passwordform is autofilled, when a new passwordform is
102 // submitted, or when a navigation occurs to update the visibility of the 94 // submitted, or when a navigation occurs to update the visibility of the
103 // manage passwords icon and bubble. 95 // manage passwords icon and bubble.
104 void UpdateBubbleAndIconVisibility(); 96 void UpdateBubbleAndIconVisibility();
105 97
106 // content::WebContentsObserver: 98 // content::WebContentsObserver:
107 virtual void DidNavigateMainFrame( 99 virtual void DidNavigateMainFrame(
108 const content::LoadCommittedDetails& details, 100 const content::LoadCommittedDetails& details,
109 const content::FrameNavigateParams& params) OVERRIDE; 101 const content::FrameNavigateParams& params) OVERRIDE;
102 virtual void WebContentsDestroyed(
103 content::WebContents* web_contents) OVERRIDE;
110 104
111 // Set by OnPasswordSubmitted() when the user submits a form containing login 105 // 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 106 // 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 107 // this password?" prompt, we ask this object to save or blacklist the
114 // associated login information in Chrome's password store. 108 // associated login information in Chrome's password store.
115 scoped_ptr<password_manager::PasswordFormManager> form_manager_; 109 scoped_ptr<password_manager::PasswordFormManager> form_manager_;
116 110
117 // All previously stored credentials for a specific site. Set by 111 // All previously stored credentials for a specific site. Set by
118 // OnPasswordSubmitted() or OnPasswordAutofilled(). 112 // OnPasswordSubmitted() or OnPasswordAutofilled().
119 autofill::PasswordFormMap password_form_map_; 113 autofill::PasswordFormMap password_form_map_;
120 114
121 bool manage_passwords_icon_to_be_shown_; 115 bool manage_passwords_icon_to_be_shown_;
122 bool password_to_be_saved_; 116 bool password_to_be_saved_;
123 bool manage_passwords_bubble_needs_showing_; 117 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 118
128 // Stores whether autofill was blocked due to a user's decision to blacklist 119 // Stores whether autofill was blocked due to a user's decision to blacklist
129 // the current site ("Never save passwords for this site"). 120 // the current site ("Never save passwords for this site").
130 bool autofill_blocked_; 121 bool autofill_blocked_;
131 122
123 // The origin of the form we're currently dealing with; we'll use this to
124 // determine which PasswordStore changes we should care about when updating
125 // |password_form_map_|.
126 GURL origin_;
127
132 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController); 128 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController);
133 }; 129 };
134 130
135 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_ 131 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698