Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_driver.h
blob748ad6e5b4a87be08347eae195f74e5700da2b7b
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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_H_
8 #include <vector>
10 #include "components/autofill/core/common/form_data.h"
12 namespace base {
13 class SequencedWorkerPool;
16 namespace net {
17 class URLRequestContextGetter;
20 namespace autofill {
22 class FormStructure;
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.
27 class 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
37 virtual ~AutofillDriver() {}
39 // Returns whether the user is currently operating in an off-the-record
40 // (i.e., incognito) context.
41 virtual bool IsOffTheRecord() const = 0;
43 // Returns the URL request context information associated with this driver.
44 virtual net::URLRequestContextGetter* GetURLRequestContext() = 0;
46 // Returns the SequencedWorkerPool on which core Autofill code should run
47 // tasks that may block. This pool must live at least as long as the driver.
48 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
50 // Returns true iff the renderer is available for communication.
51 virtual bool RendererIsAvailable() = 0;
53 // Forwards |data| to the renderer. |query_id| is the id of the renderer's
54 // original request for the data. |action| is the action the renderer should
55 // perform with the |data|. This method is a no-op if the renderer is not
56 // currently available.
57 virtual void SendFormDataToRenderer(int query_id,
58 RendererFormDataAction action,
59 const FormData& data) = 0;
61 // Pings renderer. The renderer will return an IPC acknowledging the ping.
62 virtual void PingRenderer() = 0;
64 // Sends the field type predictions specified in |forms| to the renderer. This
65 // method is a no-op if the renderer is not available or the appropriate
66 // command-line flag is not set.
67 virtual void SendAutofillTypePredictionsToRenderer(
68 const std::vector<FormStructure*>& forms) = 0;
70 // Tells the renderer to accept data list suggestions for |value|.
71 virtual void RendererShouldAcceptDataListSuggestion(
72 const base::string16& value) = 0;
74 // Tells the renderer to clear the currently filled Autofill results.
75 virtual void RendererShouldClearFilledForm() = 0;
77 // Tells the renderer to clear the currently previewed Autofill results.
78 virtual void RendererShouldClearPreviewedForm() = 0;
80 // Tells the renderer to set the node text.
81 virtual void RendererShouldFillFieldWithValue(
82 const base::string16& value) = 0;
84 // Tells the renderer to preview the node with suggested text.
85 virtual void RendererShouldPreviewFieldWithValue(
86 const base::string16& value) = 0;
89 } // namespace autofill
91 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_H_