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/ref_counted.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
19 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 19 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 20 #include "chrome/browser/password_manager/password_manager_util.h" |
20 #include "chrome/browser/password_manager/password_store_factory.h" | 21 #include "chrome/browser/password_manager/password_store_factory.h" |
21 #include "chrome/browser/prerender/prerender_contents.h" | 22 #include "chrome/browser/prerender/prerender_contents.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/signin/signin_manager_factory.h" | 24 #include "chrome/browser/signin/signin_manager_factory.h" |
24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 25 #include "chrome/browser/sync/profile_sync_service_factory.h" |
25 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 26 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
26 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" | 27 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" |
27 #include "chrome/common/channel_info.h" | 28 #include "chrome/common/channel_info.h" |
28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
(...skipping 25 matching lines...) Expand all Loading... |
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_util::PostHSTSQueryForHostAndProfile(origin, profile_, |
265 content::BrowserThread::IO, FROM_HERE, | 248 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 |