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

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

Issue 2783773002: Link PasswordProtectionService to Profile and SB Service (Closed)
Patch Set: refine histogram description Created 3 years, 8 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 password_manager::PasswordManagerInternalsServiceFactory:: 179 password_manager::PasswordManagerInternalsServiceFactory::
180 GetForBrowserContext(profile_), 180 GetForBrowserContext(profile_),
181 base::Bind( 181 base::Bind(
182 &ContentPasswordManagerDriverFactory::RequestSendLoggingAvailability, 182 &ContentPasswordManagerDriverFactory::RequestSendLoggingAvailability,
183 base::Unretained(driver_factory_))); 183 base::Unretained(driver_factory_)));
184 184
185 saving_and_filling_passwords_enabled_.Init( 185 saving_and_filling_passwords_enabled_.Init(
186 password_manager::prefs::kCredentialsEnableService, GetPrefs()); 186 password_manager::prefs::kCredentialsEnableService, GetPrefs());
187 ReportMetrics(*saving_and_filling_passwords_enabled_, this, profile_); 187 ReportMetrics(*saving_and_filling_passwords_enabled_, this, profile_);
188 driver_factory_->RequestSendLoggingAvailability(); 188 driver_factory_->RequestSendLoggingAvailability();
189
190 #if (defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)) && \
191 !defined(OS_ANDROID) && !defined(OS_IOS)
192 if (CanSetPasswordProtectionService()) {
193 password_reuse_detection_manager_.SetPasswordProtectionService(
194 g_browser_process->safe_browsing_service()
195 ->password_protection_service()
196 ->GetWeakPtr());
197 }
198 #endif
199 } 189 }
200 190
201 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} 191 ChromePasswordManagerClient::~ChromePasswordManagerClient() {}
202 192
203 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() 193 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage()
204 const { 194 const {
205 DCHECK(web_contents()); 195 DCHECK(web_contents());
206 content::NavigationEntry* entry = 196 content::NavigationEntry* entry =
207 web_contents()->GetController().GetLastCommittedEntry(); 197 web_contents()->GetController().GetLastCommittedEntry();
208 bool is_enabled = false; 198 bool is_enabled = false;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, 394 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin,
405 federated_matches); 395 federated_matches);
406 #endif 396 #endif
407 } 397 }
408 398
409 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { 399 void ChromePasswordManagerClient::HidePasswordGenerationPopup() {
410 if (popup_controller_) 400 if (popup_controller_)
411 popup_controller_->HideAndDestroy(); 401 popup_controller_->HideAndDestroy();
412 } 402 }
413 403
404 #if defined(SAFE_BROWSING_DB_LOCAL)
405 safe_browsing::PasswordProtectionService*
406 ChromePasswordManagerClient::GetPasswordProtectionService() const {
407 if (g_browser_process && g_browser_process->safe_browsing_service()) {
408 return g_browser_process->safe_browsing_service()
409 ->GetPasswordProtectionService(profile_);
410 }
411 return nullptr;
412 }
413 #endif
414
414 // TODO(crbug.com/706392): Fix password reuse detection for Android. 415 // TODO(crbug.com/706392): Fix password reuse detection for Android.
415 #if !defined(OS_ANDROID) 416 #if !defined(OS_ANDROID)
416 void ChromePasswordManagerClient::DidFinishNavigation( 417 void ChromePasswordManagerClient::DidFinishNavigation(
417 content::NavigationHandle* navigation_handle) { 418 content::NavigationHandle* navigation_handle) {
418 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) 419 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
419 return; 420 return;
420 421
421 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); 422 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL());
422 // After some navigations RenderViewHost persists and just adding the observer 423 // After some navigations RenderViewHost persists and just adding the observer
423 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to 424 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 browser_sync::ProfileSyncService* profile_sync_service = 628 browser_sync::ProfileSyncService* profile_sync_service =
628 ProfileSyncServiceFactory::GetForProfile(profile); 629 ProfileSyncServiceFactory::GetForProfile(profile);
629 if (!profile_sync_service || !profile_sync_service->IsSyncActive() || 630 if (!profile_sync_service || !profile_sync_service->IsSyncActive() ||
630 profile_sync_service->IsUsingSecondaryPassphrase()) { 631 profile_sync_service->IsUsingSecondaryPassphrase()) {
631 return false; 632 return false;
632 } 633 }
633 634
634 return true; 635 return true;
635 } 636 }
636 637
637 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
638 bool ChromePasswordManagerClient::CanSetPasswordProtectionService() {
639 return g_browser_process && g_browser_process->safe_browsing_service() &&
640 g_browser_process->safe_browsing_service()
641 ->password_protection_service();
642 }
643 #endif
644
645 void ChromePasswordManagerClient::AnnotateNavigationEntry( 638 void ChromePasswordManagerClient::AnnotateNavigationEntry(
646 bool has_password_field) { 639 bool has_password_field) {
647 if (!ShouldAnnotateNavigationEntries(profile_)) 640 if (!ShouldAnnotateNavigationEntries(profile_))
648 return; 641 return;
649 642
650 content::NavigationEntry* entry = 643 content::NavigationEntry* entry =
651 web_contents()->GetController().GetLastCommittedEntry(); 644 web_contents()->GetController().GetLastCommittedEntry();
652 if (!entry) 645 if (!entry)
653 return; 646 return;
654 647
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 // static 690 // static
698 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { 691 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) {
699 std::string scheme = url.scheme(); 692 std::string scheme = url.scheme();
700 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 693 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
701 scheme) && 694 scheme) &&
702 #if BUILDFLAG(ENABLE_EXTENSIONS) 695 #if BUILDFLAG(ENABLE_EXTENSIONS)
703 scheme != extensions::kExtensionScheme && 696 scheme != extensions::kExtensionScheme &&
704 #endif 697 #endif
705 scheme != content::kChromeDevToolsScheme); 698 scheme != content::kChromeDevToolsScheme);
706 } 699 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698