| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <memory> | |
| 10 #include <string> | 8 #include <string> |
| 11 | 9 |
| 12 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| 13 #include "components/autofill/content/common/autofill_driver.mojom.h" | 11 #include "components/autofill/content/common/autofill_driver.mojom.h" |
| 12 #include "components/autofill/core/browser/autofill_driver_factory.h" |
| 14 #include "components/autofill/core/browser/autofill_manager.h" | 13 #include "components/autofill/core/browser/autofill_manager.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 16 | 15 |
| 17 namespace content { | 16 namespace content { |
| 18 class RenderFrameHost; | 17 class RenderFrameHost; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace autofill { | 20 namespace autofill { |
| 22 | 21 |
| 23 class ContentAutofillDriver; | 22 class ContentAutofillDriver; |
| 24 | 23 |
| 25 // Manages lifetime of ContentAutofillDriver. One Factory per WebContents | 24 // Manages lifetime of ContentAutofillDriver. One Factory per WebContents |
| 26 // creates one Driver per RenderFrame. | 25 // creates one Driver per RenderFrame. |
| 27 class ContentAutofillDriverFactory : public content::WebContentsObserver, | 26 class ContentAutofillDriverFactory : public AutofillDriverFactory, |
| 27 public content::WebContentsObserver, |
| 28 public base::SupportsUserData::Data { | 28 public base::SupportsUserData::Data { |
| 29 public: | 29 public: |
| 30 ~ContentAutofillDriverFactory() override; | 30 ~ContentAutofillDriverFactory() override; |
| 31 | 31 |
| 32 static void CreateForWebContentsAndDelegate( | 32 static void CreateForWebContentsAndDelegate( |
| 33 content::WebContents* contents, | 33 content::WebContents* contents, |
| 34 AutofillClient* client, | 34 AutofillClient* client, |
| 35 const std::string& app_locale, | 35 const std::string& app_locale, |
| 36 AutofillManager::AutofillDownloadManagerState enable_download_manager); | 36 AutofillManager::AutofillDownloadManagerState enable_download_manager); |
| 37 static ContentAutofillDriverFactory* FromWebContents( | 37 static ContentAutofillDriverFactory* FromWebContents( |
| 38 content::WebContents* contents); | 38 content::WebContents* contents); |
| 39 static void BindAutofillDriver(content::RenderFrameHost* render_frame_host, | 39 static void BindAutofillDriver(content::RenderFrameHost* render_frame_host, |
| 40 mojom::AutofillDriverRequest request); | 40 mojom::AutofillDriverRequest request); |
| 41 | 41 |
| 42 // Gets the |ContentAutofillDriver| associated with |render_frame_host|. | 42 // Gets the |ContentAutofillDriver| associated with |render_frame_host|. |
| 43 // |render_frame_host| must be owned by |web_contents()|. | 43 // |render_frame_host| must be owned by |web_contents()|. |
| 44 ContentAutofillDriver* DriverForFrame( | 44 ContentAutofillDriver* DriverForFrame( |
| 45 content::RenderFrameHost* render_frame_host); | 45 content::RenderFrameHost* render_frame_host); |
| 46 | 46 |
| 47 // content::WebContentsObserver: | 47 // content::WebContentsObserver: |
| 48 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | 48 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
| 49 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 49 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 50 void DidFinishNavigation( | 50 void DidFinishNavigation( |
| 51 content::NavigationHandle* navigation_handle) override; | 51 content::NavigationHandle* navigation_handle) override; |
| 52 void WasHidden() override; | 52 void WasHidden() override; |
| 53 | 53 |
| 54 static const char kContentAutofillDriverFactoryWebContentsUserDataKey[]; | 54 static const char kContentAutofillDriverFactoryWebContentsUserDataKey[]; |
| 55 | 55 |
| 56 protected: | 56 private: |
| 57 ContentAutofillDriverFactory( | 57 ContentAutofillDriverFactory( |
| 58 content::WebContents* web_contents, | 58 content::WebContents* web_contents, |
| 59 AutofillClient* client, | 59 AutofillClient* client, |
| 60 const std::string& app_locale, | 60 const std::string& app_locale, |
| 61 AutofillManager::AutofillDownloadManagerState enable_download_manager); | 61 AutofillManager::AutofillDownloadManagerState enable_download_manager); |
| 62 | 62 |
| 63 private: | |
| 64 AutofillClient* client_; | |
| 65 std::string app_locale_; | 63 std::string app_locale_; |
| 66 AutofillManager::AutofillDownloadManagerState enable_download_manager_; | 64 AutofillManager::AutofillDownloadManagerState enable_download_manager_; |
| 67 | |
| 68 std::map<content::RenderFrameHost*, std::unique_ptr<ContentAutofillDriver>> | |
| 69 frame_driver_map_; | |
| 70 }; | 65 }; |
| 71 | 66 |
| 72 } // namespace autofill | 67 } // namespace autofill |
| 73 | 68 |
| 74 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H
_ | 69 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H
_ |
| OLD | NEW |