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. 4 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_H_ 7 8 #include <vector> 9 10 #include "components/autofill/core/common/form_data.h" 11 12 namespace content { 13 class WebContents; 14 } 15 16 namespace autofill { 17 18 class FormStructure; 19 20 // Interface that allows Autofill core code to interact with its driver (i.e., 21 // obtain information from it and give information to it). A concrete 22 // implementation must be provided by the driver. 23 class AutofillDriver { 24 public: 25 // The possible actions that the renderer can take on receiving form data. 26 enum RendererFormDataAction { 27 // The renderer should fill the form data. 28 FORM_DATA_ACTION_FILL, 29 // The renderer should preview the form data. 30 FORM_DATA_ACTION_PREVIEW 31 }; 32 33 virtual ~AutofillDriver() {} 34 35 // TODO(blundell): Remove this method once shared code no longer needs to 36 // know about WebContents. 37 virtual content::WebContents* GetWebContents() = 0; 38 39 // Returns true iff the renderer is available for communication. 40 virtual bool RendererIsAvailable() = 0; 41 42 // Informs the renderer what action to take with the next form data that it 43 // receives. Must be called before each call to |SendFormDataToRenderer|. 44 virtual void SetRendererActionOnFormDataReception( 45 RendererFormDataAction action) = 0; 46 47 // Forwards |data| to the renderer. |query_id| is the id of the renderer's 48 // original request for the data. This method is a no-op if the renderer is 49 // not currently available. 50 virtual void SendFormDataToRenderer(int query_id, const FormData& data) = 0; 51 52 // Sends the field type predictions specified in |forms| to the renderer. This 53 // method is a no-op if the renderer is not available or the appropriate 54 // command-line flag is not set. 55 virtual void SendAutofillTypePredictionsToRenderer( 56 const std::vector<FormStructure*>& forms) = 0; 57 58 // Tells the renderer to clear the currently filled Autofill results. 59 virtual void RendererShouldClearFilledForm() = 0; 60 61 // Tells the renderer to clear the currently previewed Autofill results. 62 virtual void RendererShouldClearPreviewedForm() = 0; 63 }; 64 65 } // namespace autofill 66 67 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_H_ 68