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 ChromePasswordManagerClient* client = | |
vabr (Chromium)
2014/11/18 10:10:11
Don't retrieve the |client| and use |this| instead
Sunil Ratnu
2014/11/18 12:58:39
The function had const in its signature. Hence, I
vabr (Chromium)
2014/11/18 14:22:49
This should be fixed by https://codereview.chromiu
| |
304 ChromePasswordManagerClient::FromWebContents(web_contents()); | |
305 logger.reset( | |
306 new password_manager::BrowserSavePasswordProgressLogger(client)); | |
307 logger->LogMessage(Logger::STRING_WAS_LAST_NAVIGATION_HTTP_ERROR); | |
308 } | |
309 | |
310 content::NavigationEntry* entry = | |
311 web_contents()->GetController().GetVisibleEntry(); | |
312 if (!entry) | |
313 return false; | |
314 int http_status_code = entry->GetHttpStatusCode(); | |
315 | |
316 if (logger) | |
317 logger->LogNumber(Logger::STRING_HTTP_STATUS_CODE, http_status_code); | |
318 | |
319 if (http_status_code >= 400 && http_status_code < 600) | |
320 return true; | |
321 return false; | |
322 } | |
323 | |
293 // static | 324 // static |
294 password_manager::PasswordGenerationManager* | 325 password_manager::PasswordGenerationManager* |
295 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( | 326 ChromePasswordManagerClient::GetGenerationManagerFromWebContents( |
296 content::WebContents* contents) { | 327 content::WebContents* contents) { |
297 ChromePasswordManagerClient* client = | 328 ChromePasswordManagerClient* client = |
298 ChromePasswordManagerClient::FromWebContents(contents); | 329 ChromePasswordManagerClient::FromWebContents(contents); |
299 if (!client) | 330 if (!client) |
300 return NULL; | 331 return NULL; |
301 return client->GetDriver()->GetPasswordGenerationManager(); | 332 return client->GetDriver()->GetPasswordGenerationManager(); |
302 } | 333 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 | 520 |
490 if (group_name == "DisallowSyncCredentialsForReauth") { | 521 if (group_name == "DisallowSyncCredentialsForReauth") { |
491 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; | 522 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS_FOR_REAUTH; |
492 } else if (group_name == "DisallowSyncCredentials") { | 523 } else if (group_name == "DisallowSyncCredentials") { |
493 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; | 524 autofill_sync_state_ = DISALLOW_SYNC_CREDENTIALS; |
494 } else { | 525 } else { |
495 // Allow by default. | 526 // Allow by default. |
496 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; | 527 autofill_sync_state_ = ALLOW_SYNC_CREDENTIALS; |
497 } | 528 } |
498 } | 529 } |
OLD | NEW |