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

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

Issue 2721663002: Move Credentials when migrating to HSTS page (Closed)
Patch Set: More Explanation Created 3 years, 9 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"
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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 client->GetPasswordSyncState() == 134 client->GetPasswordSyncState() ==
133 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE); 135 password_manager::SYNCING_WITH_CUSTOM_PASSPHRASE);
134 } 136 }
135 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled); 137 UMA_HISTOGRAM_BOOLEAN("PasswordManager.Enabled", password_manager_enabled);
136 UMA_HISTOGRAM_BOOLEAN( 138 UMA_HISTOGRAM_BOOLEAN(
137 "PasswordManager.ShouldShowAutoSignInFirstRunExperience", 139 "PasswordManager.ShouldShowAutoSignInFirstRunExperience",
138 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 140 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
139 profile->GetPrefs())); 141 profile->GetPrefs()));
140 } 142 }
141 143
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
142 } // namespace 160 } // namespace
143 161
144 // static 162 // static
145 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( 163 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
146 content::WebContents* contents, 164 content::WebContents* contents,
147 autofill::AutofillClient* autofill_client) { 165 autofill::AutofillClient* autofill_client) {
148 if (FromWebContents(contents)) 166 if (FromWebContents(contents))
149 return; 167 return;
150 168
151 contents->SetUserData( 169 contents->SetUserData(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // here once we decide to switch to new settings behavior for everyone. 251 // here once we decide to switch to new settings behavior for everyone.
234 return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() && 252 return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() &&
235 IsFillingEnabledForCurrentPage(); 253 IsFillingEnabledForCurrentPage();
236 } 254 }
237 255
238 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const { 256 bool ChromePasswordManagerClient::IsFillingEnabledForCurrentPage() const {
239 return !DidLastPageLoadEncounterSSLErrors() && 257 return !DidLastPageLoadEncounterSSLErrors() &&
240 IsPasswordManagementEnabledForCurrentPage(); 258 IsPasswordManagementEnabledForCurrentPage();
241 } 259 }
242 260
243 bool ChromePasswordManagerClient::IsHSTSActiveForHost( 261 void ChromePasswordManagerClient::PostHSTSQueryForHost(
244 const GURL& origin) const { 262 const GURL& origin,
245 if (!origin.is_valid()) 263 const HSTSCallback& callback) const {
246 return false; 264 content::BrowserThread::PostTaskAndReplyWithResult(
247 265 content::BrowserThread::IO, FROM_HERE,
248 net::TransportSecurityState* security_state = 266 base::Bind(&IsHSTSActiveForHostAndRequestContext, origin,
249 profile_->GetRequestContext() 267 make_scoped_refptr(profile_->GetRequestContext())),
250 ->GetURLRequestContext() 268 callback);
251 ->transport_security_state();
252
253 if (!security_state)
254 return false;
255
256 return security_state->ShouldUpgradeToSSL(origin.host());
257 } 269 }
258 270
259 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { 271 bool ChromePasswordManagerClient::OnCredentialManagerUsed() {
260 prerender::PrerenderContents* prerender_contents = 272 prerender::PrerenderContents* prerender_contents =
261 prerender::PrerenderContents::FromWebContents(web_contents()); 273 prerender::PrerenderContents::FromWebContents(web_contents());
262 if (prerender_contents) { 274 if (prerender_contents) {
263 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); 275 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API);
264 return false; 276 return false;
265 } 277 }
266 return true; 278 return true;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 // static 710 // static
699 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { 711 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) {
700 std::string scheme = url.scheme(); 712 std::string scheme = url.scheme();
701 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 713 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
702 scheme) && 714 scheme) &&
703 #if BUILDFLAG(ENABLE_EXTENSIONS) 715 #if BUILDFLAG(ENABLE_EXTENSIONS)
704 scheme != extensions::kExtensionScheme && 716 scheme != extensions::kExtensionScheme &&
705 #endif 717 #endif
706 scheme != content::kChromeDevToolsScheme); 718 scheme != content::kChromeDevToolsScheme);
707 } 719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698