Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc

Issue 952023002: Credential Manager API: pop up the new "Manage accounts" bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the test Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/command_line.h"
8 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/password_manager/password_store_factory.h" 9 #include "chrome/browser/password_manager/password_store_factory.h"
8 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 12 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
12 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" 14 #include "chrome/browser/ui/passwords/password_bubble_experiment.h"
13 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
14 #include "components/feedback/feedback_data.h" 16 #include "components/feedback/feedback_data.h"
15 #include "components/feedback/feedback_util.h" 17 #include "components/feedback/feedback_util.h"
16 #include "components/password_manager/content/common/credential_manager_types.h" 18 #include "components/password_manager/content/common/credential_manager_types.h"
17 #include "components/password_manager/core/browser/password_store.h" 19 #include "components/password_manager/core/browser/password_store.h"
18 #include "components/password_manager/core/common/password_manager_ui.h" 20 #include "components/password_manager/core/common/password_manager_ui.h"
19 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/common/content_switches.h"
20 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
22 25
23 using autofill::PasswordFormMap; 26 using autofill::PasswordFormMap;
24 using feedback::FeedbackData; 27 using feedback::FeedbackData;
25 using content::WebContents; 28 using content::WebContents;
26 namespace metrics_util = password_manager::metrics_util; 29 namespace metrics_util = password_manager::metrics_util;
27 30
28 namespace { 31 namespace {
29 32
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } else if (state_ == password_manager::ui::BLACKLIST_STATE) { 107 } else if (state_ == password_manager::ui::BLACKLIST_STATE) {
105 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE); 108 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE);
106 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) { 109 } else if (state_ == password_manager::ui::CONFIRMATION_STATE) {
107 title_ = 110 title_ =
108 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE); 111 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TITLE);
109 } else if (state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { 112 } else if (state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) {
110 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE); 113 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE);
111 } else if (state_ == password_manager::ui::AUTO_SIGNIN_STATE) { 114 } else if (state_ == password_manager::ui::AUTO_SIGNIN_STATE) {
112 // There is no title. 115 // There is no title.
113 } else { 116 } else {
114 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); 117 title_ = IsNewUIActive() ?
118 l10n_util::GetStringFUTF16(IDS_MANAGE_ACCOUNTS_TITLE,
119 base::UTF8ToUTF16(origin_.spec())) :
120 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE);
115 } 121 }
116 122
117 if (state_ == password_manager::ui::CONFIRMATION_STATE) { 123 if (state_ == password_manager::ui::CONFIRMATION_STATE) {
118 base::string16 save_confirmation_link = 124 base::string16 save_confirmation_link =
119 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_LINK); 125 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_LINK);
120 size_t offset; 126 size_t offset;
121 save_confirmation_text_ = 127 save_confirmation_text_ =
122 l10n_util::GetStringFUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TEXT, 128 l10n_util::GetStringFUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TEXT,
123 save_confirmation_link, &offset); 129 save_confirmation_link, &offset);
124 save_confirmation_link_range_ = 130 save_confirmation_link_range_ =
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 void ManagePasswordsBubbleModel::OnManageLinkClicked() { 244 void ManagePasswordsBubbleModel::OnManageLinkClicked() {
239 dismissal_reason_ = metrics_util::CLICKED_MANAGE; 245 dismissal_reason_ = metrics_util::CLICKED_MANAGE;
240 ManagePasswordsUIController::FromWebContents(web_contents()) 246 ManagePasswordsUIController::FromWebContents(web_contents())
241 ->NavigateToPasswordManagerSettingsPage(); 247 ->NavigateToPasswordManagerSettingsPage();
242 } 248 }
243 249
244 void ManagePasswordsBubbleModel::OnAutoSignInToastTimeout() { 250 void ManagePasswordsBubbleModel::OnAutoSignInToastTimeout() {
245 dismissal_reason_ = metrics_util::AUTO_SIGNIN_TOAST_TIMEOUT; 251 dismissal_reason_ = metrics_util::AUTO_SIGNIN_TOAST_TIMEOUT;
246 } 252 }
247 253
254 void ManagePasswordsBubbleModel::OnAutoSignInClicked() {
255 dismissal_reason_ = metrics_util::AUTO_SIGNIN_TOAST_CLICKED;
256 ManagePasswordsUIController* manage_passwords_ui_controller =
257 ManagePasswordsUIController::FromWebContents(web_contents());
258 manage_passwords_ui_controller->ManageAccounts();
259 state_ = password_manager::ui::MANAGE_STATE;
260 }
261
248 void ManagePasswordsBubbleModel::OnPasswordAction( 262 void ManagePasswordsBubbleModel::OnPasswordAction(
249 const autofill::PasswordForm& password_form, 263 const autofill::PasswordForm& password_form,
250 PasswordAction action) { 264 PasswordAction action) {
251 if (!web_contents()) 265 if (!web_contents())
252 return; 266 return;
253 Profile* profile = 267 Profile* profile =
254 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 268 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
255 password_manager::PasswordStore* password_store = 269 password_manager::PasswordStore* password_store =
256 PasswordStoreFactory::GetForProfile( 270 PasswordStoreFactory::GetForProfile(
257 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); 271 profile, ServiceAccessType::EXPLICIT_ACCESS).get();
(...skipping 13 matching lines...) Expand all
271 ManagePasswordsUIController::FromWebContents(web_contents()); 285 ManagePasswordsUIController::FromWebContents(web_contents());
272 manage_passwords_ui_controller->ChooseCredential(password_form, 286 manage_passwords_ui_controller->ChooseCredential(password_form,
273 credential_type); 287 credential_type);
274 state_ = password_manager::ui::INACTIVE_STATE; 288 state_ = password_manager::ui::INACTIVE_STATE;
275 } 289 }
276 290
277 Profile* ManagePasswordsBubbleModel::GetProfile() const { 291 Profile* ManagePasswordsBubbleModel::GetProfile() const {
278 return GetProfileFromWebContents(web_contents()); 292 return GetProfileFromWebContents(web_contents());
279 } 293 }
280 294
295 bool ManagePasswordsBubbleModel::IsNewUIActive() const {
296 return base::CommandLine::ForCurrentProcess()->HasSwitch(
297 switches::kEnableCredentialManagerAPI);
298 }
299
281 // static 300 // static
282 int ManagePasswordsBubbleModel::UsernameFieldWidth() { 301 int ManagePasswordsBubbleModel::UsernameFieldWidth() {
283 return GetFieldWidth(USERNAME_FIELD); 302 return GetFieldWidth(USERNAME_FIELD);
284 } 303 }
285 304
286 // static 305 // static
287 int ManagePasswordsBubbleModel::PasswordFieldWidth() { 306 int ManagePasswordsBubbleModel::PasswordFieldWidth() {
288 return GetFieldWidth(PASSWORD_FIELD); 307 return GetFieldWidth(PASSWORD_FIELD);
289 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698