| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 18 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 19 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 19 #include "chrome/browser/password_manager/password_store_factory.h" | 20 #include "chrome/browser/password_manager/password_store_factory.h" |
| 20 #include "chrome/browser/prerender/prerender_contents.h" | 21 #include "chrome/browser/prerender/prerender_contents.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/signin/signin_manager_factory.h" | 23 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 #include "components/password_manager/core/browser/password_manager_settings_mig
ration_experiment.h" | 44 #include "components/password_manager/core/browser/password_manager_settings_mig
ration_experiment.h" |
| 44 #include "components/password_manager/core/browser/password_manager_util.h" | 45 #include "components/password_manager/core/browser/password_manager_util.h" |
| 45 #include "components/password_manager/core/common/credential_manager_types.h" | 46 #include "components/password_manager/core/common/credential_manager_types.h" |
| 46 #include "components/password_manager/core/common/password_manager_features.h" | 47 #include "components/password_manager/core/common/password_manager_features.h" |
| 47 #include "components/password_manager/core/common/password_manager_pref_names.h" | 48 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 48 #include "components/password_manager/sync/browser/password_sync_util.h" | 49 #include "components/password_manager/sync/browser/password_sync_util.h" |
| 49 #include "components/prefs/pref_service.h" | 50 #include "components/prefs/pref_service.h" |
| 50 #include "components/sessions/content/content_record_password_state.h" | 51 #include "components/sessions/content/content_record_password_state.h" |
| 51 #include "components/signin/core/browser/signin_manager.h" | 52 #include "components/signin/core/browser/signin_manager.h" |
| 52 #include "components/version_info/version_info.h" | 53 #include "components/version_info/version_info.h" |
| 54 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/child_process_security_policy.h" | 55 #include "content/public/browser/child_process_security_policy.h" |
| 54 #include "content/public/browser/navigation_entry.h" | 56 #include "content/public/browser/navigation_entry.h" |
| 55 #include "content/public/browser/navigation_handle.h" | 57 #include "content/public/browser/navigation_handle.h" |
| 56 #include "content/public/browser/render_view_host.h" | 58 #include "content/public/browser/render_view_host.h" |
| 57 #include "content/public/browser/ssl_status.h" | 59 #include "content/public/browser/ssl_status.h" |
| 58 #include "content/public/browser/web_contents.h" | 60 #include "content/public/browser/web_contents.h" |
| 59 #include "content/public/common/origin_util.h" | 61 #include "content/public/common/origin_util.h" |
| 60 #include "extensions/features/features.h" | 62 #include "extensions/features/features.h" |
| 61 #include "google_apis/gaia/gaia_urls.h" | 63 #include "google_apis/gaia/gaia_urls.h" |
| 62 #include "net/base/url_util.h" | 64 #include "net/base/url_util.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 client->GetPasswordSyncState() == | 128 client->GetPasswordSyncState() == |
| 127 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE); | 129 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE); |
| 128 } | 130 } |
| 129 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); | 131 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); |
| 130 UMA_HISTOGRAM_BOOLEAN( | 132 UMA_HISTOGRAM_BOOLEAN( |
| 131 "PasswordManager.ShouldShowAutoSignInFirstRunExperience", | 133 "PasswordManager.ShouldShowAutoSignInFirstRunExperience", |
| 132 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( | 134 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( |
| 133 profile->GetPrefs())); | 135 profile->GetPrefs())); |
| 134 } | 136 } |
| 135 | 137 |
| 138 bool IsHSTSActiveForHostAndRequestContext( |
| 139 const GURL& origin, |
| 140 const scoped_refptr<net::URLRequestContextGetter>& request_context) { |
| 141 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 142 if (!origin.is_valid()) |
| 143 return false; |
| 144 |
| 145 net::TransportSecurityState* security_state = |
| 146 request_context->GetURLRequestContext()->transport_security_state(); |
| 147 |
| 148 if (!security_state) |
| 149 return false; |
| 150 |
| 151 return security_state->ShouldUpgradeToSSL(origin.host()); |
| 152 } |
| 153 |
| 136 } // namespace | 154 } // namespace |
| 137 | 155 |
| 138 // static | 156 // static |
| 139 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( | 157 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( |
| 140 content::WebContents* contents, | 158 content::WebContents* contents, |
| 141 autofill::AutofillClient* autofill_client) { | 159 autofill::AutofillClient* autofill_client) { |
| 142 if (FromWebContents(contents)) | 160 if (FromWebContents(contents)) |
| 143 return; | 161 return; |
| 144 | 162 |
| 145 contents->SetUserData( | 163 contents->SetUserData( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // here once we decide to switch to new settings behavior for everyone. | 236 // here once we decide to switch to new settings behavior for everyone. |
| 219 return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() && | 237 return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() && |
| 220 IsFillingEnabledForCurrentPage(); | 238 IsFillingEnabledForCurrentPage(); |
| 221 } | 239 } |
| 222 | 240 |
| 223 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const { | 241 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const { |
| 224 return !DidLastPageLoadEncounterSSLErrors() && | 242 return !DidLastPageLoadEncounterSSLErrors() && |
| 225 IsPasswordManagementEnabledForCurrentPage(); | 243 IsPasswordManagementEnabledForCurrentPage(); |
| 226 } | 244 } |
| 227 | 245 |
| 228 bool ChromePasswordManagerClient::IsHSTSActiveForHost( | 246 void ChromePasswordManagerClient::PostHSTSQueryForHost( |
| 229 const GURL& origin) const { | 247 const GURL& origin, |
| 230 if (!origin.is_valid()) | 248 const HSTSCallback& callback) const { |
| 231 return false; | 249 content::BrowserThread::PostTaskAndReplyWithResult( |
| 232 | 250 content::BrowserThread::IO, FROM_HERE, |
| 233 net::TransportSecurityState* security_state = | 251 base::Bind(&IsHSTSActiveForHostAndRequestContext, origin, |
| 234 profile_->GetRequestContext() | 252 make_scoped_refptr(profile_->GetRequestContext())), |
| 235 ->GetURLRequestContext() | 253 callback); |
| 236 ->transport_security_state(); | |
| 237 | |
| 238 if (!security_state) | |
| 239 return false; | |
| 240 | |
| 241 return security_state->ShouldUpgradeToSSL(origin.host()); | |
| 242 } | 254 } |
| 243 | 255 |
| 244 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { | 256 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { |
| 245 prerender::PrerenderContents* prerender_contents = | 257 prerender::PrerenderContents* prerender_contents = |
| 246 prerender::PrerenderContents::FromWebContents(web_contents()); | 258 prerender::PrerenderContents::FromWebContents(web_contents()); |
| 247 if (prerender_contents) { | 259 if (prerender_contents) { |
| 248 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); | 260 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); |
| 249 return false; | 261 return false; |
| 250 } | 262 } |
| 251 return true; | 263 return true; |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 // static | 688 // static |
| 677 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { | 689 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { |
| 678 std::string scheme = url.scheme(); | 690 std::string scheme = url.scheme(); |
| 679 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( | 691 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( |
| 680 scheme) && | 692 scheme) && |
| 681 #if BUILDFLAG(ENABLE_EXTENSIONS) | 693 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 682 scheme != extensions::kExtensionScheme && | 694 scheme != extensions::kExtensionScheme && |
| 683 #endif | 695 #endif |
| 684 scheme != content::kChromeDevToolsScheme); | 696 scheme != content::kChromeDevToolsScheme); |
| 685 } | 697 } |
| OLD | NEW |