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

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: merge with the trunk 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 if (IsNewUIActive()) {
Mike West 2015/03/18 08:33:51 Optional nit: I'd vaguely prefer `title_ = IsNewUI
vasilii 2015/03/18 09:25:08 Done.
118 title_ = l10n_util::GetStringFUTF16(IDS_MANAGE_ACCOUNTS_TITLE,
119 base::UTF8ToUTF16(origin_.spec()));
120 } else {
121 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE);
122 }
115 } 123 }
116 124
117 if (state_ == password_manager::ui::CONFIRMATION_STATE) { 125 if (state_ == password_manager::ui::CONFIRMATION_STATE) {
118 base::string16 save_confirmation_link = 126 base::string16 save_confirmation_link =
119 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_LINK); 127 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_LINK);
120 size_t offset; 128 size_t offset;
121 save_confirmation_text_ = 129 save_confirmation_text_ =
122 l10n_util::GetStringFUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TEXT, 130 l10n_util::GetStringFUTF16(IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TEXT,
123 save_confirmation_link, &offset); 131 save_confirmation_link, &offset);
124 save_confirmation_link_range_ = 132 save_confirmation_link_range_ =
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 void ManagePasswordsBubbleModel::OnManageLinkClicked() { 246 void ManagePasswordsBubbleModel::OnManageLinkClicked() {
239 dismissal_reason_ = metrics_util::CLICKED_MANAGE; 247 dismissal_reason_ = metrics_util::CLICKED_MANAGE;
240 ManagePasswordsUIController::FromWebContents(web_contents()) 248 ManagePasswordsUIController::FromWebContents(web_contents())
241 ->NavigateToPasswordManagerSettingsPage(); 249 ->NavigateToPasswordManagerSettingsPage();
242 } 250 }
243 251
244 void ManagePasswordsBubbleModel::OnAutoSignInToastTimeout() { 252 void ManagePasswordsBubbleModel::OnAutoSignInToastTimeout() {
245 dismissal_reason_ = metrics_util::AUTO_SIGNIN_TOAST_TIMEOUT; 253 dismissal_reason_ = metrics_util::AUTO_SIGNIN_TOAST_TIMEOUT;
246 } 254 }
247 255
256 void ManagePasswordsBubbleModel::OnAutoSignInClicked() {
257 dismissal_reason_ = metrics_util::AUTO_SIGNIN_TOAST_CLICKED;
258 ManagePasswordsUIController* manage_passwords_ui_controller =
259 ManagePasswordsUIController::FromWebContents(web_contents());
260 manage_passwords_ui_controller->ManageAccounts();
261 state_ = password_manager::ui::MANAGE_STATE;
262 }
263
248 void ManagePasswordsBubbleModel::OnPasswordAction( 264 void ManagePasswordsBubbleModel::OnPasswordAction(
249 const autofill::PasswordForm& password_form, 265 const autofill::PasswordForm& password_form,
250 PasswordAction action) { 266 PasswordAction action) {
251 if (!web_contents()) 267 if (!web_contents())
252 return; 268 return;
253 Profile* profile = 269 Profile* profile =
254 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 270 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
255 password_manager::PasswordStore* password_store = 271 password_manager::PasswordStore* password_store =
256 PasswordStoreFactory::GetForProfile( 272 PasswordStoreFactory::GetForProfile(
257 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); 273 profile, ServiceAccessType::EXPLICIT_ACCESS).get();
(...skipping 13 matching lines...) Expand all
271 ManagePasswordsUIController::FromWebContents(web_contents()); 287 ManagePasswordsUIController::FromWebContents(web_contents());
272 manage_passwords_ui_controller->ChooseCredential(password_form, 288 manage_passwords_ui_controller->ChooseCredential(password_form,
273 credential_type); 289 credential_type);
274 state_ = password_manager::ui::INACTIVE_STATE; 290 state_ = password_manager::ui::INACTIVE_STATE;
275 } 291 }
276 292
277 Profile* ManagePasswordsBubbleModel::GetProfile() const { 293 Profile* ManagePasswordsBubbleModel::GetProfile() const {
278 return GetProfileFromWebContents(web_contents()); 294 return GetProfileFromWebContents(web_contents());
279 } 295 }
280 296
297 bool ManagePasswordsBubbleModel::IsNewUIActive() const {
298 return base::CommandLine::ForCurrentProcess()->HasSwitch(
299 switches::kEnableCredentialManagerAPI);
300 }
301
281 // static 302 // static
282 int ManagePasswordsBubbleModel::UsernameFieldWidth() { 303 int ManagePasswordsBubbleModel::UsernameFieldWidth() {
283 return GetFieldWidth(USERNAME_FIELD); 304 return GetFieldWidth(USERNAME_FIELD);
284 } 305 }
285 306
286 // static 307 // static
287 int ManagePasswordsBubbleModel::PasswordFieldWidth() { 308 int ManagePasswordsBubbleModel::PasswordFieldWidth() {
288 return GetFieldWidth(PASSWORD_FIELD); 309 return GetFieldWidth(PASSWORD_FIELD);
289 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698