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