| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| 11 #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" | 12 #include "components/autofill/core/browser/autofill_driver_factory.h" |
| 13 #include "components/autofill/core/browser/autofill_manager.h" | 13 #include "components/autofill/core/browser/autofill_manager.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "services/service_manager/public/cpp/bind_source_info.h" | 15 #include "services/service_manager/public/cpp/bind_source_info.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class RenderFrameHost; | 18 class RenderFrameHost; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 | 22 |
| 23 class ContentAutofillDriver; | 23 class ContentAutofillDriver; |
| 24 class AutofillProvider; |
| 24 | 25 |
| 25 // Manages lifetime of ContentAutofillDriver. One Factory per WebContents | 26 // Manages lifetime of ContentAutofillDriver. One Factory per WebContents |
| 26 // creates one Driver per RenderFrame. | 27 // creates one Driver per RenderFrame. |
| 27 class ContentAutofillDriverFactory : public AutofillDriverFactory, | 28 class ContentAutofillDriverFactory : public AutofillDriverFactory, |
| 28 public content::WebContentsObserver, | 29 public content::WebContentsObserver, |
| 29 public base::SupportsUserData::Data { | 30 public base::SupportsUserData::Data { |
| 30 public: | 31 public: |
| 31 ~ContentAutofillDriverFactory() override; | 32 ~ContentAutofillDriverFactory() override; |
| 32 | 33 |
| 33 static void CreateForWebContentsAndDelegate( | 34 static void CreateForWebContentsAndDelegate( |
| 34 content::WebContents* contents, | 35 content::WebContents* contents, |
| 35 AutofillClient* client, | 36 AutofillClient* client, |
| 36 const std::string& app_locale, | 37 const std::string& app_locale, |
| 37 AutofillManager::AutofillDownloadManagerState enable_download_manager); | 38 AutofillManager::AutofillDownloadManagerState enable_download_manager); |
| 39 |
| 40 static void CreateForWebContentsAndDelegate( |
| 41 content::WebContents* contents, |
| 42 AutofillClient* client, |
| 43 const std::string& app_locale, |
| 44 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| 45 AutofillProvider* provider); |
| 46 |
| 38 static ContentAutofillDriverFactory* FromWebContents( | 47 static ContentAutofillDriverFactory* FromWebContents( |
| 39 content::WebContents* contents); | 48 content::WebContents* contents); |
| 40 static void BindAutofillDriver( | 49 static void BindAutofillDriver( |
| 41 content::RenderFrameHost* render_frame_host, | 50 content::RenderFrameHost* render_frame_host, |
| 42 const service_manager::BindSourceInfo& source_info, | 51 const service_manager::BindSourceInfo& source_info, |
| 43 mojom::AutofillDriverRequest request); | 52 mojom::AutofillDriverRequest request); |
| 44 | 53 |
| 45 // Gets the |ContentAutofillDriver| associated with |render_frame_host|. | 54 // Gets the |ContentAutofillDriver| associated with |render_frame_host|. |
| 46 // |render_frame_host| must be owned by |web_contents()|. | 55 // |render_frame_host| must be owned by |web_contents()|. |
| 47 ContentAutofillDriver* DriverForFrame( | 56 ContentAutofillDriver* DriverForFrame( |
| 48 content::RenderFrameHost* render_frame_host); | 57 content::RenderFrameHost* render_frame_host); |
| 49 | 58 |
| 50 // content::WebContentsObserver: | 59 // content::WebContentsObserver: |
| 51 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | 60 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
| 52 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 61 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 53 void DidFinishNavigation( | 62 void DidFinishNavigation( |
| 54 content::NavigationHandle* navigation_handle) override; | 63 content::NavigationHandle* navigation_handle) override; |
| 55 void WasHidden() override; | 64 void WasHidden() override; |
| 56 | 65 |
| 57 static const char kContentAutofillDriverFactoryWebContentsUserDataKey[]; | 66 static const char kContentAutofillDriverFactoryWebContentsUserDataKey[]; |
| 58 | 67 |
| 59 private: | 68 private: |
| 60 ContentAutofillDriverFactory( | 69 ContentAutofillDriverFactory( |
| 61 content::WebContents* web_contents, | 70 content::WebContents* web_contents, |
| 62 AutofillClient* client, | 71 AutofillClient* client, |
| 63 const std::string& app_locale, | 72 const std::string& app_locale, |
| 64 AutofillManager::AutofillDownloadManagerState enable_download_manager); | 73 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| 74 AutofillProvider* provider); |
| 65 | 75 |
| 66 std::string app_locale_; | 76 std::string app_locale_; |
| 67 AutofillManager::AutofillDownloadManagerState enable_download_manager_; | 77 AutofillManager::AutofillDownloadManagerState enable_download_manager_; |
| 78 AutofillProvider* provider_; |
| 68 }; | 79 }; |
| 69 | 80 |
| 70 } // namespace autofill | 81 } // namespace autofill |
| 71 | 82 |
| 72 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H
_ | 83 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H
_ |
| OLD | NEW |