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 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
6 | 6 |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "chrome/browser/password_manager/password_store_factory.h" | 9 #include "chrome/browser/password_manager/password_store_factory.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 void ManagePasswordsBubbleModel::OnOKClicked() { | 160 void ManagePasswordsBubbleModel::OnOKClicked() { |
161 dismissal_reason_ = metrics_util::CLICKED_OK; | 161 dismissal_reason_ = metrics_util::CLICKED_OK; |
162 } | 162 } |
163 | 163 |
164 void ManagePasswordsBubbleModel::OnManageLinkClicked() { | 164 void ManagePasswordsBubbleModel::OnManageLinkClicked() { |
165 dismissal_reason_ = metrics_util::CLICKED_MANAGE; | 165 dismissal_reason_ = metrics_util::CLICKED_MANAGE; |
166 ManagePasswordsUIController::FromWebContents(web_contents()) | 166 ManagePasswordsUIController::FromWebContents(web_contents()) |
167 ->NavigateToPasswordManagerSettingsPage(); | 167 ->NavigateToPasswordManagerSettingsPage(); |
168 } | 168 } |
169 | 169 |
170 // TODO(gcasto): Is it worth having a new dismissal reason to distinguish | |
171 // the two management cases? User intention is pretty similar between the two, | |
172 // but the context in which they are shown is pretty different since one is | |
173 // from an explict action and the other isn't. | |
174 void ManagePasswordsBubbleModel::OnRemoteManageLinkClicked() { | |
175 dismissal_reason_ = metrics_util::CLICKED_MANAGE; | |
176 ManagePasswordsUIController::FromWebContents(web_contents()) | |
177 ->NavigateToAccountCentralManagementPage(); | |
178 } | |
179 | |
180 void ManagePasswordsBubbleModel::OnPasswordAction( | 170 void ManagePasswordsBubbleModel::OnPasswordAction( |
181 const autofill::PasswordForm& password_form, | 171 const autofill::PasswordForm& password_form, |
182 PasswordAction action) { | 172 PasswordAction action) { |
183 if (!web_contents()) | 173 if (!web_contents()) |
184 return; | 174 return; |
185 Profile* profile = | 175 Profile* profile = |
186 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 176 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
187 password_manager::PasswordStore* password_store = | 177 password_manager::PasswordStore* password_store = |
188 PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS) | 178 PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS) |
189 .get(); | 179 .get(); |
190 DCHECK(password_store); | 180 DCHECK(password_store); |
191 if (action == REMOVE_PASSWORD) | 181 if (action == REMOVE_PASSWORD) |
192 password_store->RemoveLogin(password_form); | 182 password_store->RemoveLogin(password_form); |
193 else | 183 else |
194 password_store->AddLogin(password_form); | 184 password_store->AddLogin(password_form); |
195 } | 185 } |
196 | 186 |
197 // static | 187 // static |
198 int ManagePasswordsBubbleModel::UsernameFieldWidth() { | 188 int ManagePasswordsBubbleModel::UsernameFieldWidth() { |
199 return GetFieldWidth(USERNAME_FIELD); | 189 return GetFieldWidth(USERNAME_FIELD); |
200 } | 190 } |
201 | 191 |
202 // static | 192 // static |
203 int ManagePasswordsBubbleModel::PasswordFieldWidth() { | 193 int ManagePasswordsBubbleModel::PasswordFieldWidth() { |
204 return GetFieldWidth(PASSWORD_FIELD); | 194 return GetFieldWidth(PASSWORD_FIELD); |
205 } | 195 } |
OLD | NEW |