Commit ba615ac7 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS] Creates a provider for Manualfill

Creates the provider that will contain the buttons to bring up manual
fallbacks for autofill. Gated behind the manual fill flag.

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ia36af25fc1e45f92e892b72a058b92d00c135b9c
Bug: 845472
Reviewed-on: https://chromium-review.googlesource.com/1135323
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575677}
parent 9ffaf123
......@@ -6,33 +6,14 @@ import("//ios/web/js_compile.gni")
source_set("manualfill") {
sources = [
"input_assistant_manualfill_view_controller.h",
"input_assistant_manualfill_view_controller.mm",
"manualfill_keyboard_view_controller.h",
"manualfill_keyboard_view_controller.mm",
"manualfill_view_controller.h",
"manualfill_view_controller.mm",
"password_picker_view_controller.h",
"password_picker_view_controller.mm",
"accessory_provider.h",
"accessory_provider.mm",
]
deps = [
":injected_js",
"//base",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/autofill",
"//ios/chrome/browser/ui/autofill/manualfill",
"//ios/web/public:public",
]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
js_compile_checked("injected_js") {
visibility = [ ":manualfill" ]
sources = [
"resources/manualfill_controller.js",
]
js_modules = [
"//components/autofill/ios/fill/resources/form.js",
"//components/autofill/ios/fill/resources/fill.js",
]
}
// 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_AUTOFILL_MANUALFILL_ACCESSORY_PROVIDER_H_
#define IOS_CHROME_BROWSER_AUTOFILL_MANUALFILL_ACCESSORY_PROVIDER_H_
#import "ios/chrome/browser/autofill/form_input_accessory_view_provider.h"
// Returns a default keyboard accessory view with entry points to manual
// fallbacks for form filling.
@interface ManualfillAccessoryProvider
: NSObject<FormInputAccessoryViewProvider>
@end
#endif // IOS_CHROME_BROWSER_AUTOFILL_MANUALFILL_ACCESSORY_PROVIDER_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/autofill/manualfill_accessory_provider.h"
#include "base/feature_list.h"
#import "base/mac/foundation_util.h"
#include "components/autofill/core/common/autofill_features.h"
#import "ios/chrome/browser/ui/autofill/manualfill/keyboard_accessory_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface ManualfillAccessoryProvider ()
// The default accesory view to return in the update block.
@property(nonatomic, readonly) KeyboardAccessoryView* accessoryView;
// Callback to update the accessory view.
@property(nonatomic, copy)
AccessoryViewReadyCompletion accessoryViewUpdateBlock;
@end
@implementation ManualfillAccessoryProvider
@synthesize accessoryViewDelegate = _accessoryViewDelegate;
@synthesize accessoryView = _accessoryView;
@synthesize accessoryViewUpdateBlock = _accessoryViewUpdateBlock;
#pragma mark - FormInputAccessoryViewProvider
- (void)retrieveAccessoryViewForForm:(const web::FormActivityParams&)params
webState:(web::WebState*)webState
accessoryViewUpdateBlock:
(AccessoryViewReadyCompletion)accessoryViewUpdateBlock {
DCHECK(accessoryViewUpdateBlock);
BOOL isManualfillEnabled =
base::FeatureList::IsEnabled(autofill::features::kAutofillManualFallback);
if (!isManualfillEnabled) {
accessoryViewUpdateBlock(nil, self);
return;
}
accessoryViewUpdateBlock(self.accessoryView, self);
self.accessoryViewUpdateBlock = accessoryViewUpdateBlock;
}
- (void)inputAccessoryViewControllerDidReset:
(FormInputAccessoryViewController*)controller {
self.accessoryViewUpdateBlock = nil;
}
- (void)resizeAccessoryView {
DCHECK(_accessoryViewUpdateBlock);
self.accessoryViewUpdateBlock(self.accessoryView, self);
}
#pragma mark - Getters
- (KeyboardAccessoryView*)accessoryView {
if (!_accessoryView) {
_accessoryView = [[KeyboardAccessoryView alloc] initWithDelegate:nil];
}
return _accessoryView;
}
@end
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