| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 possible_auto_sign_in_->origin == form.origin) { | 380 possible_auto_sign_in_->origin == form.origin) { |
| 381 PromptUserToEnableAutosigninIfNecessary(); | 381 PromptUserToEnableAutosigninIfNecessary(); |
| 382 } | 382 } |
| 383 possible_auto_sign_in_.reset(); | 383 possible_auto_sign_in_.reset(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void ChromePasswordManagerClient::NotifyStorePasswordCalled() { | 386 void ChromePasswordManagerClient::NotifyStorePasswordCalled() { |
| 387 // If a site stores a credential the autofill password manager shouldn't kick | 387 // If a site stores a credential the autofill password manager shouldn't kick |
| 388 // in. | 388 // in. |
| 389 password_manager_.DropFormManagers(); | 389 password_manager_.DropFormManagers(); |
| 390 was_store_ever_called_ = true; |
| 390 } | 391 } |
| 391 | 392 |
| 392 void ChromePasswordManagerClient::AutomaticPasswordSave( | 393 void ChromePasswordManagerClient::AutomaticPasswordSave( |
| 393 std::unique_ptr<password_manager::PasswordFormManager> saved_form) { | 394 std::unique_ptr<password_manager::PasswordFormManager> saved_form) { |
| 394 #if defined(OS_ANDROID) | 395 #if defined(OS_ANDROID) |
| 395 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); | 396 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); |
| 396 #else | 397 #else |
| 397 PasswordsClientUIDelegate* manage_passwords_ui_controller = | 398 PasswordsClientUIDelegate* manage_passwords_ui_controller = |
| 398 PasswordsClientUIDelegateFromWebContents(web_contents()); | 399 PasswordsClientUIDelegateFromWebContents(web_contents()); |
| 399 manage_passwords_ui_controller->OnAutomaticPasswordSave( | 400 manage_passwords_ui_controller->OnAutomaticPasswordSave( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 PasswordManagerMetricsRecorder& | 472 PasswordManagerMetricsRecorder& |
| 472 ChromePasswordManagerClient::GetMetricsRecorder() { | 473 ChromePasswordManagerClient::GetMetricsRecorder() { |
| 473 if (!metrics_recorder_) { | 474 if (!metrics_recorder_) { |
| 474 metrics_recorder_.emplace( | 475 metrics_recorder_.emplace( |
| 475 PasswordManagerMetricsRecorder::CreateUkmEntryBuilder( | 476 PasswordManagerMetricsRecorder::CreateUkmEntryBuilder( |
| 476 GetUkmRecorder(), GetUkmSourceId())); | 477 GetUkmRecorder(), GetUkmSourceId())); |
| 477 } | 478 } |
| 478 return metrics_recorder_.value(); | 479 return metrics_recorder_.value(); |
| 479 } | 480 } |
| 480 | 481 |
| 481 // TODO(crbug.com/706392): Fix password reuse detection for Android. | |
| 482 #if !defined(OS_ANDROID) | |
| 483 void ChromePasswordManagerClient::DidFinishNavigation( | 482 void ChromePasswordManagerClient::DidFinishNavigation( |
| 484 content::NavigationHandle* navigation_handle) { | 483 content::NavigationHandle* navigation_handle) { |
| 485 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) | 484 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 486 return; | 485 return; |
| 487 | 486 |
| 488 if (!navigation_handle->IsSameDocument()) { | 487 if (!navigation_handle->IsSameDocument()) { |
| 489 ukm_source_id_.reset(); | 488 ukm_source_id_.reset(); |
| 490 // Send any collected metrics by destroying the metrics recorder. | 489 // Send any collected metrics by destroying the metrics recorder. |
| 491 metrics_recorder_.reset(); | 490 metrics_recorder_.reset(); |
| 492 } | 491 } |
| 493 | 492 |
| 493 // From this point on, the CredentialManagerImpl will service API calls in the |
| 494 // context of the new WebContents::GetLastCommittedURL, which may very well be |
| 495 // cross-origin. Disconnect existing client, and drop pending requests. |
| 496 if (!navigation_handle->IsSameDocument()) |
| 497 credential_manager_impl_.DisconnectBinding(); |
| 498 |
| 499 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 500 #if !defined(OS_ANDROID) |
| 494 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); | 501 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); |
| 495 // After some navigations RenderViewHost persists and just adding the observer | 502 // After some navigations RenderViewHost persists and just adding the observer |
| 496 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to | 503 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to |
| 497 // check whether the observer is already added, the observer is removed and | 504 // check whether the observer is already added, the observer is removed and |
| 498 // added again, to ensure that it is added only once. | 505 // added again, to ensure that it is added only once. |
| 499 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver( | 506 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver( |
| 500 this); | 507 this); |
| 501 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this); | 508 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this); |
| 509 #endif |
| 502 } | 510 } |
| 503 | 511 |
| 512 #if !defined(OS_ANDROID) |
| 504 void ChromePasswordManagerClient::OnInputEvent( | 513 void ChromePasswordManagerClient::OnInputEvent( |
| 505 const blink::WebInputEvent& event) { | 514 const blink::WebInputEvent& event) { |
| 506 if (event.GetType() != blink::WebInputEvent::kChar) | 515 if (event.GetType() != blink::WebInputEvent::kChar) |
| 507 return; | 516 return; |
| 508 const blink::WebKeyboardEvent& key_event = | 517 const blink::WebKeyboardEvent& key_event = |
| 509 static_cast<const blink::WebKeyboardEvent&>(event); | 518 static_cast<const blink::WebKeyboardEvent&>(event); |
| 510 password_reuse_detection_manager_.OnKeyPressed(key_event.text); | 519 password_reuse_detection_manager_.OnKeyPressed(key_event.text); |
| 511 } | 520 } |
| 512 #endif | 521 #endif |
| 513 | 522 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 return &credentials_filter_; | 743 return &credentials_filter_; |
| 735 } | 744 } |
| 736 | 745 |
| 737 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() | 746 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() |
| 738 const { | 747 const { |
| 739 return log_manager_.get(); | 748 return log_manager_.get(); |
| 740 } | 749 } |
| 741 | 750 |
| 742 // static | 751 // static |
| 743 void ChromePasswordManagerClient::BindCredentialManager( | 752 void ChromePasswordManagerClient::BindCredentialManager( |
| 744 const service_manager::BindSourceInfo& source_info, | 753 password_manager::mojom::CredentialManagerAssociatedRequest request, |
| 745 password_manager::mojom::CredentialManagerRequest request, | |
| 746 content::RenderFrameHost* render_frame_host) { | 754 content::RenderFrameHost* render_frame_host) { |
| 747 // Only valid for the main frame. | 755 // Only valid for the main frame. |
| 748 if (render_frame_host->GetParent()) | 756 if (render_frame_host->GetParent()) |
| 749 return; | 757 return; |
| 750 | 758 |
| 751 content::WebContents* web_contents = | 759 content::WebContents* web_contents = |
| 752 content::WebContents::FromRenderFrameHost(render_frame_host); | 760 content::WebContents::FromRenderFrameHost(render_frame_host); |
| 753 DCHECK(web_contents); | 761 DCHECK(web_contents); |
| 754 | 762 |
| 763 // Only valid for the currently committed RenderFrameHost, and not, e.g. old |
| 764 // zombie RFH's being swapped out following cross-origin navigations. |
| 765 if (web_contents->GetMainFrame() != render_frame_host) |
| 766 return; |
| 767 |
| 755 ChromePasswordManagerClient* instance = | 768 ChromePasswordManagerClient* instance = |
| 756 ChromePasswordManagerClient::FromWebContents(web_contents); | 769 ChromePasswordManagerClient::FromWebContents(web_contents); |
| 757 | 770 |
| 758 // Try to bind to the driver, but if driver is not available for this render | 771 // Try to bind to the driver, but if driver is not available for this render |
| 759 // frame host, the request will be just dropped. This will cause the message | 772 // frame host, the request will be just dropped. This will cause the message |
| 760 // pipe to be closed, which will raise a connection error on the peer side. | 773 // pipe to be closed, which will raise a connection error on the peer side. |
| 761 if (!instance) | 774 if (!instance) |
| 762 return; | 775 return; |
| 763 | 776 |
| 764 instance->credential_manager_impl_.BindRequest(std::move(request)); | 777 instance->credential_manager_impl_.BindRequest(std::move(request)); |
| 765 } | 778 } |
| 766 | 779 |
| 767 // static | 780 // static |
| 768 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { | 781 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { |
| 769 std::string scheme = url.scheme(); | 782 std::string scheme = url.scheme(); |
| 770 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 783 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
| 771 scheme) && | 784 scheme) && |
| 772 #if BUILDFLAG(ENABLE_EXTENSIONS) | 785 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 773 scheme != extensions::kExtensionScheme && | 786 scheme != extensions::kExtensionScheme && |
| 774 #endif | 787 #endif |
| 775 scheme != content::kChromeDevToolsScheme); | 788 scheme != content::kChromeDevToolsScheme); |
| 776 } | 789 } |
| OLD | NEW |