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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/chrome_version_info.h" | 24 #include "chrome/common/chrome_version_info.h" |
25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
26 #include "components/autofill/content/common/autofill_messages.h" | 26 #include "components/autofill/content/common/autofill_messages.h" |
27 #include "components/autofill/core/browser/password_generator.h" | 27 #include "components/autofill/core/browser/password_generator.h" |
28 #include "components/autofill/core/common/password_form.h" | 28 #include "components/autofill/core/common/password_form.h" |
29 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" | 29 #include "components/password_manager/content/browser/password_manager_internals
_service_factory.h" |
30 #include "components/password_manager/content/common/credential_manager_messages
.h" | 30 #include "components/password_manager/content/common/credential_manager_messages
.h" |
31 #include "components/password_manager/content/common/credential_manager_types.h" | 31 #include "components/password_manager/content/common/credential_manager_types.h" |
| 32 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
32 #include "components/password_manager/core/browser/log_receiver.h" | 33 #include "components/password_manager/core/browser/log_receiver.h" |
33 #include "components/password_manager/core/browser/password_form_manager.h" | 34 #include "components/password_manager/core/browser/password_form_manager.h" |
34 #include "components/password_manager/core/browser/password_manager.h" | 35 #include "components/password_manager/core/browser/password_manager.h" |
35 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 36 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
36 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 37 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
37 #include "components/password_manager/core/common/password_manager_switches.h" | 38 #include "components/password_manager/core/common/password_manager_switches.h" |
38 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
39 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
41 #include "google_apis/gaia/gaia_urls.h" | 42 #include "google_apis/gaia/gaia_urls.h" |
42 #include "net/base/url_util.h" | 43 #include "net/base/url_util.h" |
43 #include "third_party/re2/re2/re2.h" | 44 #include "third_party/re2/re2/re2.h" |
44 | 45 |
45 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
46 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" | 47 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" |
47 #endif | 48 #endif |
48 | 49 |
49 using password_manager::PasswordManagerInternalsService; | 50 using password_manager::PasswordManagerInternalsService; |
50 using password_manager::PasswordManagerInternalsServiceFactory; | 51 using password_manager::PasswordManagerInternalsServiceFactory; |
51 | 52 |
52 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); | 53 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); |
53 | 54 |
| 55 // Shorten the name to spare line breaks. The code provides enough context |
| 56 // already. |
| 57 typedef autofill::SavePasswordProgressLogger Logger; |
| 58 |
54 // static | 59 // static |
55 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( | 60 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( |
56 content::WebContents* contents, | 61 content::WebContents* contents, |
57 autofill::AutofillClient* autofill_client) { | 62 autofill::AutofillClient* autofill_client) { |
58 if (FromWebContents(contents)) | 63 if (FromWebContents(contents)) |
59 return; | 64 return; |
60 | 65 |
61 contents->SetUserData( | 66 contents->SetUserData( |
62 UserDataKey(), | 67 UserDataKey(), |
63 new ChromePasswordManagerClient(contents, autofill_client)); | 68 new ChromePasswordManagerClient(contents, autofill_client)); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (service) | 288 if (service) |
284 service->ProcessLog(text); | 289 service->ProcessLog(text); |
285 } | 290 } |
286 | 291 |
287 bool ChromePasswordManagerClient::IsLoggingActive() const { | 292 bool ChromePasswordManagerClient::IsLoggingActive() const { |
288 // WebUI tabs do not need to log password saving progress. In particular, the | 293 // WebUI tabs do not need to log password saving progress. In particular, the |
289 // internals page itself should not send any logs. | 294 // internals page itself should not send any logs. |
290 return can_use_log_router_ && !web_contents()->GetWebUI(); | 295 return can_use_log_router_ && !web_contents()->GetWebUI(); |
291 } | 296 } |
292 | 297 |
| 298 bool ChromePasswordManagerClient::WasLastNavigationHTTPError() const { |
| 299 DCHECK(web_contents()); |
| 300 |
| 301 scoped_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; |
| 302 if (IsLoggingActive()) { |
| 303 logger.reset(new password_manager::BrowserSavePasswordProgressLogger(this)); |
| 304 logger->LogMessage( |
| 305 Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR_METHOD); |
| 306 } |
| 307 |
| 308 content::NavigationEntry* entry = |
| 309 web_contents()->GetController().GetVisibleEntry(); |
| 310 if (!entry) |
| 311 return false; |
| 312 int http_status_code = entry->GetHttpStatusCode(); |
| 313 |
| 314 if (logger) |
| 315 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); |
| 316 |
| 317 if (http_status_code >= 400 && http_status_code < 600) |
| 318 return true; |
| 319 return false; |
| 320 } |
| 321 |
293 // static | 322 // static |
294 password_manager::PasswordGenerationManager* | 323 password_manager::PasswordGenerationManager* |
295 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( | 324 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( |
296 content::WebContents* contents) { | 325 content::WebContents* contents) { |
297 ChromePasswordManagerClient* client = | 326 ChromePasswordManagerClient* client = |
298 ChromePasswordManagerClient::FromWebContents(contents); | 327 ChromePasswordManagerClient::FromWebContents(contents); |
299 if (!client) | 328 if (!client) |
300 return NULL; | 329 return NULL; |
301 return client->GetDriver()->GetPasswordGenerationManager(); | 330 return client->GetDriver()->GetPasswordGenerationManager(); |
302 } | 331 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 518 |
490 if (group_name == "DisallowSyncCredentialsForReauth") { | 519 if (group_name == "DisallowSyncCredentialsForReauth") { |
491 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 520 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
492 } else if (group_name == "DisallowSyncCredentials") { | 521 } else if (group_name == "DisallowSyncCredentials") { |
493 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 522 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
494 } else { | 523 } else { |
495 // Allow by default. | 524 // Allow by default. |
496 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 525 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
497 } | 526 } |
498 } | 527 } |
OLD | NEW |