| 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 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "components/autofill/content/browser/content_autofill_driver.h" | 30 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 31 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 31 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 32 #include "components/autofill/core/browser/password_generator.h" | 32 #include "components/autofill/core/browser/password_generator.h" |
| 33 #include "components/autofill/core/common/password_form.h" | 33 #include "components/autofill/core/common/password_form.h" |
| 34 #include "components/browser_sync/profile_sync_service.h" | 34 #include "components/browser_sync/profile_sync_service.h" |
| 35 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 35 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
| 36 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 36 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
| 37 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 37 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
| 38 #include "components/password_manager/core/browser/hsts_query.h" |
| 38 #include "components/password_manager/core/browser/log_manager.h" | 39 #include "components/password_manager/core/browser/log_manager.h" |
| 39 #include "components/password_manager/core/browser/log_receiver.h" | 40 #include "components/password_manager/core/browser/log_receiver.h" |
| 40 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 41 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| 41 #include "components/password_manager/core/browser/password_form_manager.h" | 42 #include "components/password_manager/core/browser/password_form_manager.h" |
| 42 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 43 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
| 43 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 44 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 44 #include "components/password_manager/core/browser/password_manager_settings_mig
ration_experiment.h" | 45 #include "components/password_manager/core/browser/password_manager_settings_mig
ration_experiment.h" |
| 45 #include "components/password_manager/core/browser/password_manager_util.h" | 46 #include "components/password_manager/core/browser/password_manager_util.h" |
| 46 #include "components/password_manager/core/common/credential_manager_types.h" | 47 #include "components/password_manager/core/common/credential_manager_types.h" |
| 47 #include "components/password_manager/core/common/password_manager_features.h" | 48 #include "components/password_manager/core/common/password_manager_features.h" |
| 48 #include "components/password_manager/core/common/password_manager_pref_names.h" | 49 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 49 #include "components/password_manager/sync/browser/password_sync_util.h" | 50 #include "components/password_manager/sync/browser/password_sync_util.h" |
| 50 #include "components/prefs/pref_service.h" | 51 #include "components/prefs/pref_service.h" |
| 51 #include "components/sessions/content/content_record_password_state.h" | 52 #include "components/sessions/content/content_record_password_state.h" |
| 52 #include "components/signin/core/browser/signin_manager.h" | 53 #include "components/signin/core/browser/signin_manager.h" |
| 53 #include "components/version_info/version_info.h" | 54 #include "components/version_info/version_info.h" |
| 54 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
| 55 #include "content/public/browser/child_process_security_policy.h" | 56 #include "content/public/browser/child_process_security_policy.h" |
| 56 #include "content/public/browser/navigation_entry.h" | 57 #include "content/public/browser/navigation_entry.h" |
| 57 #include "content/public/browser/navigation_handle.h" | 58 #include "content/public/browser/navigation_handle.h" |
| 58 #include "content/public/browser/render_view_host.h" | 59 #include "content/public/browser/render_view_host.h" |
| 59 #include "content/public/browser/ssl_status.h" | 60 #include "content/public/browser/ssl_status.h" |
| 60 #include "content/public/browser/web_contents.h" | 61 #include "content/public/browser/web_contents.h" |
| 61 #include "content/public/common/origin_util.h" | 62 #include "content/public/common/origin_util.h" |
| 62 #include "extensions/features/features.h" | 63 #include "extensions/features/features.h" |
| 63 #include "google_apis/gaia/gaia_urls.h" | 64 #include "google_apis/gaia/gaia_urls.h" |
| 64 #include "net/base/url_util.h" | 65 #include "net/base/url_util.h" |
| 65 #include "net/http/transport_security_state.h" | |
| 66 #include "net/url_request/url_request_context.h" | |
| 67 #include "third_party/re2/src/re2/re2.h" | 66 #include "third_party/re2/src/re2/re2.h" |
| 68 | 67 |
| 69 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) | 68 #if defined(SAFE_BROWSING_DB_LOCAL) || defined(SAFE_BROWSING_DB_REMOTE) |
| 70 #include "chrome/browser/browser_process.h" | 69 #include "chrome/browser/browser_process.h" |
| 71 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 70 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 72 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" | 71 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" |
| 73 #endif | 72 #endif |
| 74 | 73 |
| 75 #if defined(OS_ANDROID) | 74 #if defined(OS_ANDROID) |
| 76 #include "chrome/browser/android/tab_android.h" | 75 #include "chrome/browser/android/tab_android.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 client->GetPasswordSyncState() == | 133 client->GetPasswordSyncState() == |
| 135 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE); | 134 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE); |
| 136 } | 135 } |
| 137 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); | 136 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); |
| 138 UMA_HISTOGRAM_BOOLEAN( | 137 UMA_HISTOGRAM_BOOLEAN( |
| 139 "PasswordManager.ShouldShowAutoSignInFirstRunExperience", | 138 "PasswordManager.ShouldShowAutoSignInFirstRunExperience", |
| 140 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( | 139 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( |
| 141 profile->GetPrefs())); | 140 profile->GetPrefs())); |
| 142 } | 141 } |
| 143 | 142 |
| 144 bool IsHSTSActiveForHostAndRequestContext( | |
| 145 const GURL& origin, | |
| 146 const scoped_refptr<net::URLRequestContextGetter>& request_context) { | |
| 147 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 148 if (!origin.is_valid()) | |
| 149 return false; | |
| 150 | |
| 151 net::TransportSecurityState* security_state = | |
| 152 request_context->GetURLRequestContext()->transport_security_state(); | |
| 153 | |
| 154 if (!security_state) | |
| 155 return false; | |
| 156 | |
| 157 return security_state->ShouldUpgradeToSSL(origin.host()); | |
| 158 } | |
| 159 | |
| 160 } // namespace | 143 } // namespace |
| 161 | 144 |
| 162 // static | 145 // static |
| 163 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( | 146 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( |
| 164 content::WebContents* contents, | 147 content::WebContents* contents, |
| 165 autofill::AutofillClient* autofill_client) { | 148 autofill::AutofillClient* autofill_client) { |
| 166 if (FromWebContents(contents)) | 149 if (FromWebContents(contents)) |
| 167 return; | 150 return; |
| 168 | 151 |
| 169 contents->SetUserData( | 152 contents->SetUserData( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 237 } |
| 255 | 238 |
| 256 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const { | 239 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const { |
| 257 return !DidLastPageLoadEncounterSSLErrors() && | 240 return !DidLastPageLoadEncounterSSLErrors() && |
| 258 IsPasswordManagementEnabledForCurrentPage(); | 241 IsPasswordManagementEnabledForCurrentPage(); |
| 259 } | 242 } |
| 260 | 243 |
| 261 void ChromePasswordManagerClient::PostHSTSQueryForHost( | 244 void ChromePasswordManagerClient::PostHSTSQueryForHost( |
| 262 const GURL& origin, | 245 const GURL& origin, |
| 263 const HSTSCallback& callback) const { | 246 const HSTSCallback& callback) const { |
| 264 content::BrowserThread::PostTaskAndReplyWithResult( | 247 password_manager::PostHSTSQueryForHostAndRequestContext( |
| 265 content::BrowserThread::IO, FROM_HERE, | 248 origin, make_scoped_refptr(profile_->GetRequestContext()), callback); |
| 266 base::Bind(&IsHSTSActiveForHostAndRequestContext, origin, | |
| 267 make_scoped_refptr(profile_->GetRequestContext())), | |
| 268 callback); | |
| 269 } | 249 } |
| 270 | 250 |
| 271 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { | 251 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { |
| 272 prerender::PrerenderContents* prerender_contents = | 252 prerender::PrerenderContents* prerender_contents = |
| 273 prerender::PrerenderContents::FromWebContents(web_contents()); | 253 prerender::PrerenderContents::FromWebContents(web_contents()); |
| 274 if (prerender_contents) { | 254 if (prerender_contents) { |
| 275 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); | 255 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); |
| 276 return false; | 256 return false; |
| 277 } | 257 } |
| 278 return true; | 258 return true; |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // static | 690 // static |
| 711 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { | 691 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { |
| 712 std::string scheme = url.scheme(); | 692 std::string scheme = url.scheme(); |
| 713 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 693 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
| 714 scheme) && | 694 scheme) && |
| 715 #if BUILDFLAG(ENABLE_EXTENSIONS) | 695 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 716 scheme != extensions::kExtensionScheme && | 696 scheme != extensions::kExtensionScheme && |
| 717 #endif | 697 #endif |
| 718 scheme != content::kChromeDevToolsScheme); | 698 scheme != content::kChromeDevToolsScheme); |
| 719 } | 699 } |
| OLD | NEW |