Commit 4394d66f authored by vasilii's avatar vasilii Committed by Commit Bot

Add a footer to the "Save password?" infobar.

It appears for the Chrome Sync users.

Bug: 890336
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I0a443b3d29670c00c28a847d6d2253db3a620996
Reviewed-on: https://chromium-review.googlesource.com/c/1270922Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598780}
parent 651f257e
......@@ -25,6 +25,8 @@ source_set("passwords") {
"ios_chrome_save_password_infobar_delegate.mm",
"ios_chrome_update_password_infobar_delegate.h",
"ios_chrome_update_password_infobar_delegate.mm",
"ios_password_infobar_controller.h",
"ios_password_infobar_controller.mm",
"js_credential_manager.h",
"js_credential_manager.mm",
"notify_auto_signin_view_controller.h",
......
......@@ -19,12 +19,15 @@ class PasswordFormManagerForUI;
// Base class for password manager infobar delegates, e.g.
// IOSChromeSavePasswordInfoBarDelegate and
// IOSChromeUpdatePasswordInfoBarDelegate. Provides link text and action for
// smart lock.
// IOSChromeUpdatePasswordInfoBarDelegate.
class IOSChromePasswordManagerInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
~IOSChromePasswordManagerInfoBarDelegate() override;
// Getter for the message displayed in addition to the title. If no message
// was set, this returns an empty string.
base::string16 GetDetailsMessageText() const;
protected:
IOSChromePasswordManagerInfoBarDelegate(
bool is_sync_user,
......
......@@ -8,7 +8,9 @@
#include "base/strings/string16.h"
#include "components/password_manager/core/browser/password_form_manager_for_ui.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ios/chrome/grit/ios_theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -26,6 +28,12 @@ IOSChromePasswordManagerInfoBarDelegate::
infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION),
is_sync_user_(is_sync_user) {}
base::string16 IOSChromePasswordManagerInfoBarDelegate::GetDetailsMessageText()
const {
return is_sync_user_ ? l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD_FOOTER)
: base::string16();
}
int IOSChromePasswordManagerInfoBarDelegate::GetIconId() const {
return IDR_IOS_INFOBAR_SAVE_PASSWORD;
};
......@@ -13,6 +13,8 @@
#include "components/password_manager/core/browser/password_form_metrics_recorder.h"
#include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/infobars/infobar.h"
#import "ios/chrome/browser/passwords/ios_password_infobar_controller.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -33,8 +35,11 @@ void IOSChromeSavePasswordInfoBarDelegate::Create(
auto delegate = base::WrapUnique(new IOSChromeSavePasswordInfoBarDelegate(
is_sync_user, std::move(form_to_save)));
delegate->set_dispatcher(dispatcher);
IOSPasswordInfoBarController* controller =
[[IOSPasswordInfoBarController alloc]
initWithInfoBarDelegate:delegate.get()];
infobar_manager->AddInfoBar(
infobar_manager->CreateConfirmInfoBar(std::move(delegate)));
std::make_unique<InfoBarIOS>(controller, std::move(delegate)));
}
IOSChromeSavePasswordInfoBarDelegate::~IOSChromeSavePasswordInfoBarDelegate() {
......
......@@ -42,8 +42,8 @@ void IOSChromeUpdatePasswordInfoBarDelegate::Create(
[[UpdatePasswordInfoBarController alloc]
initWithBaseViewController:baseViewController
infoBarDelegate:delegate.get()];
auto infobar = std::make_unique<InfoBarIOS>(controller, std::move(delegate));
infobar_manager->AddInfoBar(std::move(infobar));
infobar_manager->AddInfoBar(
std::make_unique<InfoBarIOS>(controller, std::move(delegate)));
}
IOSChromeUpdatePasswordInfoBarDelegate::
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_PASSWORDS_IOS_PASSWORD_INFOBAR_CONTROLLER_H_
#define IOS_CHROME_BROWSER_PASSWORDS_IOS_PASSWORD_INFOBAR_CONTROLLER_H_
#import "ios/chrome/browser/infobars/confirm_infobar_controller.h"
@interface IOSPasswordInfoBarController : ConfirmInfoBarController
@end
#endif // IOS_CHROME_BROWSER_PASSWORDS_IOS_PASSWORD_INFOBAR_CONTROLLER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/passwords/ios_password_infobar_controller.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/infobars/confirm_infobar_controller+protected.h"
#import "ios/chrome/browser/passwords/ios_chrome_password_manager_infobar_delegate.h"
#import "ios/chrome/browser/ui/infobars/confirm_infobar_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation IOSPasswordInfoBarController
- (void)updateInfobarLabel:(ConfirmInfoBarView*)view {
[super updateInfobarLabel:view];
auto* delegate = static_cast<IOSChromePasswordManagerInfoBarDelegate*>(
self.infoBarDelegate);
base::string16 message = delegate->GetDetailsMessageText();
if (message.empty())
return;
[view addFooterLabel:base::SysUTF16ToNSString(
delegate->GetDetailsMessageText())];
}
@end
......@@ -5,13 +5,13 @@
#ifndef IOS_CHROME_BROWSER_PASSWORDS_UPDATE_PASSWORD_INFOBAR_CONTROLLER_H_
#define IOS_CHROME_BROWSER_PASSWORDS_UPDATE_PASSWORD_INFOBAR_CONTROLLER_H_
#include "ios/chrome/browser/infobars/confirm_infobar_controller.h"
#import "ios/chrome/browser/passwords/ios_password_infobar_controller.h"
class IOSChromeUpdatePasswordInfoBarDelegate;
// Controller for the Update Password info bar. Presents an info bar that asks
// the user whether they want to update their password.
@interface UpdatePasswordInfoBarController : ConfirmInfoBarController
@interface UpdatePasswordInfoBarController : IOSPasswordInfoBarController
- (instancetype)init NS_UNAVAILABLE;
......
......@@ -60,6 +60,9 @@
target:(id)target
action:(SEL)action;
// Adds to the infobar a footer label below the title.
- (void)addFooterLabel:(NSString*)label;
@end
#endif // IOS_CHROME_BROWSER_UI_INFOBARS_CONFIRM_INFOBAR_VIEW_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment