| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" | 5 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/ios/block_types.h" | 9 #include "base/ios/block_types.h" |
| 8 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| 9 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/scoped_block.h" | 12 #include "base/mac/scoped_block.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #import "components/autofill/core/browser/keyboard_accessory_metrics_logger.h" | 14 #import "components/autofill/core/browser/keyboard_accessory_metrics_logger.h" |
| 14 #import "components/autofill/ios/browser/js_suggestion_manager.h" | 15 #import "components/autofill/ios/browser/js_suggestion_manager.h" |
| 15 #import "ios/chrome/browser/autofill/form_input_accessory_view.h" | 16 #import "ios/chrome/browser/autofill/form_input_accessory_view.h" |
| 16 #import "ios/chrome/browser/autofill/form_suggestion_view.h" | 17 #import "ios/chrome/browser/autofill/form_suggestion_view.h" |
| 17 #import "ios/chrome/browser/passwords/password_generation_utils.h" | 18 #import "ios/chrome/browser/passwords/password_generation_utils.h" |
| 18 #include "ios/chrome/browser/ui/ui_util.h" | 19 #include "ios/chrome/browser/ui/ui_util.h" |
| 19 #include "ios/web/public/test/crw_test_js_injection_receiver.h" | 20 #include "ios/web/public/test/crw_test_js_injection_receiver.h" |
| 20 #import "ios/web/public/url_scheme_util.h" | 21 #import "ios/web/public/url_scheme_util.h" |
| 21 #import "ios/web/public/web_state/crw_web_view_proxy.h" | 22 #import "ios/web/public/web_state/crw_web_view_proxy.h" |
| 22 #include "ios/web/public/web_state/url_verification_constants.h" | 23 #include "ios/web/public/web_state/url_verification_constants.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // The current web state. | 192 // The current web state. |
| 192 @property(nonatomic, readonly) web::WebState* webState; | 193 @property(nonatomic, readonly) web::WebState* webState; |
| 193 | 194 |
| 194 // The current web view proxy. | 195 // The current web view proxy. |
| 195 @property(nonatomic, readonly) id<CRWWebViewProxy> webViewProxy; | 196 @property(nonatomic, readonly) id<CRWWebViewProxy> webViewProxy; |
| 196 | 197 |
| 197 @end | 198 @end |
| 198 | 199 |
| 199 @implementation FormInputAccessoryViewController { | 200 @implementation FormInputAccessoryViewController { |
| 200 // Bridge to observe the web state from Objective-C. | 201 // Bridge to observe the web state from Objective-C. |
| 201 scoped_ptr<web::WebStateObserverBridge> _webStateObserverBridge; | 202 std::unique_ptr<web::WebStateObserverBridge> _webStateObserverBridge; |
| 202 | 203 |
| 203 // Last registered keyboard rectangle. | 204 // Last registered keyboard rectangle. |
| 204 CGRect _keyboardFrame; | 205 CGRect _keyboardFrame; |
| 205 | 206 |
| 206 // The custom view that should be shown in the input accessory view. | 207 // The custom view that should be shown in the input accessory view. |
| 207 base::scoped_nsobject<UIView> _customAccessoryView; | 208 base::scoped_nsobject<UIView> _customAccessoryView; |
| 208 | 209 |
| 209 // The JS manager for interacting with the underlying form. | 210 // The JS manager for interacting with the underlying form. |
| 210 base::scoped_nsobject<JsSuggestionManager> _JSSuggestionManager; | 211 base::scoped_nsobject<JsSuggestionManager> _JSSuggestionManager; |
| 211 | 212 |
| 212 // The original subviews in keyboard accessory view that were originally not | 213 // The original subviews in keyboard accessory view that were originally not |
| 213 // hidden but were hidden when showing Autofill suggestions. | 214 // hidden but were hidden when showing Autofill suggestions. |
| 214 base::scoped_nsobject<NSMutableArray> _hiddenOriginalSubviews; | 215 base::scoped_nsobject<NSMutableArray> _hiddenOriginalSubviews; |
| 215 | 216 |
| 216 // The objects that can provide a custom input accessory view while filling | 217 // The objects that can provide a custom input accessory view while filling |
| 217 // forms. | 218 // forms. |
| 218 base::scoped_nsobject<NSArray> _providers; | 219 base::scoped_nsobject<NSArray> _providers; |
| 219 | 220 |
| 220 // Whether suggestions have previously been shown. | 221 // Whether suggestions have previously been shown. |
| 221 BOOL _suggestionsHaveBeenShown; | 222 BOOL _suggestionsHaveBeenShown; |
| 222 | 223 |
| 223 // The object that manages the currently-shown custom accessory view. | 224 // The object that manages the currently-shown custom accessory view. |
| 224 base::WeakNSProtocol<id<FormInputAccessoryViewProvider>> _currentProvider; | 225 base::WeakNSProtocol<id<FormInputAccessoryViewProvider>> _currentProvider; |
| 225 | 226 |
| 226 // Logs UMA metrics for the keyboard accessory. | 227 // Logs UMA metrics for the keyboard accessory. |
| 227 scoped_ptr<autofill::KeyboardAccessoryMetricsLogger> | 228 std::unique_ptr<autofill::KeyboardAccessoryMetricsLogger> |
| 228 _keyboardAccessoryMetricsLogger; | 229 _keyboardAccessoryMetricsLogger; |
| 229 } | 230 } |
| 230 | 231 |
| 231 - (instancetype)initWithWebState:(web::WebState*)webState | 232 - (instancetype)initWithWebState:(web::WebState*)webState |
| 232 providers:(NSArray*)providers { | 233 providers:(NSArray*)providers { |
| 233 JsSuggestionManager* suggestionManager = | 234 JsSuggestionManager* suggestionManager = |
| 234 base::mac::ObjCCastStrict<JsSuggestionManager>( | 235 base::mac::ObjCCastStrict<JsSuggestionManager>( |
| 235 [webState->GetJSInjectionReceiver() | 236 [webState->GetJSInjectionReceiver() |
| 236 instanceOfClass:[JsSuggestionManager class]]); | 237 instanceOfClass:[JsSuggestionManager class]]); |
| 237 return [self initWithWebState:webState | 238 return [self initWithWebState:webState |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // that we don't present our custom view over the keyboard. | 648 // that we don't present our custom view over the keyboard. |
| 648 - (void)textInputDidBeginEditing:(NSNotification*)notification { | 649 - (void)textInputDidBeginEditing:(NSNotification*)notification { |
| 649 [self reset]; | 650 [self reset]; |
| 650 } | 651 } |
| 651 | 652 |
| 652 - (void)keyboardDidHide:(NSNotification*)notification { | 653 - (void)keyboardDidHide:(NSNotification*)notification { |
| 653 _keyboardFrame = CGRectZero; | 654 _keyboardFrame = CGRectZero; |
| 654 } | 655 } |
| 655 | 656 |
| 656 @end | 657 @end |
| OLD | NEW |