| 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_suggestion_controller.h" | 5 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 8 #include "base/ios/weak_nsobject.h" | 10 #include "base/ios/weak_nsobject.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 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "components/autofill/core/browser/autofill_field_trial_ios.h" | 16 #include "components/autofill/core/browser/autofill_field_trial_ios.h" |
| 16 #include "components/autofill/core/browser/autofill_popup_delegate.h" | 17 #include "components/autofill/core/browser/autofill_popup_delegate.h" |
| 17 #import "components/autofill/ios/browser/form_suggestion.h" | 18 #import "components/autofill/ios/browser/form_suggestion.h" |
| 18 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" | 19 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" |
| 19 #import "ios/chrome/browser/autofill/form_suggestion_provider.h" | 20 #import "ios/chrome/browser/autofill/form_suggestion_provider.h" |
| 20 #import "ios/chrome/browser/autofill/form_suggestion_view.h" | 21 #import "ios/chrome/browser/autofill/form_suggestion_view.h" |
| 21 #import "ios/chrome/browser/passwords/password_generation_utils.h" | 22 #import "ios/chrome/browser/passwords/password_generation_utils.h" |
| 22 #include "ios/chrome/browser/ui/ui_util.h" | 23 #include "ios/chrome/browser/ui/ui_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 | 53 |
| 53 @interface FormSuggestionController () <FormInputAccessoryViewProvider> { | 54 @interface FormSuggestionController () <FormInputAccessoryViewProvider> { |
| 54 // Form navigation delegate. | 55 // Form navigation delegate. |
| 55 base::WeakNSProtocol<id<FormInputAccessoryViewDelegate>> _delegate; | 56 base::WeakNSProtocol<id<FormInputAccessoryViewDelegate>> _delegate; |
| 56 | 57 |
| 57 // Callback to update the accessory view. | 58 // Callback to update the accessory view. |
| 58 base::mac::ScopedBlock<AccessoryViewReadyCompletion> | 59 base::mac::ScopedBlock<AccessoryViewReadyCompletion> |
| 59 accessoryViewUpdateBlock_; | 60 accessoryViewUpdateBlock_; |
| 60 | 61 |
| 61 // Autofill suggestion state. | 62 // Autofill suggestion state. |
| 62 scoped_ptr<AutofillSuggestionState> _suggestionState; | 63 std::unique_ptr<AutofillSuggestionState> _suggestionState; |
| 63 | 64 |
| 64 // Providers for suggestions, sorted according to the order in which | 65 // Providers for suggestions, sorted according to the order in which |
| 65 // they should be asked for suggestions, with highest priority in front. | 66 // they should be asked for suggestions, with highest priority in front. |
| 66 base::scoped_nsobject<NSArray> _suggestionProviders; | 67 base::scoped_nsobject<NSArray> _suggestionProviders; |
| 67 | 68 |
| 68 // Access to WebView from the CRWWebController. | 69 // Access to WebView from the CRWWebController. |
| 69 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; | 70 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; |
| 70 } | 71 } |
| 71 | 72 |
| 72 // Returns an autoreleased input accessory view that shows |suggestions|. | 73 // Returns an autoreleased input accessory view that shows |suggestions|. |
| 73 - (UIView*)suggestionViewWithSuggestions:(NSArray*)suggestions; | 74 - (UIView*)suggestionViewWithSuggestions:(NSArray*)suggestions; |
| 74 | 75 |
| 75 // Updates keyboard for |suggestionState|. | 76 // Updates keyboard for |suggestionState|. |
| 76 - (void)updateKeyboard:(AutofillSuggestionState*)suggestionState; | 77 - (void)updateKeyboard:(AutofillSuggestionState*)suggestionState; |
| 77 | 78 |
| 78 // Updates keyboard with |suggestions|. | 79 // Updates keyboard with |suggestions|. |
| 79 - (void)updateKeyboardWithSuggestions:(NSArray*)suggestions; | 80 - (void)updateKeyboardWithSuggestions:(NSArray*)suggestions; |
| 80 | 81 |
| 81 // Clears state in between page loads. | 82 // Clears state in between page loads. |
| 82 - (void)resetSuggestionState; | 83 - (void)resetSuggestionState; |
| 83 | 84 |
| 84 @end | 85 @end |
| 85 | 86 |
| 86 @implementation FormSuggestionController { | 87 @implementation FormSuggestionController { |
| 87 // Bridge to observe the web state from Objective-C. | 88 // Bridge to observe the web state from Objective-C. |
| 88 scoped_ptr<web::WebStateObserverBridge> _webStateObserverBridge; | 89 std::unique_ptr<web::WebStateObserverBridge> _webStateObserverBridge; |
| 89 | 90 |
| 90 // Manager for FormSuggestion JavaScripts. | 91 // Manager for FormSuggestion JavaScripts. |
| 91 base::scoped_nsobject<JsSuggestionManager> _jsSuggestionManager; | 92 base::scoped_nsobject<JsSuggestionManager> _jsSuggestionManager; |
| 92 | 93 |
| 93 // The provider for the current set of suggestions. | 94 // The provider for the current set of suggestions. |
| 94 id<FormSuggestionProvider> _provider; // weak | 95 id<FormSuggestionProvider> _provider; // weak |
| 95 } | 96 } |
| 96 | 97 |
| 97 - (instancetype)initWithWebState:(web::WebState*)webState | 98 - (instancetype)initWithWebState:(web::WebState*)webState |
| 98 providers:(NSArray*)providers | 99 providers:(NSArray*)providers |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 364 |
| 364 - (void)resizeAccessoryView { | 365 - (void)resizeAccessoryView { |
| 365 [self updateKeyboard:_suggestionState.get()]; | 366 [self updateKeyboard:_suggestionState.get()]; |
| 366 } | 367 } |
| 367 | 368 |
| 368 - (BOOL)getLogKeyboardAccessoryMetrics { | 369 - (BOOL)getLogKeyboardAccessoryMetrics { |
| 369 return YES; | 370 return YES; |
| 370 } | 371 } |
| 371 | 372 |
| 372 @end | 373 @end |
| OLD | NEW |