1 // Copyright 2014 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_CONTENT_AUTOFILL_DRIVER_FACTORY_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/supports_user_data.h"
12 #include "components/autofill/content/browser/request_autocomplete_manager.h"
13 #include "components/autofill/core/browser/autofill_manager.h"
14 #include "content/public/browser/web_contents_observer.h"
17 class RenderFrameHost
;
27 class ContentAutofillDriver
;
29 // Manages lifetime of ContentAutofillDriver. One Factory per WebContents
30 // creates one Driver per RenderFrame.
31 class ContentAutofillDriverFactory
: public content::WebContentsObserver
,
32 public base::SupportsUserData::Data
{
34 static void CreateForWebContentsAndDelegate(
35 content::WebContents
* contents
,
36 AutofillClient
* client
,
37 const std::string
& app_locale
,
38 AutofillManager::AutofillDownloadManagerState enable_download_manager
);
39 static ContentAutofillDriverFactory
* FromWebContents(
40 content::WebContents
* contents
);
42 // Gets the |ContentAutofillDriver| associated with |render_frame_host|.
43 // |render_frame_host| must be owned by |web_contents()|.
44 ContentAutofillDriver
* DriverForFrame(
45 content::RenderFrameHost
* render_frame_host
);
47 // content::WebContentsObserver:
48 bool OnMessageReceived(const IPC::Message
& message
,
49 content::RenderFrameHost
* render_frame_host
) override
;
50 void RenderFrameCreated(content::RenderFrameHost
* render_frame_host
) override
;
51 void RenderFrameDeleted(content::RenderFrameHost
* render_frame_host
) override
;
52 void DidNavigateAnyFrame(
53 content::RenderFrameHost
* render_frame_host
,
54 const content::LoadCommittedDetails
& details
,
55 const content::FrameNavigateParams
& params
) override
;
56 void NavigationEntryCommitted(
57 const content::LoadCommittedDetails
& load_details
) override
;
58 void WasHidden() override
;
60 static const char kContentAutofillDriverFactoryWebContentsUserDataKey
[];
63 ContentAutofillDriverFactory(
64 content::WebContents
* web_contents
,
65 AutofillClient
* client
,
66 const std::string
& app_locale
,
67 AutofillManager::AutofillDownloadManagerState enable_download_manager
);
68 ~ContentAutofillDriverFactory() override
;
71 void CreateDriverForFrame(content::RenderFrameHost
* render_frame_host
);
73 AutofillClient
* client_
;
74 std::string app_locale_
;
75 AutofillManager::AutofillDownloadManagerState enable_download_manager_
;
77 std::map
<content::RenderFrameHost
*, ContentAutofillDriver
*> frame_driver_map_
;
80 } // namespace autofill
82 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_