| 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/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/timer/elapsed_timer.h" | 9 #include "base/timer/elapsed_timer.h" |
| 10 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 virtual const autofill::PasswordForm& PendingPassword() const; | 102 virtual const autofill::PasswordForm& PendingPassword() const; |
| 103 | 103 |
| 104 // Set the state of the Omnibox icon, and possibly show the associated bubble | 104 // Set the state of the Omnibox icon, and possibly show the associated bubble |
| 105 // without user interaction. | 105 // without user interaction. |
| 106 virtual void UpdateIconAndBubbleState(ManagePasswordsIcon* icon); | 106 virtual void UpdateIconAndBubbleState(ManagePasswordsIcon* icon); |
| 107 | 107 |
| 108 // Called from the model when the bubble is displayed. | 108 // Called from the model when the bubble is displayed. |
| 109 void OnBubbleShown(); | 109 void OnBubbleShown(); |
| 110 | 110 |
| 111 // Called from the model when the bubble is hidden. |
| 112 void OnBubbleHidden(); |
| 113 |
| 111 password_manager::ui::State state() const { return state_; } | 114 password_manager::ui::State state() const { return state_; } |
| 112 | 115 |
| 113 ScopedVector<autofill::PasswordForm>& federated_credentials_forms() { | 116 ScopedVector<autofill::PasswordForm>& federated_credentials_forms() { |
| 114 return federated_credentials_forms_; | 117 return federated_credentials_forms_; |
| 115 } | 118 } |
| 116 | 119 |
| 117 ScopedVector<autofill::PasswordForm>& local_credentials_forms() { | 120 ScopedVector<autofill::PasswordForm>& local_credentials_forms() { |
| 118 return local_credentials_forms_; | 121 return local_credentials_forms_; |
| 119 } | 122 } |
| 120 | 123 |
| 121 // True if a password is sitting around, waiting for a user to decide whether | 124 // True if a password is sitting around, waiting for a user to decide whether |
| 122 // or not to save it. | 125 // or not to save it. |
| 123 bool PasswordPendingUserDecision() const; | 126 bool PasswordPendingUserDecision() const; |
| 124 | 127 |
| 125 const autofill::ConstPasswordFormMap& best_matches() const { | 128 const autofill::ConstPasswordFormMap& best_matches() const { |
| 126 return password_form_map_; | 129 return password_form_map_; |
| 127 } | 130 } |
| 128 | 131 |
| 129 const GURL& origin() const { return origin_; } | 132 const GURL& origin() const { return origin_; } |
| 130 | 133 |
| 134 bool IsAutomaticallyOpeningBubble() const { return should_pop_up_bubble_; } |
| 135 |
| 131 protected: | 136 protected: |
| 132 explicit ManagePasswordsUIController( | 137 explicit ManagePasswordsUIController( |
| 133 content::WebContents* web_contents); | 138 content::WebContents* web_contents); |
| 134 | 139 |
| 135 // The pieces of saving and blacklisting passwords that interact with | 140 // The pieces of saving and blacklisting passwords that interact with |
| 136 // FormManager, split off into internal functions for testing/mocking. | 141 // FormManager, split off into internal functions for testing/mocking. |
| 137 virtual void SavePasswordInternal(); | 142 virtual void SavePasswordInternal(); |
| 138 virtual void NeverSavePasswordInternal(); | 143 virtual void NeverSavePasswordInternal(); |
| 139 | 144 |
| 140 // Called when a passwordform is autofilled, when a new passwordform is | 145 // Called when a passwordform is autofilled, when a new passwordform is |
| (...skipping 29 matching lines...) Expand all Loading... |
| 170 ScopedVector<autofill::PasswordForm> local_credentials_forms_; | 175 ScopedVector<autofill::PasswordForm> local_credentials_forms_; |
| 171 | 176 |
| 172 // All previously stored credentials for a specific site. | 177 // All previously stored credentials for a specific site. |
| 173 // Protected, not private, so we can mess with the value in | 178 // Protected, not private, so we can mess with the value in |
| 174 // ManagePasswordsUIControllerMock. | 179 // ManagePasswordsUIControllerMock. |
| 175 autofill::ConstPasswordFormMap password_form_map_; | 180 autofill::ConstPasswordFormMap password_form_map_; |
| 176 | 181 |
| 177 private: | 182 private: |
| 178 friend class content::WebContentsUserData<ManagePasswordsUIController>; | 183 friend class content::WebContentsUserData<ManagePasswordsUIController>; |
| 179 | 184 |
| 180 // Shows the password bubble without user interaction. The controller MUST | 185 // Shows the password bubble without user interaction. |
| 181 // be in PENDING_PASSWORD_AND_BUBBLE_STATE. | |
| 182 void ShowBubbleWithoutUserInteraction(); | 186 void ShowBubbleWithoutUserInteraction(); |
| 183 | 187 |
| 184 // content::WebContentsObserver: | 188 // content::WebContentsObserver: |
| 185 void WebContentsDestroyed() override; | 189 void WebContentsDestroyed() override; |
| 186 | 190 |
| 187 // The current state of the password manager UI. | 191 // The current state of the password manager UI. |
| 188 password_manager::ui::State state_; | 192 password_manager::ui::State state_; |
| 189 | 193 |
| 190 // Used to measure the amount of time on a page; if it's less than some | 194 // Used to measure the amount of time on a page; if it's less than some |
| 191 // reasonable limit, then don't close the bubble upon navigation. We create | 195 // reasonable limit, then don't close the bubble upon navigation. We create |
| 192 // (and destroy) the timer in DidNavigateMainFrame. | 196 // (and destroy) the timer in DidNavigateMainFrame. |
| 193 scoped_ptr<base::ElapsedTimer> timer_; | 197 scoped_ptr<base::ElapsedTimer> timer_; |
| 194 | 198 |
| 195 // Set by OnPasswordSubmitted() when the user submits a form containing login | 199 // Set by OnPasswordSubmitted() when the user submits a form containing login |
| 196 // information. If the user responds to a subsequent "Do you want to save | 200 // information. If the user responds to a subsequent "Do you want to save |
| 197 // this password?" prompt, we ask this object to save or blacklist the | 201 // this password?" prompt, we ask this object to save or blacklist the |
| 198 // associated login information in Chrome's password store. | 202 // associated login information in Chrome's password store. |
| 199 scoped_ptr<password_manager::PasswordFormManager> form_manager_; | 203 scoped_ptr<password_manager::PasswordFormManager> form_manager_; |
| 200 | 204 |
| 201 // A callback to be invoked when user selects a credential. | 205 // A callback to be invoked when user selects a credential. |
| 202 base::Callback<void(const password_manager::CredentialInfo&)> | 206 base::Callback<void(const password_manager::CredentialInfo&)> |
| 203 credentials_callback_; | 207 credentials_callback_; |
| 204 | 208 |
| 205 // Contains true is the bubble's appeared during the last call to | 209 // Contains true if the bubble is to be popped up in the next call to |
| 206 // UpdateBubbleAndIconVisibility(). | 210 // UpdateBubbleAndIconVisibility(). |
| 207 bool bubble_shown_; | 211 bool should_pop_up_bubble_; |
| 208 | 212 |
| 209 // The origin of the form we're currently dealing with; we'll use this to | 213 // The origin of the form we're currently dealing with; we'll use this to |
| 210 // determine which PasswordStore changes we should care about when updating | 214 // determine which PasswordStore changes we should care about when updating |
| 211 // |password_form_map_|. | 215 // |password_form_map_|. |
| 212 GURL origin_; | 216 GURL origin_; |
| 213 | 217 |
| 214 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); | 218 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); |
| 215 }; | 219 }; |
| 216 | 220 |
| 217 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ | 221 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ |
| OLD | NEW |