Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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; | |
| 103 | |
| 104 // Returns the password store associated with the web_contents. | |
| 105 PasswordStore* GetPasswordStore(content::WebContents* web_contents); | |
|
vabr (Chromium)
2014/04/08 13:08:34
Could this be (in order of my preference):
1) a he
Mike West
2014/04/09 07:06:51
A helper method in the anonymous namespace it is!
| |
| 110 | 106 |
| 111 // Set by OnPasswordSubmitted() when the user submits a form containing login | 107 // 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 | 108 // 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 | 109 // this password?" prompt, we ask this object to save or blacklist the |
| 114 // associated login information in Chrome's password store. | 110 // associated login information in Chrome's password store. |
| 115 scoped_ptr<PasswordFormManager> form_manager_; | 111 scoped_ptr<PasswordFormManager> form_manager_; |
| 116 | 112 |
| 117 // All previously stored credentials for a specific site. Set by | 113 // All previously stored credentials for a specific site. Set by |
| 118 // OnPasswordSubmitted() or OnPasswordAutofilled(). | 114 // OnPasswordSubmitted() or OnPasswordAutofilled(). |
| 119 autofill::PasswordFormMap password_form_map_; | 115 autofill::PasswordFormMap password_form_map_; |
| 120 | 116 |
| 121 bool manage_passwords_icon_to_be_shown_; | 117 bool manage_passwords_icon_to_be_shown_; |
| 122 bool password_to_be_saved_; | 118 bool password_to_be_saved_; |
| 123 bool manage_passwords_bubble_needs_showing_; | 119 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 | 120 |
| 128 // Stores whether autofill was blocked due to a user's decision to blacklist | 121 // Stores whether autofill was blocked due to a user's decision to blacklist |
| 129 // the current site ("Never save passwords for this site"). | 122 // the current site ("Never save passwords for this site"). |
| 130 bool autofill_blocked_; | 123 bool autofill_blocked_; |
| 131 | 124 |
| 125 // The origin of the form we're currently dealing with; we'll use this to | |
| 126 // determine which PasswordStore changes we should care about when updating | |
| 127 // |password_form_map_|. | |
| 128 GURL origin_; | |
| 129 | |
| 132 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController); | 130 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController); |
| 133 }; | 131 }; |
| 134 | 132 |
| 135 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_ | 133 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_ |
| OLD | NEW |