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.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
14 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
15 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
18 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
19 #include "chrome/browser/sync/profile_sync_service_factory.h" | 18 #include "chrome/browser/sync/profile_sync_service_factory.h" |
20 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" | 19 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h
" |
21 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 20 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
22 #include "chrome/common/channel_info.h" | 21 #include "chrome/common/channel_info.h" |
23 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
25 #include "components/autofill/content/browser/content_autofill_driver.h" | 24 #include "components/autofill/content/browser/content_autofill_driver.h" |
(...skipping 17 matching lines...) Expand all Loading... |
43 #include "components/password_manager/sync/browser/password_sync_util.h" | 42 #include "components/password_manager/sync/browser/password_sync_util.h" |
44 #include "components/signin/core/browser/signin_manager.h" | 43 #include "components/signin/core/browser/signin_manager.h" |
45 #include "components/version_info/version_info.h" | 44 #include "components/version_info/version_info.h" |
46 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
47 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
48 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
49 #include "google_apis/gaia/gaia_urls.h" | 48 #include "google_apis/gaia/gaia_urls.h" |
50 #include "net/base/url_util.h" | 49 #include "net/base/url_util.h" |
51 #include "third_party/re2/re2/re2.h" | 50 #include "third_party/re2/re2/re2.h" |
52 | 51 |
| 52 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 53 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
| 54 #endif |
| 55 |
53 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
54 #include "chrome/browser/android/tab_android.h" | 57 #include "chrome/browser/android/tab_android.h" |
55 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" | 58 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" |
56 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h" | 59 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h" |
57 #endif | 60 #endif |
58 | 61 |
59 using password_manager::ContentPasswordManagerDriverFactory; | 62 using password_manager::ContentPasswordManagerDriverFactory; |
60 using password_manager::PasswordManagerInternalsService; | 63 using password_manager::PasswordManagerInternalsService; |
61 using password_manager::PasswordManagerInternalsServiceFactory; | 64 using password_manager::PasswordManagerInternalsServiceFactory; |
62 | 65 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (IsTheHotNewBubbleUIEnabled()) { | 222 if (IsTheHotNewBubbleUIEnabled()) { |
220 ManagePasswordsUIController* manage_passwords_ui_controller = | 223 ManagePasswordsUIController* manage_passwords_ui_controller = |
221 ManagePasswordsUIController::FromWebContents(web_contents()); | 224 ManagePasswordsUIController::FromWebContents(web_contents()); |
222 if (update_password && IsUpdatePasswordUIEnabled()) { | 225 if (update_password && IsUpdatePasswordUIEnabled()) { |
223 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( | 226 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( |
224 form_to_save.Pass()); | 227 form_to_save.Pass()); |
225 } else { | 228 } else { |
226 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); | 229 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); |
227 } | 230 } |
228 } else { | 231 } else { |
| 232 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
229 if (form_to_save->IsBlacklisted()) | 233 if (form_to_save->IsBlacklisted()) |
230 return false; | 234 return false; |
231 std::string uma_histogram_suffix( | 235 std::string uma_histogram_suffix( |
232 password_manager::metrics_util::GroupIdToString( | 236 password_manager::metrics_util::GroupIdToString( |
233 password_manager::metrics_util::MonitoredDomainGroupId( | 237 password_manager::metrics_util::MonitoredDomainGroupId( |
234 form_to_save->pending_credentials().signon_realm, GetPrefs()))); | 238 form_to_save->pending_credentials().signon_realm, GetPrefs()))); |
235 SavePasswordInfoBarDelegate::Create( | 239 SavePasswordInfoBarDelegate::Create( |
236 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); | 240 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); |
| 241 #else |
| 242 NOTREACHED() << "Aura platforms should always use the bubble"; |
| 243 #endif |
237 } | 244 } |
238 return true; | 245 return true; |
239 } | 246 } |
240 | 247 |
241 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( | 248 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( |
242 ScopedVector<autofill::PasswordForm> local_forms, | 249 ScopedVector<autofill::PasswordForm> local_forms, |
243 ScopedVector<autofill::PasswordForm> federated_forms, | 250 ScopedVector<autofill::PasswordForm> federated_forms, |
244 const GURL& origin, | 251 const GURL& origin, |
245 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 252 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
246 return ManagePasswordsUIController::FromWebContents(web_contents())-> | 253 return ManagePasswordsUIController::FromWebContents(web_contents())-> |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 return false; | 516 return false; |
510 | 517 |
511 // All password sites, including test sites, have autofilling disabled. | 518 // All password sites, including test sites, have autofilling disabled. |
512 CR_DEFINE_STATIC_LOCAL(RE2, account_dashboard_pattern, | 519 CR_DEFINE_STATIC_LOCAL(RE2, account_dashboard_pattern, |
513 ("passwords(-([a-z-]+\\.corp))?\\.google\\.com")); | 520 ("passwords(-([a-z-]+\\.corp))?\\.google\\.com")); |
514 | 521 |
515 return RE2::FullMatch(GURL(param_value).host(), account_dashboard_pattern); | 522 return RE2::FullMatch(GURL(param_value).host(), account_dashboard_pattern); |
516 } | 523 } |
517 | 524 |
518 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { | 525 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { |
519 #if !defined(USE_AURA) && !defined(OS_MACOSX) | 526 #if defined(OS_ANDROID) |
520 return false; | 527 return false; |
521 #endif | 528 #elif defined(OS_MACOSX) |
522 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 529 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
523 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) | 530 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) |
524 return false; | 531 return false; |
525 | 532 |
526 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) | 533 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) |
527 return true; | 534 return true; |
528 | 535 |
529 std::string group_name = | 536 std::string group_name = |
530 base::FieldTrialList::FindFullName("PasswordManagerUI"); | 537 base::FieldTrialList::FindFullName("PasswordManagerUI"); |
531 | 538 |
532 // The bubble should be the default case that runs on the bots. | 539 // The bubble should be the default case that runs on the bots. |
533 return group_name != "Infobar"; | 540 return group_name != "Infobar"; |
| 541 #else |
| 542 // All other platforms use Aura, and therefore always show the bubble. |
| 543 return true; |
| 544 #endif |
534 } | 545 } |
535 | 546 |
536 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { | 547 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { |
537 #if defined(OS_MACOSX) | 548 #if defined(OS_MACOSX) |
538 return false; | 549 return false; |
539 #else | 550 #else |
540 return IsTheHotNewBubbleUIEnabled(); | 551 return IsTheHotNewBubbleUIEnabled(); |
541 #endif | 552 #endif |
542 } | 553 } |
543 | 554 |
(...skipping 24 matching lines...) Expand all Loading... |
568 if (!entry) | 579 if (!entry) |
569 return GURL::EmptyGURL(); | 580 return GURL::EmptyGURL(); |
570 | 581 |
571 return entry->GetURL(); | 582 return entry->GetURL(); |
572 } | 583 } |
573 | 584 |
574 const password_manager::CredentialsFilter* | 585 const password_manager::CredentialsFilter* |
575 ChromePasswordManagerClient::GetStoreResultFilter() const { | 586 ChromePasswordManagerClient::GetStoreResultFilter() const { |
576 return &credentials_filter_; | 587 return &credentials_filter_; |
577 } | 588 } |
OLD | NEW |