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/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/timer/elapsed_timer.h" |
9 #include "components/autofill/core/common/password_form.h" | 11 #include "components/autofill/core/common/password_form.h" |
10 #include "components/password_manager/core/browser/password_form_manager.h" | 12 #include "components/password_manager/core/browser/password_form_manager.h" |
11 #include "components/password_manager/core/browser/password_store.h" | 13 #include "components/password_manager/core/browser/password_store.h" |
12 #include "components/password_manager/core/browser/password_store_change.h" | 14 #include "components/password_manager/core/browser/password_store_change.h" |
13 #include "components/password_manager/core/common/password_manager_ui.h" | 15 #include "components/password_manager/core/common/password_manager_ui.h" |
14 #include "content/public/browser/navigation_details.h" | 16 #include "content/public/browser/navigation_details.h" |
15 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
16 #include "content/public/browser/web_contents_user_data.h" | 18 #include "content/public/browser/web_contents_user_data.h" |
17 | 19 |
18 namespace content { | 20 namespace content { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const autofill::PasswordFormMap best_matches() const { | 86 const autofill::PasswordFormMap best_matches() const { |
85 return password_form_map_; | 87 return password_form_map_; |
86 } | 88 } |
87 | 89 |
88 const GURL& origin() const { return origin_; } | 90 const GURL& origin() const { return origin_; } |
89 | 91 |
90 protected: | 92 protected: |
91 explicit ManagePasswordsUIController( | 93 explicit ManagePasswordsUIController( |
92 content::WebContents* web_contents); | 94 content::WebContents* web_contents); |
93 | 95 |
| 96 // content::WebContentsObserver: |
| 97 virtual void DidNavigateMainFrame( |
| 98 const content::LoadCommittedDetails& details, |
| 99 const content::FrameNavigateParams& params) OVERRIDE; |
| 100 |
94 // All previously stored credentials for a specific site. Set by | 101 // All previously stored credentials for a specific site. Set by |
95 // OnPasswordSubmitted(), OnPasswordAutofilled(), or | 102 // OnPasswordSubmitted(), OnPasswordAutofilled(), or |
96 // OnBlacklistBlockedAutofill(). Protected, not private, so we can mess with | 103 // OnBlacklistBlockedAutofill(). Protected, not private, so we can mess with |
97 // the value in ManagePasswordsUIControllerMock. | 104 // the value in ManagePasswordsUIControllerMock. |
98 autofill::PasswordFormMap password_form_map_; | 105 autofill::PasswordFormMap password_form_map_; |
99 | 106 |
100 // We create copies of PasswordForm objects that come in via OnLoginsChanged() | 107 // We create copies of PasswordForm objects that come in via OnLoginsChanged() |
101 // and store them in this vector as well as in |password_form_map_| to ensure | 108 // and store them in this vector as well as in |password_form_map_| to ensure |
102 // that we destroy them correctly. | 109 // that we destroy them correctly. |
103 ScopedVector<autofill::PasswordForm> new_password_forms_; | 110 ScopedVector<autofill::PasswordForm> new_password_forms_; |
104 | 111 |
105 // The current state of the password manager. Protected so we can manipulate | 112 // The current state of the password manager. Protected so we can manipulate |
106 // the value in tests. | 113 // the value in tests. |
107 password_manager::ui::State state_; | 114 password_manager::ui::State state_; |
108 | 115 |
| 116 // Used to measure the amount of time on a page; if it's less than some |
| 117 // reasonable limit, then don't close the bubble upon navigation. We create |
| 118 // (and destroy) the timer in DidNavigateMainFrame. |
| 119 scoped_ptr<base::ElapsedTimer> timer_; |
| 120 |
109 private: | 121 private: |
110 friend class content::WebContentsUserData<ManagePasswordsUIController>; | 122 friend class content::WebContentsUserData<ManagePasswordsUIController>; |
111 | 123 |
112 // Shows the password bubble without user interaction. The controller MUST | 124 // Shows the password bubble without user interaction. The controller MUST |
113 // be in PENDING_PASSWORD_AND_BUBBLE_STATE. | 125 // be in PENDING_PASSWORD_AND_BUBBLE_STATE. |
114 void ShowBubbleWithoutUserInteraction(); | 126 void ShowBubbleWithoutUserInteraction(); |
115 | 127 |
116 // Called when a passwordform is autofilled, when a new passwordform is | 128 // Called when a passwordform is autofilled, when a new passwordform is |
117 // submitted, or when a navigation occurs to update the visibility of the | 129 // submitted, or when a navigation occurs to update the visibility of the |
118 // manage passwords icon and bubble. | 130 // manage passwords icon and bubble. |
119 void UpdateBubbleAndIconVisibility(); | 131 void UpdateBubbleAndIconVisibility(); |
120 | 132 |
121 // content::WebContentsObserver: | 133 // content::WebContentsObserver: |
122 virtual void DidNavigateMainFrame( | |
123 const content::LoadCommittedDetails& details, | |
124 const content::FrameNavigateParams& params) OVERRIDE; | |
125 virtual void WebContentsDestroyed() OVERRIDE; | 134 virtual void WebContentsDestroyed() OVERRIDE; |
126 | 135 |
127 // Set by OnPasswordSubmitted() when the user submits a form containing login | 136 // Set by OnPasswordSubmitted() when the user submits a form containing login |
128 // information. If the user responds to a subsequent "Do you want to save | 137 // information. If the user responds to a subsequent "Do you want to save |
129 // this password?" prompt, we ask this object to save or blacklist the | 138 // this password?" prompt, we ask this object to save or blacklist the |
130 // associated login information in Chrome's password store. | 139 // associated login information in Chrome's password store. |
131 scoped_ptr<password_manager::PasswordFormManager> form_manager_; | 140 scoped_ptr<password_manager::PasswordFormManager> form_manager_; |
132 | 141 |
133 // Stores whether autofill was blocked due to a user's decision to blacklist | 142 // Stores whether autofill was blocked due to a user's decision to blacklist |
134 // the current site ("Never save passwords for this site"). | 143 // the current site ("Never save passwords for this site"). |
135 bool autofill_blocked_; | 144 bool autofill_blocked_; |
136 | 145 |
137 // The origin of the form we're currently dealing with; we'll use this to | 146 // The origin of the form we're currently dealing with; we'll use this to |
138 // determine which PasswordStore changes we should care about when updating | 147 // determine which PasswordStore changes we should care about when updating |
139 // |password_form_map_|. | 148 // |password_form_map_|. |
140 GURL origin_; | 149 GURL origin_; |
141 | 150 |
142 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); | 151 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); |
143 }; | 152 }; |
144 | 153 |
145 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ | 154 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ |
OLD | NEW |