Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_UI_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 : public content::WebContentsObserver, | 28 : public content::WebContentsObserver, |
| 29 public content::WebContentsUserData<ManagePasswordsUIController>, | 29 public content::WebContentsUserData<ManagePasswordsUIController>, |
| 30 public password_manager::PasswordStore::Observer { | 30 public password_manager::PasswordStore::Observer { |
| 31 public: | 31 public: |
| 32 virtual ~ManagePasswordsUIController(); | 32 virtual ~ManagePasswordsUIController(); |
| 33 | 33 |
| 34 // Called when the user submits a form containing login information, so we | 34 // Called when the user submits a form containing login information, so we |
| 35 // can handle later requests to save or blacklist that login information. | 35 // can handle later requests to save or blacklist that login information. |
| 36 // This stores the provided object in form_manager_ and triggers the UI to | 36 // This stores the provided object in form_manager_ and triggers the UI to |
| 37 // prompt the user about whether they would like to save the password. | 37 // prompt the user about whether they would like to save the password. |
| 38 void OnPasswordSubmitted(password_manager::PasswordFormManager* form_manager); | 38 void OnPasswordSubmitted( |
| 39 scoped_ptr<password_manager::PasswordFormManager> form_manager); | |
| 40 | |
| 41 // Called when the password will be saved automatically, but we still wish to | |
| 42 // visually inform the user that the save has occured. | |
| 43 void OnAutomaticPasswordSave( | |
| 44 scoped_ptr<password_manager::PasswordFormManager> form_manager); | |
| 39 | 45 |
| 40 // Called when a form is autofilled with login information, so we can manage | 46 // Called when a form is autofilled with login information, so we can manage |
| 41 // password credentials for the current site which are stored in | 47 // password credentials for the current site which are stored in |
| 42 // |password_form_map|. This stores a copy of |password_form_map| and shows | 48 // |password_form_map|. This stores a copy of |password_form_map| and shows |
| 43 // the manage password icon. | 49 // the manage password icon. |
| 44 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map); | 50 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map); |
| 45 | 51 |
| 46 // Called when a form is _not_ autofilled due to user blacklisting. This | 52 // Called when a form is _not_ autofilled due to user blacklisting. This |
| 47 // stores a copy of |password_form_map| so that we can offer the user the | 53 // stores a copy of |password_form_map| so that we can offer the user the |
| 48 // ability to reenable the manager for this form. | 54 // ability to reenable the manager for this form. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 64 virtual void NeverSavePassword(); | 70 virtual void NeverSavePassword(); |
| 65 | 71 |
| 66 // Called from the model when the user chooses to unblacklist the site. The | 72 // Called from the model when the user chooses to unblacklist the site. The |
| 67 // controller MUST be in BLACKLIST_STATE, and WILL be in MANAGE_STATE after | 73 // controller MUST be in BLACKLIST_STATE, and WILL be in MANAGE_STATE after |
| 68 // this method executes. | 74 // this method executes. |
| 69 virtual void UnblacklistSite(); | 75 virtual void UnblacklistSite(); |
| 70 | 76 |
| 71 // Open a new tab, pointing to the password manager settings page. | 77 // Open a new tab, pointing to the password manager settings page. |
| 72 virtual void NavigateToPasswordManagerSettingsPage(); | 78 virtual void NavigateToPasswordManagerSettingsPage(); |
| 73 | 79 |
| 80 // Open a new tab, pointing to the Google manage passwords website. | |
| 81 virtual void NavigateToAccountCentralManagementPage(); | |
| 82 | |
| 74 virtual const autofill::PasswordForm& PendingCredentials() const; | 83 virtual const autofill::PasswordForm& PendingCredentials() const; |
| 75 | 84 |
| 76 // Set the state of the Omnibox icon, and possibly show the associated bubble | 85 // Set the state of the Omnibox icon, and possibly show the associated bubble |
| 77 // without user interaction. | 86 // without user interaction. |
| 78 virtual void UpdateIconAndBubbleState(ManagePasswordsIcon* icon); | 87 virtual void UpdateIconAndBubbleState(ManagePasswordsIcon* icon); |
| 79 | 88 |
| 80 password_manager::ui::State state() const { return state_; } | 89 password_manager::ui::State state() const { return state_; } |
| 81 | 90 |
| 82 // True if a password is sitting around, waiting for a user to decide whether | 91 // True if a password is sitting around, waiting for a user to decide whether |
| 83 // or not to save it. | 92 // or not to save it. |
| 84 bool PasswordPendingUserDecision() const; | 93 bool PasswordPendingUserDecision() const; |
| 85 | 94 |
| 86 const autofill::PasswordFormMap best_matches() const { | 95 const autofill::ConstPasswordFormMap best_matches() const { |
| 87 return password_form_map_; | 96 return password_form_map_; |
| 88 } | 97 } |
| 89 | 98 |
| 90 const GURL& origin() const { return origin_; } | 99 const GURL& origin() const { return origin_; } |
| 91 | 100 |
| 92 protected: | 101 protected: |
| 93 explicit ManagePasswordsUIController( | 102 explicit ManagePasswordsUIController( |
| 94 content::WebContents* web_contents); | 103 content::WebContents* web_contents); |
| 95 | 104 |
| 96 // The pieces of saving and blacklisting passwords that interact with | 105 // The pieces of saving and blacklisting passwords that interact with |
| 97 // FormManager, split off into internal functions for testing/mocking. | 106 // FormManager, split off into internal functions for testing/mocking. |
| 98 virtual void SavePasswordInternal(); | 107 virtual void SavePasswordInternal(); |
| 99 virtual void NeverSavePasswordInternal(); | 108 virtual void NeverSavePasswordInternal(); |
| 100 | 109 |
| 101 // content::WebContentsObserver: | 110 // content::WebContentsObserver: |
| 102 virtual void DidNavigateMainFrame( | 111 virtual void DidNavigateMainFrame( |
| 103 const content::LoadCommittedDetails& details, | 112 const content::LoadCommittedDetails& details, |
| 104 const content::FrameNavigateParams& params) OVERRIDE; | 113 const content::FrameNavigateParams& params) OVERRIDE; |
| 105 | 114 |
| 106 // All previously stored credentials for a specific site. Set by | 115 // All previously stored credentials for a specific site. This is not |
| 107 // OnPasswordSubmitted(), OnPasswordAutofilled(), or | 116 // physically const, but the contents of the maps should be treated as const. |
| 108 // OnBlacklistBlockedAutofill(). Protected, not private, so we can mess with | 117 // Protected, not private, so we can mess with the value in |
| 109 // the value in ManagePasswordsUIControllerMock. | 118 // ManagePasswordsUIControllerMock. |
|
Mike West
2014/07/17 13:43:17
You can kill this bit of the comment, right?
Garrett Casto
2014/07/17 20:54:55
Yep, done.
| |
| 110 autofill::PasswordFormMap password_form_map_; | 119 autofill::ConstPasswordFormMap password_form_map_; |
| 111 | 120 |
| 112 // We create copies of PasswordForm objects that come in via OnLoginsChanged() | 121 // We create copies of PasswordForm objects that come in via OnLoginsChanged() |
| 113 // and store them in this vector as well as in |password_form_map_| to ensure | 122 // and store them in this vector as well as in |password_form_map_| to ensure |
| 114 // that we destroy them correctly. | 123 // that we destroy them correctly. |
| 115 ScopedVector<autofill::PasswordForm> new_password_forms_; | 124 ScopedVector<autofill::PasswordForm> new_password_forms_; |
| 116 | 125 |
| 117 // The current state of the password manager. Protected so we can manipulate | 126 // The current state of the password manager. Protected so we can manipulate |
| 118 // the value in tests. | 127 // the value in tests. |
| 119 password_manager::ui::State state_; | 128 password_manager::ui::State state_; |
| 120 | 129 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 150 | 159 |
| 151 // The origin of the form we're currently dealing with; we'll use this to | 160 // The origin of the form we're currently dealing with; we'll use this to |
| 152 // determine which PasswordStore changes we should care about when updating | 161 // determine which PasswordStore changes we should care about when updating |
| 153 // |password_form_map_|. | 162 // |password_form_map_|. |
| 154 GURL origin_; | 163 GURL origin_; |
| 155 | 164 |
| 156 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); | 165 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); |
| 157 }; | 166 }; |
| 158 | 167 |
| 159 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ | 168 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ |
| OLD | NEW |