| 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.h" | 5 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 11 #include "components/autofill/content/browser/content_autofill_driver_factory.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_external_delegate.h" | 13 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 14 #include "components/autofill/core/browser/autofill_manager.h" | 14 #include "components/autofill/core/browser/autofill_manager.h" |
| 15 #include "components/autofill/core/browser/form_structure.h" | 15 #include "components/autofill/core/browser/form_structure.h" |
| 16 #include "components/autofill/core/common/autofill_switches.h" | 16 #include "components/autofill/core/common/autofill_switches.h" |
| 17 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/navigation_details.h" | |
| 21 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/render_widget_host_view.h" | 22 #include "content/public/browser/render_widget_host_view.h" |
| 24 #include "content/public/browser/site_instance.h" | 23 #include "content/public/browser/site_instance.h" |
| 25 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
| 26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 27 #include "services/service_manager/public/cpp/interface_provider.h" | 26 #include "services/service_manager/public/cpp/interface_provider.h" |
| 28 #include "ui/gfx/geometry/size_f.h" | 27 #include "ui/gfx/geometry/size_f.h" |
| 29 | 28 |
| 30 namespace autofill { | 29 namespace autofill { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 } | 45 } |
| 47 | 46 |
| 48 ContentAutofillDriver::~ContentAutofillDriver() {} | 47 ContentAutofillDriver::~ContentAutofillDriver() {} |
| 49 | 48 |
| 50 // static | 49 // static |
| 51 ContentAutofillDriver* ContentAutofillDriver::GetForRenderFrameHost( | 50 ContentAutofillDriver* ContentAutofillDriver::GetForRenderFrameHost( |
| 52 content::RenderFrameHost* render_frame_host) { | 51 content::RenderFrameHost* render_frame_host) { |
| 53 ContentAutofillDriverFactory* factory = | 52 ContentAutofillDriverFactory* factory = |
| 54 ContentAutofillDriverFactory::FromWebContents( | 53 ContentAutofillDriverFactory::FromWebContents( |
| 55 content::WebContents::FromRenderFrameHost(render_frame_host)); | 54 content::WebContents::FromRenderFrameHost(render_frame_host)); |
| 56 return factory ? factory->DriverForFrame(render_frame_host) : nullptr; | 55 return factory ? static_cast<ContentAutofillDriver*>( |
| 56 factory->DriverForFrame(render_frame_host)) |
| 57 : nullptr; |
| 57 } | 58 } |
| 58 | 59 |
| 59 void ContentAutofillDriver::BindRequest(mojom::AutofillDriverRequest request) { | 60 void ContentAutofillDriver::BindRequest(mojom::AutofillDriverRequest request) { |
| 60 binding_.Bind(std::move(request)); | 61 binding_.Bind(std::move(request)); |
| 61 } | 62 } |
| 62 | 63 |
| 63 bool ContentAutofillDriver::IsOffTheRecord() const { | 64 bool ContentAutofillDriver::IsOffTheRecord() const { |
| 64 return render_frame_host_->GetSiteInstance() | 65 return render_frame_host_->GetSiteInstance() |
| 65 ->GetBrowserContext() | 66 ->GetBrowserContext() |
| 66 ->IsOffTheRecord(); | 67 ->IsOffTheRecord(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 void ContentAutofillDriver::DidInteractWithCreditCardForm() { | 174 void ContentAutofillDriver::DidInteractWithCreditCardForm() { |
| 174 // Notify the WebContents about credit card inputs on HTTP pages. | 175 // Notify the WebContents about credit card inputs on HTTP pages. |
| 175 content::WebContents* contents = | 176 content::WebContents* contents = |
| 176 content::WebContents::FromRenderFrameHost(render_frame_host_); | 177 content::WebContents::FromRenderFrameHost(render_frame_host_); |
| 177 if (contents->GetVisibleURL().SchemeIsCryptographic()) | 178 if (contents->GetVisibleURL().SchemeIsCryptographic()) |
| 178 return; | 179 return; |
| 179 contents->OnCreditCardInputShownOnHttp(); | 180 contents->OnCreditCardInputShownOnHttp(); |
| 180 } | 181 } |
| 181 | 182 |
| 183 void ContentAutofillDriver::NavigatedToDifferentPage() { |
| 184 autofill_manager_->Reset(); |
| 185 } |
| 186 |
| 182 // mojom::AutofillDriver: | 187 // mojom::AutofillDriver: |
| 183 void ContentAutofillDriver::FirstUserGestureObserved() { | 188 void ContentAutofillDriver::FirstUserGestureObserved() { |
| 184 client_->OnFirstUserGestureObserved(); | 189 client_->OnFirstUserGestureObserved(); |
| 185 } | 190 } |
| 186 | 191 |
| 187 void ContentAutofillDriver::FormsSeen(const std::vector<FormData>& forms, | 192 void ContentAutofillDriver::FormsSeen(const std::vector<FormData>& forms, |
| 188 base::TimeTicks timestamp) { | 193 base::TimeTicks timestamp) { |
| 189 autofill_manager_->OnFormsSeen(forms, timestamp); | 194 autofill_manager_->OnFormsSeen(forms, timestamp); |
| 190 } | 195 } |
| 191 | 196 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 void ContentAutofillDriver::DidEndTextFieldEditing() { | 237 void ContentAutofillDriver::DidEndTextFieldEditing() { |
| 233 autofill_manager_->OnDidEndTextFieldEditing(); | 238 autofill_manager_->OnDidEndTextFieldEditing(); |
| 234 } | 239 } |
| 235 | 240 |
| 236 void ContentAutofillDriver::SetDataList( | 241 void ContentAutofillDriver::SetDataList( |
| 237 const std::vector<base::string16>& values, | 242 const std::vector<base::string16>& values, |
| 238 const std::vector<base::string16>& labels) { | 243 const std::vector<base::string16>& labels) { |
| 239 autofill_manager_->OnSetDataList(values, labels); | 244 autofill_manager_->OnSetDataList(values, labels); |
| 240 } | 245 } |
| 241 | 246 |
| 242 void ContentAutofillDriver::DidNavigateFrame( | |
| 243 const content::LoadCommittedDetails& details, | |
| 244 const content::FrameNavigateParams& params) { | |
| 245 if (details.is_navigation_to_different_page()) | |
| 246 autofill_manager_->Reset(); | |
| 247 } | |
| 248 | |
| 249 void ContentAutofillDriver::SetAutofillManager( | 247 void ContentAutofillDriver::SetAutofillManager( |
| 250 std::unique_ptr<AutofillManager> manager) { | 248 std::unique_ptr<AutofillManager> manager) { |
| 251 autofill_manager_ = std::move(manager); | 249 autofill_manager_ = std::move(manager); |
| 252 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); | 250 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); |
| 253 } | 251 } |
| 254 | 252 |
| 255 void ContentAutofillDriver::NotifyFirstUserGestureObservedInTab() { | 253 void ContentAutofillDriver::NotifyFirstUserGestureObservedInTab() { |
| 256 GetAutofillAgent()->FirstUserGestureObservedInTab(); | 254 GetAutofillAgent()->FirstUserGestureObservedInTab(); |
| 257 } | 255 } |
| 258 | 256 |
| 259 const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() { | 257 const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() { |
| 260 // Here is a lazy binding, and will not reconnect after connection error. | 258 // Here is a lazy binding, and will not reconnect after connection error. |
| 261 if (!autofill_agent_) { | 259 if (!autofill_agent_) { |
| 262 render_frame_host_->GetRemoteInterfaces()->GetInterface( | 260 render_frame_host_->GetRemoteInterfaces()->GetInterface( |
| 263 mojo::MakeRequest(&autofill_agent_)); | 261 mojo::MakeRequest(&autofill_agent_)); |
| 264 } | 262 } |
| 265 | 263 |
| 266 return autofill_agent_; | 264 return autofill_agent_; |
| 267 } | 265 } |
| 268 | 266 |
| 269 } // namespace autofill | 267 } // namespace autofill |
| OLD | NEW |