| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  174  |  174  | 
|  175 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() |  175 bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage() | 
|  176     const { |  176     const { | 
|  177   DCHECK(web_contents()); |  177   DCHECK(web_contents()); | 
|  178   content::NavigationEntry* entry = |  178   content::NavigationEntry* entry = | 
|  179       web_contents()->GetController().GetLastCommittedEntry(); |  179       web_contents()->GetController().GetLastCommittedEntry(); | 
|  180   bool is_enabled = false; |  180   bool is_enabled = false; | 
|  181   if (!entry) { |  181   if (!entry) { | 
|  182     // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. |  182     // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here. | 
|  183     is_enabled = true; |  183     is_enabled = true; | 
|  184   } else if (EnabledForSyncSignin()) { |  | 
|  185     is_enabled = true; |  | 
|  186   } else { |  184   } else { | 
|  187     // Do not fill nor save password when a user is signing in for sync. This |  185     // 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 |  186     // is because users need to remember their password if they are syncing as | 
|  189     // this is effectively their master password. |  187     // this is effectively their master password. | 
|  190     is_enabled = |  188     is_enabled = | 
|  191         entry->GetURL().host_piece() != chrome::kChromeUIChromeSigninHost; |  189         entry->GetURL().host_piece() != chrome::kChromeUIChromeSigninHost; | 
|  192   } |  190   } | 
|  193   if (log_manager_->IsLoggingActive()) { |  191   if (log_manager_->IsLoggingActive()) { | 
|  194     password_manager::BrowserSavePasswordProgressLogger logger( |  192     password_manager::BrowserSavePasswordProgressLogger logger( | 
|  195         log_manager_.get()); |  193         log_manager_.get()); | 
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  592  |  590  | 
|  593 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { |  591 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { | 
|  594 #if BUILDFLAG(ANDROID_JAVA_UI) |  592 #if BUILDFLAG(ANDROID_JAVA_UI) | 
|  595   return base::FeatureList::IsEnabled( |  593   return base::FeatureList::IsEnabled( | 
|  596       password_manager::features::kEnablePasswordChangeSupport); |  594       password_manager::features::kEnablePasswordChangeSupport); | 
|  597 #else |  595 #else | 
|  598   return IsTheHotNewBubbleUIEnabled(); |  596   return IsTheHotNewBubbleUIEnabled(); | 
|  599 #endif |  597 #endif | 
|  600 } |  598 } | 
|  601  |  599  | 
|  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 { |  600 const GURL& ChromePasswordManagerClient::GetMainFrameURL() const { | 
|  619   return web_contents()->GetVisibleURL(); |  601   return web_contents()->GetVisibleURL(); | 
|  620 } |  602 } | 
|  621  |  603  | 
|  622 const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const { |  604 const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const { | 
|  623   DCHECK(web_contents()); |  605   DCHECK(web_contents()); | 
|  624   content::NavigationEntry* entry = |  606   content::NavigationEntry* entry = | 
|  625       web_contents()->GetController().GetLastCommittedEntry(); |  607       web_contents()->GetController().GetLastCommittedEntry(); | 
|  626   if (!entry) |  608   if (!entry) | 
|  627     return GURL::EmptyGURL(); |  609     return GURL::EmptyGURL(); | 
|  628  |  610  | 
|  629   return entry->GetURL(); |  611   return entry->GetURL(); | 
|  630 } |  612 } | 
|  631  |  613  | 
|  632 const password_manager::CredentialsFilter* |  614 const password_manager::CredentialsFilter* | 
|  633 ChromePasswordManagerClient::GetStoreResultFilter() const { |  615 ChromePasswordManagerClient::GetStoreResultFilter() const { | 
|  634   return &credentials_filter_; |  616   return &credentials_filter_; | 
|  635 } |  617 } | 
|  636  |  618  | 
|  637 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() |  619 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() | 
|  638     const { |  620     const { | 
|  639   return log_manager_.get(); |  621   return log_manager_.get(); | 
|  640 } |  622 } | 
| OLD | NEW |