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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "components/password_manager/core/browser/log_receiver.h" | 39 #include "components/password_manager/core/browser/log_receiver.h" |
40 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 40 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
41 #include "components/password_manager/core/browser/password_form_manager.h" | 41 #include "components/password_manager/core/browser/password_form_manager.h" |
42 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" | 42 #include "components/password_manager/core/browser/password_manager_internals_se
rvice.h" |
43 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 43 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
44 #include "components/password_manager/core/browser/password_manager_settings_mig
ration_experiment.h" | 44 #include "components/password_manager/core/browser/password_manager_settings_mig
ration_experiment.h" |
45 #include "components/password_manager/core/browser/password_manager_util.h" | 45 #include "components/password_manager/core/browser/password_manager_util.h" |
46 #include "components/password_manager/core/common/credential_manager_types.h" | 46 #include "components/password_manager/core/common/credential_manager_types.h" |
47 #include "components/password_manager/core/common/password_manager_features.h" | 47 #include "components/password_manager/core/common/password_manager_features.h" |
48 #include "components/password_manager/core/common/password_manager_pref_names.h" | 48 #include "components/password_manager/core/common/password_manager_pref_names.h" |
49 #include "components/password_manager/core/common/password_manager_switches.h" | |
50 #include "components/password_manager/sync/browser/password_sync_util.h" | 49 #include "components/password_manager/sync/browser/password_sync_util.h" |
51 #include "components/prefs/pref_service.h" | 50 #include "components/prefs/pref_service.h" |
52 #include "components/signin/core/browser/signin_manager.h" | 51 #include "components/signin/core/browser/signin_manager.h" |
53 #include "components/version_info/version_info.h" | 52 #include "components/version_info/version_info.h" |
54 #include "content/public/browser/navigation_entry.h" | 53 #include "content/public/browser/navigation_entry.h" |
55 #include "content/public/browser/render_view_host.h" | 54 #include "content/public/browser/render_view_host.h" |
56 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
57 #include "google_apis/gaia/gaia_urls.h" | 56 #include "google_apis/gaia/gaia_urls.h" |
58 #include "net/base/url_util.h" | 57 #include "net/base/url_util.h" |
59 #include "third_party/re2/src/re2/re2.h" | 58 #include "third_party/re2/src/re2/re2.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 173 |
175 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() | 174 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() |
176 const { | 175 const { |
177 DCHECK(web_contents()); | 176 DCHECK(web_contents()); |
178 content::NavigationEntry* entry = | 177 content::NavigationEntry* entry = |
179 web_contents()->GetController().GetLastCommittedEntry(); | 178 web_contents()->GetController().GetLastCommittedEntry(); |
180 bool is_enabled = false; | 179 bool is_enabled = false; |
181 if (!entry) { | 180 if (!entry) { |
182 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. | 181 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. |
183 is_enabled = true; | 182 is_enabled = true; |
184 } else if (EnabledForSyncSignin()) { | 183 } else if (base::FeatureList::IsEnabled( |
| 184 password_manager::features::kManagerForSyncSignin)) { |
185 is_enabled = true; | 185 is_enabled = true; |
186 } else { | 186 } else { |
187 // Do not fill nor save password when a user is signing in for sync. This | 187 // Do not fill nor save password when a user is signing in for sync. This |
188 // is because users need to remember their password if they are syncing as | 188 // is because users need to remember their password if they are syncing as |
189 // this is effectively their master password. | 189 // this is effectively their master password. |
190 is_enabled = | 190 is_enabled = |
191 entry->GetURL().host_piece() != chrome::kChromeUIChromeSigninHost; | 191 entry->GetURL().host_piece() != chrome::kChromeUIChromeSigninHost; |
192 } | 192 } |
193 if (log_manager_->IsLoggingActive()) { | 193 if (log_manager_->IsLoggingActive()) { |
194 password_manager::BrowserSavePasswordProgressLogger logger( | 194 password_manager::BrowserSavePasswordProgressLogger logger( |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 | 592 |
593 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { | 593 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { |
594 #if BUILDFLAG(ANDROID_JAVA_UI) | 594 #if BUILDFLAG(ANDROID_JAVA_UI) |
595 return base::FeatureList::IsEnabled( | 595 return base::FeatureList::IsEnabled( |
596 password_manager::features::kEnablePasswordChangeSupport); | 596 password_manager::features::kEnablePasswordChangeSupport); |
597 #else | 597 #else |
598 return IsTheHotNewBubbleUIEnabled(); | 598 return IsTheHotNewBubbleUIEnabled(); |
599 #endif | 599 #endif |
600 } | 600 } |
601 | 601 |
602 bool ChromePasswordManagerClient::EnabledForSyncSignin() { | |
603 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
604 if (command_line->HasSwitch( | |
605 password_manager::switches::kDisableManagerForSyncSignin)) | |
606 return false; | |
607 | |
608 if (command_line->HasSwitch( | |
609 password_manager::switches::kEnableManagerForSyncSignin)) | |
610 return true; | |
611 | |
612 // Default is enabled. | |
613 std::string group_name = | |
614 base::FieldTrialList::FindFullName("PasswordManagerStateForSyncSignin"); | |
615 return group_name != "Disabled"; | |
616 } | |
617 | |
618 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { | 602 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { |
619 return web_contents()->GetVisibleURL(); | 603 return web_contents()->GetVisibleURL(); |
620 } | 604 } |
621 | 605 |
622 const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const { | 606 const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const { |
623 DCHECK(web_contents()); | 607 DCHECK(web_contents()); |
624 content::NavigationEntry* entry = | 608 content::NavigationEntry* entry = |
625 web_contents()->GetController().GetLastCommittedEntry(); | 609 web_contents()->GetController().GetLastCommittedEntry(); |
626 if (!entry) | 610 if (!entry) |
627 return GURL::EmptyGURL(); | 611 return GURL::EmptyGURL(); |
628 | 612 |
629 return entry->GetURL(); | 613 return entry->GetURL(); |
630 } | 614 } |
631 | 615 |
632 const password_manager::CredentialsFilter* | 616 const password_manager::CredentialsFilter* |
633 ChromePasswordManagerClient::GetStoreResultFilter() const { | 617 ChromePasswordManagerClient::GetStoreResultFilter() const { |
634 return &credentials_filter_; | 618 return &credentials_filter_; |
635 } | 619 } |
636 | 620 |
637 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() | 621 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() |
638 const { | 622 const { |
639 return log_manager_.get(); | 623 return log_manager_.get(); |
640 } | 624 } |
OLD | NEW |