Skip to content

Commit

Permalink
Restrict generation context menu item only to non passphrase sync users
Browse files Browse the repository at this point in the history
BUG=739343, 775509
TBR=melandory@chromium.org

(cherry picked from commit 8c7026b)

Change-Id: I7f9b42cadd63c55c5b59d9787f6a41ff0742a556
Reviewed-on: https://chromium-review.googlesource.com/707436
Commit-Queue: Tatiana Gornak <melandory@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#509459}
Reviewed-on: https://chromium-review.googlesource.com/727763
Reviewed-by: Tatiana Gornak <melandory@chromium.org>
Cr-Commit-Position: refs/branch-heads/3239@{#65}
Cr-Branched-From: adb61db-refs/heads/master@{#508578}
  • Loading branch information
Tatiana Gornak committed Oct 19, 2017
1 parent bb6e290 commit 73d1627
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_service_factory.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/translate_service.h"
#include "chrome/browser/ui/autofill/chrome_autofill_client.h"
Expand Down Expand Up @@ -80,6 +81,7 @@
#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "components/omnibox/browser/autocomplete_classifier.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/experiments.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
Expand Down Expand Up @@ -1529,7 +1531,9 @@ void RenderViewContextMenu::AppendPasswordItems() {
IDS_CONTENT_CONTEXT_FORCESAVEPASSWORD);
add_separator = true;
}
if (password_manager::ManualPasswordGenerationEnabled()) {
if (password_manager_util::ManualPasswordGenerationEnabled(
ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(
source_web_contents_->GetBrowserContext()))) {
menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_GENERATEPASSWORD,
IDS_CONTENT_CONTEXT_GENERATEPASSWORD);
add_separator = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/stl_util.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/log_manager.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/sync/driver/sync_service.h"
#include "crypto/openssl_util.h"
#include "third_party/boringssl/src/include/openssl/evp.h"
Expand Down Expand Up @@ -118,4 +119,11 @@ uint64_t CalculateSyncPasswordHash(const base::StringPiece16& text,
return hash37;
}

bool ManualPasswordGenerationEnabled(syncer::SyncService* sync_service) {
return (base::FeatureList::IsEnabled(
password_manager::features::kEnableManualPasswordGeneration) &&
(password_manager_util::GetPasswordSyncState(sync_service) ==
password_manager::SYNCING_NORMAL_ENCRYPTION));
}

} // namespace password_manager_util
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ bool IsLoggingActive(const password_manager::PasswordManagerClient* client);
uint64_t CalculateSyncPasswordHash(const base::StringPiece16& text,
const std::string& salt);

// True iff the manual password generation is enabled and the user is sync user
// without custom passphrase.
bool ManualPasswordGenerationEnabled(syncer::SyncService* sync_service);

} // namespace password_manager_util

#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_UTIL_H_
5 changes: 0 additions & 5 deletions components/password_manager/core/common/experiments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ bool ForceSavingExperimentEnabled() {
password_manager::features::kEnablePasswordForceSaving);
}

bool ManualPasswordGenerationEnabled() {
return base::FeatureList::IsEnabled(
password_manager::features::kEnableManualPasswordGeneration);
}

bool ShowAllSavedPasswordsContextMenuEnabled() {
return base::FeatureList::IsEnabled(
password_manager::features::kEnableShowAllSavedPasswordsContextMenu);
Expand Down
3 changes: 0 additions & 3 deletions components/password_manager/core/common/experiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace password_manager {
// True iff the force-saving of passwords is enabled.
bool ForceSavingExperimentEnabled();

// True iff the manual password generation is enabled.
bool ManualPasswordGenerationEnabled();

// True iff the "Show all saved passwords" option should be shown in Context
// Menu.
bool ShowAllSavedPasswordsContextMenuEnabled();
Expand Down

0 comments on commit 73d1627

Please sign in to comment.