| 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 // We try to bind to the driver of this render frame host, |
| 65 // but if driver is not ready for this render frame host for now, |
| 66 // the request will be just dropped, this would cause closing the message pipe |
| 67 // which would raise connection error to peer side. |
| 68 // Peer side could reconnect later when needed. |
| 69 if (!web_contents) |
| 70 return; |
| 71 |
| 72 ContentAutofillDriverFactory* factory = |
| 73 ContentAutofillDriverFactory::FromWebContents(web_contents); |
| 74 if (!factory) |
| 75 return; |
| 76 |
| 77 ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host); |
| 78 if (driver) |
| 79 driver->BindRequest(std::move(request)); |
| 80 } |
| 81 |
| 58 ContentAutofillDriverFactory::ContentAutofillDriverFactory( | 82 ContentAutofillDriverFactory::ContentAutofillDriverFactory( |
| 59 content::WebContents* web_contents, | 83 content::WebContents* web_contents, |
| 60 AutofillClient* client, | 84 AutofillClient* client, |
| 61 const std::string& app_locale, | 85 const std::string& app_locale, |
| 62 AutofillManager::AutofillDownloadManagerState enable_download_manager) | 86 AutofillManager::AutofillDownloadManagerState enable_download_manager) |
| 63 : content::WebContentsObserver(web_contents), | 87 : content::WebContentsObserver(web_contents), |
| 64 client_(client), | 88 client_(client), |
| 65 app_locale_(app_locale), | 89 app_locale_(app_locale), |
| 66 enable_download_manager_(enable_download_manager) {} | 90 enable_download_manager_(enable_download_manager) {} |
| 67 | 91 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 content::NavigationHandle* navigation_handle) { | 128 content::NavigationHandle* navigation_handle) { |
| 105 if (navigation_handle->HasCommitted()) | 129 if (navigation_handle->HasCommitted()) |
| 106 client_->HideAutofillPopup(); | 130 client_->HideAutofillPopup(); |
| 107 } | 131 } |
| 108 | 132 |
| 109 void ContentAutofillDriverFactory::WasHidden() { | 133 void ContentAutofillDriverFactory::WasHidden() { |
| 110 client_->HideAutofillPopup(); | 134 client_->HideAutofillPopup(); |
| 111 } | 135 } |
| 112 | 136 |
| 113 } // namespace autofill | 137 } // namespace autofill |
| OLD | NEW |