OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 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" |
| 15 |
| 16 namespace content { |
| 17 class RenderFrameHost; |
| 18 } |
| 19 |
| 20 namespace IPC { |
| 21 class Message; |
| 22 } |
| 23 |
| 24 namespace autofill { |
| 25 |
| 26 class AutofillDriver; |
| 27 class ContentAutofillDriver; |
| 28 |
| 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 { |
| 33 public: |
| 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); |
| 41 |
| 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); |
| 46 |
| 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(content::RenderFrameHost* render_frame_host, |
| 53 const content::LoadCommittedDetails& details, |
| 54 const content::FrameNavigateParams& params) override; |
| 55 void NavigationEntryCommitted( |
| 56 const content::LoadCommittedDetails& load_details) override; |
| 57 void WasHidden() override; |
| 58 |
| 59 protected: |
| 60 ContentAutofillDriverFactory( |
| 61 content::WebContents* web_contents, |
| 62 AutofillClient* client, |
| 63 const std::string& app_locale, |
| 64 AutofillManager::AutofillDownloadManagerState enable_download_manager); |
| 65 ~ContentAutofillDriverFactory() override; |
| 66 |
| 67 private: |
| 68 void CreateDriverForFrame(content::RenderFrameHost* render_frame_host); |
| 69 |
| 70 AutofillClient* client_; |
| 71 std::string app_locale_; |
| 72 AutofillManager::AutofillDownloadManagerState enable_download_manager_; |
| 73 |
| 74 std::map<content::RenderFrameHost*, ContentAutofillDriver*> frame_driver_map_; |
| 75 }; |
| 76 |
| 77 } // namespace autofill |
| 78 |
| 79 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_FACTORY_H
_ |
OLD | NEW |