Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: components/autofill/content/browser/content_autofill_driver_factory.cc

Issue 2007473004: [Autofill] Migrate ContentAutofillDriver<-->AutofillAgent IPCs to mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Daniel comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "components/autofill/content/browser/content_autofill_driver.h" 11 #include "components/autofill/content/browser/content_autofill_driver.h"
12 #include "components/autofill/core/browser/autofill_client.h" 12 #include "components/autofill/core/browser/autofill_client.h"
13 #include "components/autofill/core/browser/autofill_manager.h" 13 #include "components/autofill/core/browser/autofill_manager.h"
14 #include "components/autofill/core/browser/form_structure.h" 14 #include "components/autofill/core/browser/form_structure.h"
15 #include "components/autofill/core/common/autofill_switches.h" 15 #include "components/autofill/core/common/autofill_switches.h"
16 #include "content/public/browser/navigation_handle.h" 16 #include "content/public/browser/navigation_handle.h"
17 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "ipc/ipc_message_macros.h"
20 19
21 namespace autofill { 20 namespace autofill {
22 21
23 const char ContentAutofillDriverFactory:: 22 const char ContentAutofillDriverFactory::
24 kContentAutofillDriverFactoryWebContentsUserDataKey[] = 23 kContentAutofillDriverFactoryWebContentsUserDataKey[] =
25 "web_contents_autofill_driver_factory"; 24 "web_contents_autofill_driver_factory";
26 25
27 ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {} 26 ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {}
28 27
29 // static 28 // static
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Peer side could reconnect later when needed. 67 // Peer side could reconnect later when needed.
69 if (!web_contents) 68 if (!web_contents)
70 return; 69 return;
71 70
72 ContentAutofillDriverFactory* factory = 71 ContentAutofillDriverFactory* factory =
73 ContentAutofillDriverFactory::FromWebContents(web_contents); 72 ContentAutofillDriverFactory::FromWebContents(web_contents);
74 if (!factory) 73 if (!factory)
75 return; 74 return;
76 75
77 ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host); 76 ContentAutofillDriver* driver = factory->DriverForFrame(render_frame_host);
78 if (driver) 77 if (driver) {
79 driver->BindRequest(std::move(request)); 78 driver->BindRequest(std::move(request));
79 }
80 } 80 }
81 81
82 ContentAutofillDriverFactory::ContentAutofillDriverFactory( 82 ContentAutofillDriverFactory::ContentAutofillDriverFactory(
83 content::WebContents* web_contents, 83 content::WebContents* web_contents,
84 AutofillClient* client, 84 AutofillClient* client,
85 const std::string& app_locale, 85 const std::string& app_locale,
86 AutofillManager::AutofillDownloadManagerState enable_download_manager) 86 AutofillManager::AutofillDownloadManagerState enable_download_manager)
87 : content::WebContentsObserver(web_contents), 87 : content::WebContentsObserver(web_contents),
88 client_(client), 88 client_(client),
89 app_locale_(app_locale), 89 app_locale_(app_locale),
90 enable_download_manager_(enable_download_manager) {} 90 enable_download_manager_(enable_download_manager) {}
91 91
92 ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame( 92 ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
93 content::RenderFrameHost* render_frame_host) { 93 content::RenderFrameHost* render_frame_host) {
94 auto mapping = frame_driver_map_.find(render_frame_host); 94 auto mapping = frame_driver_map_.find(render_frame_host);
95 return mapping == frame_driver_map_.end() ? nullptr : mapping->second.get(); 95 return mapping == frame_driver_map_.end() ? nullptr : mapping->second.get();
96 } 96 }
97 97
98 bool ContentAutofillDriverFactory::OnMessageReceived(
99 const IPC::Message& message,
100 content::RenderFrameHost* render_frame_host) {
101 return frame_driver_map_[render_frame_host]->HandleMessage(message);
102 }
103
104 void ContentAutofillDriverFactory::RenderFrameCreated( 98 void ContentAutofillDriverFactory::RenderFrameCreated(
105 content::RenderFrameHost* render_frame_host) { 99 content::RenderFrameHost* render_frame_host) {
106 auto insertion_result = 100 auto insertion_result =
107 frame_driver_map_.insert(std::make_pair(render_frame_host, nullptr)); 101 frame_driver_map_.insert(std::make_pair(render_frame_host, nullptr));
108 // This is called twice for the main frame. 102 // This is called twice for the main frame.
109 if (insertion_result.second) { // This was the first time. 103 if (insertion_result.second) { // This was the first time.
110 insertion_result.first->second = base::WrapUnique(new ContentAutofillDriver( 104 insertion_result.first->second = base::WrapUnique(new ContentAutofillDriver(
111 render_frame_host, client_, app_locale_, enable_download_manager_)); 105 render_frame_host, client_, app_locale_, enable_download_manager_));
112 } 106 }
113 } 107 }
(...skipping 14 matching lines...) Expand all
128 content::NavigationHandle* navigation_handle) { 122 content::NavigationHandle* navigation_handle) {
129 if (navigation_handle->HasCommitted()) 123 if (navigation_handle->HasCommitted())
130 client_->HideAutofillPopup(); 124 client_->HideAutofillPopup();
131 } 125 }
132 126
133 void ContentAutofillDriverFactory::WasHidden() { 127 void ContentAutofillDriverFactory::WasHidden() {
134 client_->HideAutofillPopup(); 128 client_->HideAutofillPopup();
135 } 129 }
136 130
137 } // namespace autofill 131 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698