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

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 2947413002: Restrict CM API interface request and message dispatch. (Closed)
Patch Set: Addressed comments from rockot@. Created 3 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 "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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 possible_auto_sign_in_->origin == form.origin) { 366 possible_auto_sign_in_->origin == form.origin) {
367 PromptUserToEnableAutosigninIfNecessary(); 367 PromptUserToEnableAutosigninIfNecessary();
368 } 368 }
369 possible_auto_sign_in_.reset(); 369 possible_auto_sign_in_.reset();
370 } 370 }
371 371
372 void ChromePasswordManagerClient::NotifyStorePasswordCalled() { 372 void ChromePasswordManagerClient::NotifyStorePasswordCalled() {
373 // If a site stores a credential the autofill password manager shouldn't kick 373 // If a site stores a credential the autofill password manager shouldn't kick
374 // in. 374 // in.
375 password_manager_.DropFormManagers(); 375 password_manager_.DropFormManagers();
376 was_store_ever_called_ = true;
376 } 377 }
377 378
378 void ChromePasswordManagerClient::AutomaticPasswordSave( 379 void ChromePasswordManagerClient::AutomaticPasswordSave(
379 std::unique_ptr<password_manager::PasswordFormManager> saved_form) { 380 std::unique_ptr<password_manager::PasswordFormManager> saved_form) {
380 #if defined(OS_ANDROID) 381 #if defined(OS_ANDROID)
381 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents()); 382 GeneratedPasswordSavedInfoBarDelegateAndroid::Create(web_contents());
382 #else 383 #else
383 PasswordsClientUIDelegate* manage_passwords_ui_controller = 384 PasswordsClientUIDelegate* manage_passwords_ui_controller =
384 PasswordsClientUIDelegateFromWebContents(web_contents()); 385 PasswordsClientUIDelegateFromWebContents(web_contents());
385 manage_passwords_ui_controller->OnAutomaticPasswordSave( 386 manage_passwords_ui_controller->OnAutomaticPasswordSave(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // web contents), once the UKM framework provides a mechanism for that. 448 // web contents), once the UKM framework provides a mechanism for that.
448 if (!ukm_source_id_) { 449 if (!ukm_source_id_) {
449 ukm_source_id_ = ukm::UkmRecorder::GetNewSourceID(); 450 ukm_source_id_ = ukm::UkmRecorder::GetNewSourceID();
450 ukm::UkmRecorder* ukm_recorder = GetUkmRecorder(); 451 ukm::UkmRecorder* ukm_recorder = GetUkmRecorder();
451 if (ukm_recorder) 452 if (ukm_recorder)
452 ukm_recorder->UpdateSourceURL(*ukm_source_id_, GetMainFrameURL()); 453 ukm_recorder->UpdateSourceURL(*ukm_source_id_, GetMainFrameURL());
453 } 454 }
454 return *ukm_source_id_; 455 return *ukm_source_id_;
455 } 456 }
456 457
457 // TODO(crbug.com/706392): Fix password reuse detection for Android.
458 #if !defined(OS_ANDROID)
459 void ChromePasswordManagerClient::DidFinishNavigation( 458 void ChromePasswordManagerClient::DidFinishNavigation(
460 content::NavigationHandle* navigation_handle) { 459 content::NavigationHandle* navigation_handle) {
461 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) 460 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
462 return; 461 return;
463 462
464 if (!navigation_handle->IsSameDocument()) 463 if (!navigation_handle->IsSameDocument())
465 ukm_source_id_.reset(); 464 ukm_source_id_.reset();
466 465
466 // From this point on, the CredentialManagerImpl will service API calls in the
467 // context of the new WebContents::GetLastCommittedURL, which may very well be
468 // cross-origin. Disconnect existing client, and drop pending requests.
469 if (!navigation_handle->IsSameDocument())
470 credential_manager_impl_.DisconnectBinding();
471
472 // TODO(crbug.com/706392): Fix password reuse detection for Android.
473 #if !defined(OS_ANDROID)
467 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); 474 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL());
468 // After some navigations RenderViewHost persists and just adding the observer 475 // After some navigations RenderViewHost persists and just adding the observer
469 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to 476 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to
470 // check whether the observer is already added, the observer is removed and 477 // check whether the observer is already added, the observer is removed and
471 // added again, to ensure that it is added only once. 478 // added again, to ensure that it is added only once.
472 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver( 479 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver(
473 this); 480 this);
474 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this); 481 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this);
482 #endif
475 } 483 }
476 484
485 #if !defined(OS_ANDROID)
477 void ChromePasswordManagerClient::OnInputEvent( 486 void ChromePasswordManagerClient::OnInputEvent(
478 const blink::WebInputEvent& event) { 487 const blink::WebInputEvent& event) {
479 if (event.GetType() != blink::WebInputEvent::kChar) 488 if (event.GetType() != blink::WebInputEvent::kChar)
480 return; 489 return;
481 const blink::WebKeyboardEvent& key_event = 490 const blink::WebKeyboardEvent& key_event =
482 static_cast<const blink::WebKeyboardEvent&>(event); 491 static_cast<const blink::WebKeyboardEvent&>(event);
483 password_reuse_detection_manager_.OnKeyPressed(key_event.text); 492 password_reuse_detection_manager_.OnKeyPressed(key_event.text);
484 } 493 }
485 #endif 494 #endif
486 495
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 return &credentials_filter_; 716 return &credentials_filter_;
708 } 717 }
709 718
710 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() 719 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager()
711 const { 720 const {
712 return log_manager_.get(); 721 return log_manager_.get();
713 } 722 }
714 723
715 // static 724 // static
716 void ChromePasswordManagerClient::BindCredentialManager( 725 void ChromePasswordManagerClient::BindCredentialManager(
717 const service_manager::BindSourceInfo& source_info, 726 password_manager::mojom::CredentialManagerAssociatedRequest request,
718 password_manager::mojom::CredentialManagerRequest request,
719 content::RenderFrameHost* render_frame_host) { 727 content::RenderFrameHost* render_frame_host) {
720 // Only valid for the main frame. 728 // Only valid for the main frame.
721 if (render_frame_host->GetParent()) 729 if (render_frame_host->GetParent())
722 return; 730 return;
723 731
724 content::WebContents* web_contents = 732 content::WebContents* web_contents =
725 content::WebContents::FromRenderFrameHost(render_frame_host); 733 content::WebContents::FromRenderFrameHost(render_frame_host);
726 DCHECK(web_contents); 734 DCHECK(web_contents);
727 735
736 // Only valid for the currently committed RenderFrameHost, and not, e.g. old
737 // zombie RFH's being swapped out following cross-origin navigations.
dcheng 2017/07/03 09:23:33 Hmm... I feel like something at a higher-level is
engedy 2017/07/03 09:43:34 Yes, I agree that this is a bit weird, but note th
738 if (web_contents->GetMainFrame() != render_frame_host)
739 return;
740
728 ChromePasswordManagerClient* instance = 741 ChromePasswordManagerClient* instance =
729 ChromePasswordManagerClient::FromWebContents(web_contents); 742 ChromePasswordManagerClient::FromWebContents(web_contents);
730 743
731 // Try to bind to the driver, but if driver is not available for this render 744 // Try to bind to the driver, but if driver is not available for this render
732 // frame host, the request will be just dropped. This will cause the message 745 // frame host, the request will be just dropped. This will cause the message
733 // pipe to be closed, which will raise a connection error on the peer side. 746 // pipe to be closed, which will raise a connection error on the peer side.
734 if (!instance) 747 if (!instance)
735 return; 748 return;
736 749
737 instance->credential_manager_impl_.BindRequest(std::move(request)); 750 instance->credential_manager_impl_.BindRequest(std::move(request));
738 } 751 }
739 752
740 // static 753 // static
741 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { 754 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) {
742 std::string scheme = url.scheme(); 755 std::string scheme = url.scheme();
743 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 756 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
744 scheme) && 757 scheme) &&
745 #if BUILDFLAG(ENABLE_EXTENSIONS) 758 #if BUILDFLAG(ENABLE_EXTENSIONS)
746 scheme != extensions::kExtensionScheme && 759 scheme != extensions::kExtensionScheme &&
747 #endif 760 #endif
748 scheme != content::kChromeDevToolsScheme); 761 scheme != content::kChromeDevToolsScheme);
749 } 762 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698