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
3 // found in the LICENSE file.
5 #include "components/autofill/ios/browser/autofill_driver_ios.h"
7 #include "components/autofill/ios/browser/autofill_driver_ios_bridge.h"
8 #include "ios/web/public/browser_state.h"
9 #include "ios/web/public/web_state/web_state.h"
10 #include "ios/web/public/web_thread.h"
12 DEFINE_WEB_STATE_USER_DATA_KEY(autofill::AutofillDriverIOS);
17 void AutofillDriverIOS::CreateForWebStateAndDelegate(
18 web::WebState* web_state,
19 AutofillClient* client,
20 id<AutofillDriverIOSBridge> bridge,
21 const std::string& app_locale,
22 AutofillManager::AutofillDownloadManagerState enable_download_manager) {
23 if (FromWebState(web_state))
26 web_state->SetUserData(
28 new AutofillDriverIOS(web_state, client, bridge, app_locale,
29 enable_download_manager));
32 AutofillDriverIOS::AutofillDriverIOS(
33 web::WebState* web_state,
34 AutofillClient* client,
35 id<AutofillDriverIOSBridge> bridge,
36 const std::string& app_locale,
37 AutofillManager::AutofillDownloadManagerState enable_download_manager)
38 : web_state_(web_state),
40 autofill_manager_(this, client, app_locale, enable_download_manager),
41 autofill_external_delegate_(&autofill_manager_, this) {
42 autofill_manager_.SetExternalDelegate(&autofill_external_delegate_);
45 AutofillDriverIOS::~AutofillDriverIOS() {}
47 bool AutofillDriverIOS::IsOffTheRecord() const {
48 return web_state_->GetBrowserState()->IsOffTheRecord();
51 net::URLRequestContextGetter* AutofillDriverIOS::GetURLRequestContext() {
52 return web_state_->GetBrowserState()->GetRequestContext();
55 base::SequencedWorkerPool* AutofillDriverIOS::GetBlockingPool() {
56 return web::WebThread::GetBlockingPool();
59 bool AutofillDriverIOS::RendererIsAvailable() {
63 void AutofillDriverIOS::SendFormDataToRenderer(
65 RendererFormDataAction action,
66 const FormData& data) {
67 [bridge_ onFormDataFilled:query_id result:data];
70 void AutofillDriverIOS::PingRenderer() {
73 void AutofillDriverIOS::DetectAccountCreationForms(
74 const std::vector<autofill::FormStructure*>& forms) {
75 autofill_manager_.client()->DetectAccountCreationForms(nullptr, forms);
78 void AutofillDriverIOS::SendAutofillTypePredictionsToRenderer(
79 const std::vector<FormStructure*>& forms) {
80 [bridge_ sendAutofillTypePredictionsToRenderer:forms];
83 void AutofillDriverIOS::RendererShouldAcceptDataListSuggestion(
84 const base::string16& value) {
87 void AutofillDriverIOS::RendererShouldClearFilledForm() {
90 void AutofillDriverIOS::RendererShouldClearPreviewedForm() {
93 void AutofillDriverIOS::RendererShouldFillFieldWithValue(
94 const base::string16& value) {
97 void AutofillDriverIOS::RendererShouldPreviewFieldWithValue(
98 const base::string16& value) {
101 void AutofillDriverIOS::PopupHidden() {
104 } // namespace autofill