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

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: RemovePasswordProtectionService(..) 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 GetForBrowserContext(profile_), 194 GetForBrowserContext(profile_),
195 base::Bind( 195 base::Bind(
196 &ContentPasswordManagerDriverFactory::RequestSendLoggingAvailability, 196 &ContentPasswordManagerDriverFactory::RequestSendLoggingAvailability,
197 base::Unretained(driver_factory_))); 197 base::Unretained(driver_factory_)));
198 198
199 saving_and_filling_passwords_enabled_.Init( 199 saving_and_filling_passwords_enabled_.Init(
200 password_manager::prefs::kCredentialsEnableService, GetPrefs()); 200 password_manager::prefs::kCredentialsEnableService, GetPrefs());
201 ReportMetrics(*saving_and_filling_passwords_enabled_, this, profile_); 201 ReportMetrics(*saving_and_filling_passwords_enabled_, this, profile_);
202 driver_factory_->RequestSendLoggingAvailability(); 202 driver_factory_->RequestSendLoggingAvailability();
203 203
204 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
205 if (CanSetPasswordProtectionService()) {
206 password_reuse_detection_manager_.SetPasswordProtectionService(
207 g_browser_process->safe_browsing_service()
208 ->password_protection_service()
209 ->GetWeakPtr());
210 }
211 #endif
212 } 204 }
213 205
214 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} 206 ChromePasswordManagerClient::~ChromePasswordManagerClient() {}
215 207
216 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() 208 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage()
217 const { 209 const {
218 DCHECK(web_contents()); 210 DCHECK(web_contents());
219 content::NavigationEntry* entry = 211 content::NavigationEntry* entry =
220 web_contents()->GetController().GetLastCommittedEntry(); 212 web_contents()->GetController().GetLastCommittedEntry();
221 bool is_enabled = false; 213 bool is_enabled = false;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, 412 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin,
421 federated_matches); 413 federated_matches);
422 #endif 414 #endif
423 } 415 }
424 416
425 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { 417 void ChromePasswordManagerClient::HidePasswordGenerationPopup() {
426 if (popup_controller_) 418 if (popup_controller_)
427 popup_controller_->HideAndDestroy(); 419 popup_controller_->HideAndDestroy();
428 } 420 }
429 421
422 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
423 safe_browsing::PasswordProtectionService*
424 ChromePasswordManagerClient::GetPasswordProtectionService() const {
425 if (g_browser_process && g_browser_process->safe_browsing_service()) {
426 return g_browser_process->safe_browsing_service()
427 ->GetPasswordProtectionService(profile_);
428 }
429 return nullptr;
430 }
431 #endif
432
430 void ChromePasswordManagerClient::DidFinishNavigation( 433 void ChromePasswordManagerClient::DidFinishNavigation(
431 content::NavigationHandle* navigation_handle) { 434 content::NavigationHandle* navigation_handle) {
432 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) 435 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
433 return; 436 return;
434 437
435 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); 438 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL());
436 // After some navigations RenderViewHost persists and just adding the observer 439 // After some navigations RenderViewHost persists and just adding the observer
437 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to 440 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to
438 // check whether the observer is already added, the observer is removed and 441 // check whether the observer is already added, the observer is removed and
439 // added again, to ensure that it is added only once. 442 // added again, to ensure that it is added only once.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 browser_sync::ProfileSyncService* profile_sync_service = 643 browser_sync::ProfileSyncService* profile_sync_service =
641 ProfileSyncServiceFactory::GetForProfile(profile); 644 ProfileSyncServiceFactory::GetForProfile(profile);
642 if (!profile_sync_service || !profile_sync_service->IsSyncActive() || 645 if (!profile_sync_service || !profile_sync_service->IsSyncActive() ||
643 profile_sync_service->IsUsingSecondaryPassphrase()) { 646 profile_sync_service->IsUsingSecondaryPassphrase()) {
644 return false; 647 return false;
645 } 648 }
646 649
647 return true; 650 return true;
648 } 651 }
649 652
650 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)
651 bool ChromePasswordManagerClient::CanSetPasswordProtectionService() {
652 return g_browser_process && g_browser_process->safe_browsing_service() &&
653 g_browser_process->safe_browsing_service()
654 ->password_protection_service();
655 }
656 #endif
657
658 void ChromePasswordManagerClient::AnnotateNavigationEntry( 653 void ChromePasswordManagerClient::AnnotateNavigationEntry(
659 bool has_password_field) { 654 bool has_password_field) {
660 if (!ShouldAnnotateNavigationEntries(profile_)) 655 if (!ShouldAnnotateNavigationEntries(profile_))
661 return; 656 return;
662 657
663 content::NavigationEntry* entry = 658 content::NavigationEntry* entry =
664 web_contents()->GetController().GetLastCommittedEntry(); 659 web_contents()->GetController().GetLastCommittedEntry();
665 if (!entry) 660 if (!entry)
666 return; 661 return;
667 662
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // static 705 // static
711 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { 706 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) {
712 std::string scheme = url.scheme(); 707 std::string scheme = url.scheme();
713 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 708 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
714 scheme) && 709 scheme) &&
715 #if BUILDFLAG(ENABLE_EXTENSIONS) 710 #if BUILDFLAG(ENABLE_EXTENSIONS)
716 scheme != extensions::kExtensionScheme && 711 scheme != extensions::kExtensionScheme &&
717 #endif 712 #endif
718 scheme != content::kChromeDevToolsScheme); 713 scheme != content::kChromeDevToolsScheme);
719 } 714 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698