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 16 matching lines...) Expand all Loading... |
42 #include "components/password_manager/sync/browser/password_sync_util.h" | 41 #include "components/password_manager/sync/browser/password_sync_util.h" |
43 #include "components/signin/core/browser/signin_manager.h" | 42 #include "components/signin/core/browser/signin_manager.h" |
44 #include "components/version_info/version_info.h" | 43 #include "components/version_info/version_info.h" |
45 #include "content/public/browser/navigation_entry.h" | 44 #include "content/public/browser/navigation_entry.h" |
46 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
47 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
48 #include "google_apis/gaia/gaia_urls.h" | 47 #include "google_apis/gaia/gaia_urls.h" |
49 #include "net/base/url_util.h" | 48 #include "net/base/url_util.h" |
50 #include "third_party/re2/re2/re2.h" | 49 #include "third_party/re2/re2/re2.h" |
51 | 50 |
| 51 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 52 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
| 53 #endif |
| 54 |
52 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
53 #include "chrome/browser/android/tab_android.h" | 56 #include "chrome/browser/android/tab_android.h" |
54 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" | 57 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg
ate_android.h" |
55 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h" | 58 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h" |
56 #endif | 59 #endif |
57 | 60 |
58 using password_manager::ContentPasswordManagerDriverFactory; | 61 using password_manager::ContentPasswordManagerDriverFactory; |
59 using password_manager::PasswordManagerInternalsService; | 62 using password_manager::PasswordManagerInternalsService; |
60 using password_manager::PasswordManagerInternalsServiceFactory; | 63 using password_manager::PasswordManagerInternalsServiceFactory; |
61 | 64 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (IsTheHotNewBubbleUIEnabled()) { | 212 if (IsTheHotNewBubbleUIEnabled()) { |
210 ManagePasswordsUIController* manage_passwords_ui_controller = | 213 ManagePasswordsUIController* manage_passwords_ui_controller = |
211 ManagePasswordsUIController::FromWebContents(web_contents()); | 214 ManagePasswordsUIController::FromWebContents(web_contents()); |
212 if (update_password && IsUpdatePasswordUIEnabled()) { | 215 if (update_password && IsUpdatePasswordUIEnabled()) { |
213 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( | 216 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( |
214 form_to_save.Pass()); | 217 form_to_save.Pass()); |
215 } else { | 218 } else { |
216 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); | 219 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); |
217 } | 220 } |
218 } else { | 221 } else { |
| 222 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
219 if (form_to_save->IsBlacklisted()) | 223 if (form_to_save->IsBlacklisted()) |
220 return false; | 224 return false; |
221 std::string uma_histogram_suffix( | 225 std::string uma_histogram_suffix( |
222 password_manager::metrics_util::GroupIdToString( | 226 password_manager::metrics_util::GroupIdToString( |
223 password_manager::metrics_util::MonitoredDomainGroupId( | 227 password_manager::metrics_util::MonitoredDomainGroupId( |
224 form_to_save->pending_credentials().signon_realm, GetPrefs()))); | 228 form_to_save->pending_credentials().signon_realm, GetPrefs()))); |
225 SavePasswordInfoBarDelegate::Create( | 229 SavePasswordInfoBarDelegate::Create( |
226 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); | 230 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); |
| 231 #else |
| 232 NOTREACHED() << "Aura platforms should always use the bubble"; |
| 233 #endif |
227 } | 234 } |
228 return true; | 235 return true; |
229 } | 236 } |
230 | 237 |
231 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( | 238 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( |
232 ScopedVector<autofill::PasswordForm> local_forms, | 239 ScopedVector<autofill::PasswordForm> local_forms, |
233 ScopedVector<autofill::PasswordForm> federated_forms, | 240 ScopedVector<autofill::PasswordForm> federated_forms, |
234 const GURL& origin, | 241 const GURL& origin, |
235 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 242 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
236 return ManagePasswordsUIController::FromWebContents(web_contents())-> | 243 return ManagePasswordsUIController::FromWebContents(web_contents())-> |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 return false; | 506 return false; |
500 | 507 |
501 // All password sites, including test sites, have autofilling disabled. | 508 // All password sites, including test sites, have autofilling disabled. |
502 CR_DEFINE_STATIC_LOCAL(RE2, account_dashboard_pattern, | 509 CR_DEFINE_STATIC_LOCAL(RE2, account_dashboard_pattern, |
503 ("passwords(-([a-z-]+\\.corp))?\\.google\\.com")); | 510 ("passwords(-([a-z-]+\\.corp))?\\.google\\.com")); |
504 | 511 |
505 return RE2::FullMatch(GURL(param_value).host(), account_dashboard_pattern); | 512 return RE2::FullMatch(GURL(param_value).host(), account_dashboard_pattern); |
506 } | 513 } |
507 | 514 |
508 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { | 515 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { |
509 #if !defined(USE_AURA) && !defined(OS_MACOSX) | 516 #if defined(OS_ANDROID) |
510 return false; | 517 return false; |
511 #endif | 518 #elif defined(OS_MACOSX) |
512 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 519 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
513 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) | 520 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) |
514 return false; | 521 return false; |
515 | 522 |
516 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) | 523 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) |
517 return true; | 524 return true; |
518 | 525 |
519 std::string group_name = | 526 std::string group_name = |
520 base::FieldTrialList::FindFullName("PasswordManagerUI"); | 527 base::FieldTrialList::FindFullName("PasswordManagerUI"); |
521 | 528 |
522 // The bubble should be the default case that runs on the bots. | 529 // The bubble should be the default case that runs on the bots. |
523 return group_name != "Infobar"; | 530 return group_name != "Infobar"; |
| 531 #else |
| 532 // All other platforms use Aura, and therefore always show the bubble. |
| 533 return true; |
| 534 #endif |
524 } | 535 } |
525 | 536 |
526 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { | 537 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { |
527 #if defined(OS_MACOSX) | 538 #if defined(OS_MACOSX) |
528 return false; | 539 return false; |
529 #else | 540 #else |
530 return IsTheHotNewBubbleUIEnabled(); | 541 return IsTheHotNewBubbleUIEnabled(); |
531 #endif | 542 #endif |
532 } | 543 } |
533 | 544 |
(...skipping 24 matching lines...) Expand all Loading... |
558 if (!entry) | 569 if (!entry) |
559 return GURL::EmptyGURL(); | 570 return GURL::EmptyGURL(); |
560 | 571 |
561 return entry->GetURL(); | 572 return entry->GetURL(); |
562 } | 573 } |
563 | 574 |
564 const password_manager::CredentialsFilter* | 575 const password_manager::CredentialsFilter* |
565 ChromePasswordManagerClient::GetStoreResultFilter() const { | 576 ChromePasswordManagerClient::GetStoreResultFilter() const { |
566 return &credentials_filter_; | 577 return &credentials_filter_; |
567 } | 578 } |
OLD | NEW |