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_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/supports_user_data.h"
12 #include "components/autofill/core/browser/autofill_driver.h"
13 #include "components/autofill/core/browser/autofill_external_delegate.h"
14 #include "components/autofill/core/browser/autofill_manager.h"
15 #include "content/public/browser/web_contents_observer.h"
27 class AutofillContext;
28 class AutofillManagerDelegate;
30 // Class that drives autofill flow in the browser process based on
31 // communication from the renderer and from the external world. There is one
32 // instance per WebContents.
33 class AutofillDriverImpl : public AutofillDriver,
34 public content::WebContentsObserver,
35 public base::SupportsUserData::Data {
37 static void CreateForWebContentsAndDelegate(
38 content::WebContents* contents,
39 autofill::AutofillManagerDelegate* delegate,
40 const std::string& app_locale,
41 AutofillManager::AutofillDownloadManagerState enable_download_manager);
42 static AutofillDriverImpl* FromWebContents(content::WebContents* contents);
45 virtual content::WebContents* GetWebContents() OVERRIDE;
46 virtual base::SequencedWorkerPool* GetBlockingPool() OVERRIDE;
47 virtual bool RendererIsAvailable() OVERRIDE;
48 virtual void SetRendererActionOnFormDataReception(
49 RendererFormDataAction action) OVERRIDE;
50 virtual void SendFormDataToRenderer(int query_id,
51 const FormData& data) OVERRIDE;
52 virtual void SendAutofillTypePredictionsToRenderer(
53 const std::vector<FormStructure*>& forms) OVERRIDE;
54 virtual void RendererShouldClearFilledForm() OVERRIDE;
55 virtual void RendererShouldClearPreviewedForm() OVERRIDE;
57 AutofillExternalDelegate* autofill_external_delegate() {
58 return &autofill_external_delegate_;
61 AutofillManager* autofill_manager() { return autofill_manager_.get(); }
65 content::WebContents* web_contents,
66 autofill::AutofillManagerDelegate* delegate,
67 const std::string& app_locale,
68 AutofillManager::AutofillDownloadManagerState enable_download_manager);
69 virtual ~AutofillDriverImpl();
71 // content::WebContentsObserver:
72 virtual void DidNavigateMainFrame(
73 const content::LoadCommittedDetails& details,
74 const content::FrameNavigateParams& params) OVERRIDE;
75 virtual void NavigationEntryCommitted(
76 const content::LoadCommittedDetails& load_details) OVERRIDE;
77 virtual void WasHidden() OVERRIDE;
78 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
80 // Sets the manager to |manager| and sets |manager|'s external delegate
81 // to |autofill_external_delegate_|. Takes ownership of |manager|.
82 void SetAutofillManager(scoped_ptr<AutofillManager> manager);
85 // AutofillManager instance via which this object drives the shared Autofill
87 scoped_ptr<AutofillManager> autofill_manager_;
89 // AutofillExternalDelegate instance that this object instantiates in the
90 // case where the Autofill native UI is enabled.
91 AutofillExternalDelegate autofill_external_delegate_;
94 } // namespace autofill
96 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_