| 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 "chrome/browser/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 UserDataKey(), | 137 UserDataKey(), |
| 138 new ChromePasswordManagerClient(contents, autofill_client)); | 138 new ChromePasswordManagerClient(contents, autofill_client)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 ChromePasswordManagerClient::ChromePasswordManagerClient( | 141 ChromePasswordManagerClient::ChromePasswordManagerClient( |
| 142 content::WebContents* web_contents, | 142 content::WebContents* web_contents, |
| 143 autofill::AutofillClient* autofill_client) | 143 autofill::AutofillClient* autofill_client) |
| 144 : content::WebContentsObserver(web_contents), | 144 : content::WebContentsObserver(web_contents), |
| 145 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 145 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), |
| 146 password_manager_(this), | 146 password_manager_(this), |
| 147 password_reuse_detection_manager_(this), |
| 147 driver_factory_(nullptr), | 148 driver_factory_(nullptr), |
| 148 credential_manager_impl_(web_contents, this), | 149 credential_manager_impl_(web_contents, this), |
| 149 password_manager_client_bindings_(web_contents, this), | 150 password_manager_client_bindings_(web_contents, this), |
| 150 observer_(nullptr), | 151 observer_(nullptr), |
| 151 credentials_filter_(this, | 152 credentials_filter_(this, |
| 152 base::Bind(&GetSyncService, profile_), | 153 base::Bind(&GetSyncService, profile_), |
| 153 base::Bind(&GetSigninManager, profile_)) { | 154 base::Bind(&GetSigninManager, profile_)) { |
| 154 ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this, | 155 ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this, |
| 155 autofill_client); | 156 autofill_client); |
| 156 driver_factory_ = | 157 driver_factory_ = |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, | 371 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, |
| 371 federated_matches); | 372 federated_matches); |
| 372 #endif | 373 #endif |
| 373 } | 374 } |
| 374 | 375 |
| 375 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { | 376 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { |
| 376 if (popup_controller_) | 377 if (popup_controller_) |
| 377 popup_controller_->HideAndDestroy(); | 378 popup_controller_->HideAndDestroy(); |
| 378 } | 379 } |
| 379 | 380 |
| 381 void ChromePasswordManagerClient::DidNavigateMainFrame( |
| 382 const content::LoadCommittedDetails& details, |
| 383 const content::FrameNavigateParams& params) { |
| 384 password_reuse_detection_manager_.DidNavigateMainFrame(); |
| 385 // After some navigations RenderViewHost persists and just adding the observer |
| 386 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to |
| 387 // check whether the observer is already added, the observer is removed and |
| 388 // added again, to ensure that it is added only once. |
| 389 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver( |
| 390 this); |
| 391 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this); |
| 392 } |
| 393 |
| 394 void ChromePasswordManagerClient::OnInputEvent( |
| 395 const blink::WebInputEvent& event) { |
| 396 if (event.type != blink::WebInputEvent::Char) |
| 397 return; |
| 398 const blink::WebKeyboardEvent& key_event = |
| 399 static_cast<const blink::WebKeyboardEvent&>(event); |
| 400 password_reuse_detection_manager_.OnKeyPressed(key_event.text); |
| 401 } |
| 402 |
| 380 PrefService* ChromePasswordManagerClient::GetPrefs() { | 403 PrefService* ChromePasswordManagerClient::GetPrefs() { |
| 381 return profile_->GetPrefs(); | 404 return profile_->GetPrefs(); |
| 382 } | 405 } |
| 383 | 406 |
| 384 password_manager::PasswordStore* | 407 password_manager::PasswordStore* |
| 385 ChromePasswordManagerClient::GetPasswordStore() const { | 408 ChromePasswordManagerClient::GetPasswordStore() const { |
| 386 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord | 409 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord |
| 387 // itself when it shouldn't access the PasswordStore. | 410 // itself when it shouldn't access the PasswordStore. |
| 388 // TODO(gcasto): Is is safe to change this to | 411 // TODO(gcasto): Is is safe to change this to |
| 389 // ServiceAccessType::IMPLICIT_ACCESS? | 412 // ServiceAccessType::IMPLICIT_ACCESS? |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 ChromePasswordManagerClient::FromWebContents(web_contents); | 636 ChromePasswordManagerClient::FromWebContents(web_contents); |
| 614 | 637 |
| 615 // Try to bind to the driver, but if driver is not available for this render | 638 // Try to bind to the driver, but if driver is not available for this render |
| 616 // frame host, the request will be just dropped. This will cause the message | 639 // frame host, the request will be just dropped. This will cause the message |
| 617 // pipe to be closed, which will raise a connection error on the peer side. | 640 // pipe to be closed, which will raise a connection error on the peer side. |
| 618 if (!instance) | 641 if (!instance) |
| 619 return; | 642 return; |
| 620 | 643 |
| 621 instance->credential_manager_impl_.BindRequest(std::move(request)); | 644 instance->credential_manager_impl_.BindRequest(std::move(request)); |
| 622 } | 645 } |
| OLD | NEW |