Commit 4ca3f37d authored by Dominic Battre's avatar Dominic Battre Committed by Commit Bot

Disable manual password generation in some cases

This CL disables manual password generation in the context menu in case the
user has disabled the password manager or the site has an SSL problem (in which
case Chrome would not fill the credential).

Bug: 875751
Change-Id: I900590e6674ba0d039033fb5bacfb83f39bcba52
Reviewed-on: https://chromium-review.googlesource.com/1180966Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584457}
parent 0186fab3
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#include "chrome/browser/search/search.h" #include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h" #include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/translate/chrome_translate_client.h" #include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h" #include "chrome/browser/translate/translate_service.h"
#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
...@@ -85,6 +84,7 @@ ...@@ -85,6 +84,7 @@
#include "components/language/core/browser/language_model_manager.h" #include "components/language/core/browser/language_model_manager.h"
#include "components/omnibox/browser/autocomplete_classifier.h" #include "components/omnibox/browser/autocomplete_classifier.h"
#include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_match.h"
#include "components/password_manager/content/browser/content_password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/experiments.h" #include "components/password_manager/core/common/experiments.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
...@@ -1582,9 +1582,10 @@ void RenderViewContextMenu::AppendPasswordItems() { ...@@ -1582,9 +1582,10 @@ void RenderViewContextMenu::AppendPasswordItems() {
IDS_CONTENT_CONTEXT_FORCESAVEPASSWORD); IDS_CONTENT_CONTEXT_FORCESAVEPASSWORD);
add_separator = true; add_separator = true;
} }
if (password_manager_util::ManualPasswordGenerationEnabled( password_manager::ContentPasswordManagerDriver* driver =
ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost(
browser_context_))) { GetRenderFrameHost());
if (password_manager_util::ManualPasswordGenerationEnabled(driver)) {
menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATEPASSWORD, menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATEPASSWORD,
IDS_CONTENT_CONTEXT_GENERATEPASSWORD); IDS_CONTENT_CONTEXT_GENERATEPASSWORD);
add_separator = true; add_separator = true;
......
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
#include "components/autofill/core/common/password_generation_util.h" #include "components/autofill/core/common/password_generation_util.h"
#include "components/password_manager/core/browser/hsts_query.h" #include "components/password_manager/core/browser/hsts_query.h"
#include "components/password_manager/core/browser/log_manager.h" #include "components/password_manager/core/browser/log_manager.h"
#include "components/password_manager/core/browser/password_generation_manager.h"
#include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_store_consumer.h" #include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_features.h"
...@@ -338,11 +340,15 @@ bool IsLoggingActive(const password_manager::PasswordManagerClient* client) { ...@@ -338,11 +340,15 @@ bool IsLoggingActive(const password_manager::PasswordManagerClient* client) {
return log_manager && log_manager->IsLoggingActive(); return log_manager && log_manager->IsLoggingActive();
} }
bool ManualPasswordGenerationEnabled(syncer::SyncService* sync_service) { bool ManualPasswordGenerationEnabled(
if (password_manager_util::GetPasswordSyncState(sync_service) != password_manager::PasswordManagerDriver* driver) {
password_manager::SYNCING_NORMAL_ENCRYPTION) { password_manager::PasswordGenerationManager* password_generation_manager =
driver ? driver->GetPasswordGenerationManager() : nullptr;
if (!password_generation_manager ||
!password_generation_manager->IsGenerationEnabled(false /*logging*/)) {
return false; return false;
} }
LogPasswordGenerationEvent( LogPasswordGenerationEvent(
autofill::password_generation::PASSWORD_GENERATION_CONTEXT_MENU_SHOWN); autofill::password_generation::PASSWORD_GENERATION_CONTEXT_MENU_SHOWN);
return true; return true;
......
...@@ -24,6 +24,7 @@ class URLRequestContextGetter; ...@@ -24,6 +24,7 @@ class URLRequestContextGetter;
} }
namespace password_manager { namespace password_manager {
class PasswordManagerDriver;
class PasswordManagerClient; class PasswordManagerClient;
class PasswordStore; class PasswordStore;
} }
...@@ -71,9 +72,9 @@ void TrimUsernameOnlyCredentials( ...@@ -71,9 +72,9 @@ void TrimUsernameOnlyCredentials(
// and required to always return non-null. // and required to always return non-null.
bool IsLoggingActive(const password_manager::PasswordManagerClient* client); bool IsLoggingActive(const password_manager::PasswordManagerClient* client);
// True iff the manual password generation is enabled and the user is sync user // True iff the manual password generation is enabled for the current site.
// without custom passphrase. bool ManualPasswordGenerationEnabled(
bool ManualPasswordGenerationEnabled(syncer::SyncService* sync_service); password_manager::PasswordManagerDriver* driver);
// Returns true iff the "Show all saved passwords" option should be shown in // Returns true iff the "Show all saved passwords" option should be shown in
// Context Menu. Also records metric, that the Context Menu will have "Show all // Context Menu. Also records metric, that the Context Menu will have "Show all
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment