| 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 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 5 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 new_factory.release()); | 48 new_factory.release()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 ContentAutofillDriverFactory* ContentAutofillDriverFactory::FromWebContents( | 52 ContentAutofillDriverFactory* ContentAutofillDriverFactory::FromWebContents( |
| 53 content::WebContents* contents) { | 53 content::WebContents* contents) { |
| 54 return static_cast<ContentAutofillDriverFactory*>(contents->GetUserData( | 54 return static_cast<ContentAutofillDriverFactory*>(contents->GetUserData( |
| 55 kContentAutofillDriverFactoryWebContentsUserDataKey)); | 55 kContentAutofillDriverFactoryWebContentsUserDataKey)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // static |
| 59 void ContentAutofillDriverFactory::BindAutofillDriver( |
| 60 content::RenderFrameHost* render_frame_host, |
| 61 mojom::AutofillDriverRequest request) { |
| 62 content::WebContents* web_contents = |
| 63 content::WebContents::FromRenderFrameHost(render_frame_host); |
| 64 DCHECK(web_contents); |
| 65 |
| 66 ContentAutofillDriverFactory* factory = |
| 67 ContentAutofillDriverFactory::FromWebContents(web_contents); |
| 68 DCHECK(factory); |
| 69 |
| 70 ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host); |
| 71 // If driver is still not ready for this render frame host, |
| 72 // the request will be just dropped, this would cause closing the message pipe |
| 73 // which would raise connection error to peer side. |
| 74 // Peer side could reconnect later when needed. |
| 75 if (driver) |
| 76 driver->BindRequest(std::move(request)); |
| 77 } |
| 78 |
| 58 ContentAutofillDriverFactory::ContentAutofillDriverFactory( | 79 ContentAutofillDriverFactory::ContentAutofillDriverFactory( |
| 59 content::WebContents* web_contents, | 80 content::WebContents* web_contents, |
| 60 AutofillClient* client, | 81 AutofillClient* client, |
| 61 const std::string& app_locale, | 82 const std::string& app_locale, |
| 62 AutofillManager::AutofillDownloadManagerState enable_download_manager) | 83 AutofillManager::AutofillDownloadManagerState enable_download_manager) |
| 63 : content::WebContentsObserver(web_contents), | 84 : content::WebContentsObserver(web_contents), |
| 64 client_(client), | 85 client_(client), |
| 65 app_locale_(app_locale), | 86 app_locale_(app_locale), |
| 66 enable_download_manager_(enable_download_manager) {} | 87 enable_download_manager_(enable_download_manager) {} |
| 67 | 88 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 content::NavigationHandle* navigation_handle) { | 125 content::NavigationHandle* navigation_handle) { |
| 105 if (navigation_handle->HasCommitted()) | 126 if (navigation_handle->HasCommitted()) |
| 106 client_->HideAutofillPopup(); | 127 client_->HideAutofillPopup(); |
| 107 } | 128 } |
| 108 | 129 |
| 109 void ContentAutofillDriverFactory::WasHidden() { | 130 void ContentAutofillDriverFactory::WasHidden() { |
| 110 client_->HideAutofillPopup(); | 131 client_->HideAutofillPopup(); |
| 111 } | 132 } |
| 112 | 133 |
| 113 } // namespace autofill | 134 } // namespace autofill |
| OLD | NEW |