| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 UserDataKey(), | 170 UserDataKey(), |
| 171 new ChromePasswordManagerClient(contents, autofill_client)); | 171 new ChromePasswordManagerClient(contents, autofill_client)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 ChromePasswordManagerClient::ChromePasswordManagerClient( | 174 ChromePasswordManagerClient::ChromePasswordManagerClient( |
| 175 content::WebContents* web_contents, | 175 content::WebContents* web_contents, |
| 176 autofill::AutofillClient* autofill_client) | 176 autofill::AutofillClient* autofill_client) |
| 177 : content::WebContentsObserver(web_contents), | 177 : content::WebContentsObserver(web_contents), |
| 178 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 178 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), |
| 179 password_manager_(this), | 179 password_manager_(this), |
| 180 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 181 #if !defined(OS_ANDROID) |
| 180 password_reuse_detection_manager_(this), | 182 password_reuse_detection_manager_(this), |
| 183 #endif |
| 181 driver_factory_(nullptr), | 184 driver_factory_(nullptr), |
| 182 credential_manager_impl_(web_contents, this), | 185 credential_manager_impl_(web_contents, this), |
| 183 password_manager_client_bindings_(web_contents, this), | 186 password_manager_client_bindings_(web_contents, this), |
| 184 observer_(nullptr), | 187 observer_(nullptr), |
| 185 credentials_filter_(this, | 188 credentials_filter_(this, |
| 186 base::Bind(&GetSyncService, profile_), | 189 base::Bind(&GetSyncService, profile_), |
| 187 base::Bind(&GetSigninManager, profile_)) { | 190 base::Bind(&GetSigninManager, profile_)) { |
| 188 ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this, | 191 ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this, |
| 189 autofill_client); | 192 autofill_client); |
| 190 driver_factory_ = | 193 driver_factory_ = |
| 191 ContentPasswordManagerDriverFactory::FromWebContents(web_contents); | 194 ContentPasswordManagerDriverFactory::FromWebContents(web_contents); |
| 192 log_manager_ = password_manager::LogManager::Create( | 195 log_manager_ = password_manager::LogManager::Create( |
| 193 password_manager::PasswordManagerInternalsServiceFactory:: | 196 password_manager::PasswordManagerInternalsServiceFactory:: |
| 194 GetForBrowserContext(profile_), | 197 GetForBrowserContext(profile_), |
| 195 base::Bind( | 198 base::Bind( |
| 196 &ContentPasswordManagerDriverFactory::RequestSendLoggingAvailability, | 199 &ContentPasswordManagerDriverFactory::RequestSendLoggingAvailability, |
| 197 base::Unretained(driver_factory_))); | 200 base::Unretained(driver_factory_))); |
| 198 | 201 |
| 199 saving_and_filling_passwords_enabled_.Init( | 202 saving_and_filling_passwords_enabled_.Init( |
| 200 password_manager::prefs::kCredentialsEnableService, GetPrefs()); | 203 password_manager::prefs::kCredentialsEnableService, GetPrefs()); |
| 201 ReportMetrics(*saving_and_filling_passwords_enabled_, this, profile_); | 204 ReportMetrics(*saving_and_filling_passwords_enabled_, this, profile_); |
| 202 driver_factory_->RequestSendLoggingAvailability(); | 205 driver_factory_->RequestSendLoggingAvailability(); |
| 203 | 206 |
| 204 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) | 207 #if (defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE)) && \ |
| 208 !defined(OS_ANDROID) && !defined(OS_IOS) |
| 205 if (CanSetPasswordProtectionService()) { | 209 if (CanSetPasswordProtectionService()) { |
| 206 password_reuse_detection_manager_.SetPasswordProtectionService( | 210 password_reuse_detection_manager_.SetPasswordProtectionService( |
| 207 g_browser_process->safe_browsing_service() | 211 g_browser_process->safe_browsing_service() |
| 208 ->password_protection_service() | 212 ->password_protection_service() |
| 209 ->GetWeakPtr()); | 213 ->GetWeakPtr()); |
| 210 } | 214 } |
| 211 #endif | 215 #endif |
| 212 } | 216 } |
| 213 | 217 |
| 214 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} | 218 ChromePasswordManagerClient::~ChromePasswordManagerClient() {} |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, | 424 manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, |
| 421 federated_matches); | 425 federated_matches); |
| 422 #endif | 426 #endif |
| 423 } | 427 } |
| 424 | 428 |
| 425 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { | 429 void ChromePasswordManagerClient::HidePasswordGenerationPopup() { |
| 426 if (popup_controller_) | 430 if (popup_controller_) |
| 427 popup_controller_->HideAndDestroy(); | 431 popup_controller_->HideAndDestroy(); |
| 428 } | 432 } |
| 429 | 433 |
| 434 // TODO(crbug.com/706392): Fix password reuse detection for Android. |
| 435 #if !defined(OS_ANDROID) |
| 430 void ChromePasswordManagerClient::DidFinishNavigation( | 436 void ChromePasswordManagerClient::DidFinishNavigation( |
| 431 content::NavigationHandle* navigation_handle) { | 437 content::NavigationHandle* navigation_handle) { |
| 432 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) | 438 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| 433 return; | 439 return; |
| 434 | 440 |
| 435 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); | 441 password_reuse_detection_manager_.DidNavigateMainFrame(GetMainFrameURL()); |
| 436 // After some navigations RenderViewHost persists and just adding the observer | 442 // After some navigations RenderViewHost persists and just adding the observer |
| 437 // will cause multiple call of OnInputEvent. Since Widget API doesn't allow to | 443 // 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 | 444 // check whether the observer is already added, the observer is removed and |
| 439 // added again, to ensure that it is added only once. | 445 // added again, to ensure that it is added only once. |
| 440 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver( | 446 web_contents()->GetRenderViewHost()->GetWidget()->RemoveInputEventObserver( |
| 441 this); | 447 this); |
| 442 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this); | 448 web_contents()->GetRenderViewHost()->GetWidget()->AddInputEventObserver(this); |
| 443 } | 449 } |
| 444 | 450 |
| 445 void ChromePasswordManagerClient::OnInputEvent( | 451 void ChromePasswordManagerClient::OnInputEvent( |
| 446 const blink::WebInputEvent& event) { | 452 const blink::WebInputEvent& event) { |
| 447 if (event.type() != blink::WebInputEvent::Char) | 453 if (event.type() != blink::WebInputEvent::Char) |
| 448 return; | 454 return; |
| 449 const blink::WebKeyboardEvent& key_event = | 455 const blink::WebKeyboardEvent& key_event = |
| 450 static_cast<const blink::WebKeyboardEvent&>(event); | 456 static_cast<const blink::WebKeyboardEvent&>(event); |
| 451 password_reuse_detection_manager_.OnKeyPressed(key_event.text); | 457 password_reuse_detection_manager_.OnKeyPressed(key_event.text); |
| 452 } | 458 } |
| 459 #endif |
| 453 | 460 |
| 454 PrefService* ChromePasswordManagerClient::GetPrefs() { | 461 PrefService* ChromePasswordManagerClient::GetPrefs() { |
| 455 return profile_->GetPrefs(); | 462 return profile_->GetPrefs(); |
| 456 } | 463 } |
| 457 | 464 |
| 458 password_manager::PasswordStore* | 465 password_manager::PasswordStore* |
| 459 ChromePasswordManagerClient::GetPasswordStore() const { | 466 ChromePasswordManagerClient::GetPasswordStore() const { |
| 460 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord | 467 // Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord |
| 461 // itself when it shouldn't access the PasswordStore. | 468 // itself when it shouldn't access the PasswordStore. |
| 462 // TODO(gcasto): Is is safe to change this to | 469 // TODO(gcasto): Is is safe to change this to |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // static | 717 // static |
| 711 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { | 718 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { |
| 712 std::string scheme = url.scheme(); | 719 std::string scheme = url.scheme(); |
| 713 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 720 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
| 714 scheme) && | 721 scheme) && |
| 715 #if BUILDFLAG(ENABLE_EXTENSIONS) | 722 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 716 scheme != extensions::kExtensionScheme && | 723 scheme != extensions::kExtensionScheme && |
| 717 #endif | 724 #endif |
| 718 scheme != content::kChromeDevToolsScheme); | 725 scheme != content::kChromeDevToolsScheme); |
| 719 } | 726 } |
| OLD | NEW |