OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_AUTOFILL_DRIVER_IMPL_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
11 #include "components/autofill/browser/autofill_driver.h" | 12 #include "components/autofill/browser/autofill_driver.h" |
| 13 #include "components/autofill/browser/autofill_external_delegate.h" |
12 #include "components/autofill/browser/autofill_manager.h" | 14 #include "components/autofill/browser/autofill_manager.h" |
13 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
14 | 16 |
15 namespace content { | 17 namespace content { |
16 class WebContents; | 18 class WebContents; |
17 } | 19 } |
18 | 20 |
19 namespace IPC { | 21 namespace IPC { |
20 class Message; | 22 class Message; |
21 } | 23 } |
22 | 24 |
23 namespace autofill { | 25 namespace autofill { |
24 | 26 |
25 class AutofillContext; | 27 class AutofillContext; |
26 class AutofillExternalDelegate; | |
27 class AutofillManagerDelegate; | 28 class AutofillManagerDelegate; |
28 | 29 |
29 // Class that drives autofill flow in the browser process based on | 30 // Class that drives autofill flow in the browser process based on |
30 // communication from the renderer and from the external world. There is one | 31 // communication from the renderer and from the external world. There is one |
31 // instance per WebContents. | 32 // instance per WebContents. |
32 class AutofillDriverImpl : public AutofillDriver, | 33 class AutofillDriverImpl : public AutofillDriver, |
33 public content::WebContentsObserver, | 34 public content::WebContentsObserver, |
34 public base::SupportsUserData::Data { | 35 public base::SupportsUserData::Data { |
35 public: | 36 public: |
36 static void CreateForWebContentsAndDelegate( | 37 static void CreateForWebContentsAndDelegate( |
37 content::WebContents* contents, | 38 content::WebContents* contents, |
38 autofill::AutofillManagerDelegate* delegate, | 39 autofill::AutofillManagerDelegate* delegate, |
39 const std::string& app_locale, | 40 const std::string& app_locale, |
40 AutofillManager::AutofillDownloadManagerState enable_download_manager, | 41 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
41 bool enable_native_ui); | 42 bool enable_native_ui); |
42 static AutofillDriverImpl* FromWebContents(content::WebContents* contents); | 43 static AutofillDriverImpl* FromWebContents(content::WebContents* contents); |
43 | 44 |
44 // AutofillDriver: | 45 // AutofillDriver: |
45 virtual content::WebContents* GetWebContents() OVERRIDE; | 46 virtual content::WebContents* GetWebContents() OVERRIDE; |
46 | 47 |
| 48 AutofillExternalDelegate* autofill_external_delegate() { |
| 49 return autofill_external_delegate_.get(); |
| 50 } |
| 51 |
| 52 // Sets the external delegate to |delegate| both within this class and in the |
| 53 // shared Autofill code. Takes ownership of |delegate|. |
| 54 void SetAutofillExternalDelegate( |
| 55 scoped_ptr<AutofillExternalDelegate> delegate); |
| 56 |
47 AutofillManager* autofill_manager() { return &autofill_manager_; } | 57 AutofillManager* autofill_manager() { return &autofill_manager_; } |
48 | 58 |
49 private: | 59 private: |
50 AutofillDriverImpl( | 60 AutofillDriverImpl( |
51 content::WebContents* web_contents, | 61 content::WebContents* web_contents, |
52 autofill::AutofillManagerDelegate* delegate, | 62 autofill::AutofillManagerDelegate* delegate, |
53 const std::string& app_locale, | 63 const std::string& app_locale, |
54 AutofillManager::AutofillDownloadManagerState enable_download_manager, | 64 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
55 bool enable_native_ui); | 65 bool enable_native_ui); |
56 virtual ~AutofillDriverImpl(); | 66 virtual ~AutofillDriverImpl(); |
57 | 67 |
58 // content::WebContentsObserver: | 68 // content::WebContentsObserver: |
59 virtual void DidNavigateMainFrame( | 69 virtual void DidNavigateMainFrame( |
60 const content::LoadCommittedDetails& details, | 70 const content::LoadCommittedDetails& details, |
61 const content::FrameNavigateParams& params) OVERRIDE; | 71 const content::FrameNavigateParams& params) OVERRIDE; |
62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 72 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
63 | 73 |
| 74 // AutofillExternalDelegate instance that this object instantiates in the |
| 75 // case where the autofill native UI is enabled. |
| 76 scoped_ptr<AutofillExternalDelegate> autofill_external_delegate_; |
| 77 |
64 // AutofillManager instance via which this object drives the shared Autofill | 78 // AutofillManager instance via which this object drives the shared Autofill |
65 // code. | 79 // code. |
66 AutofillManager autofill_manager_; | 80 AutofillManager autofill_manager_; |
67 }; | 81 }; |
68 | 82 |
69 } // namespace autofill | 83 } // namespace autofill |
70 | 84 |
71 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ | 85 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOFILL_DRIVER_IMPL_H_ |
OLD | NEW |