Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3107)

Unified Diff: chrome/browser/ui/passwords/password_manager_url_collection_experiment.cc

Issue 777423004: Skeleton code for experiment setup, which will determine should "Allow to collect URL?" bubble be s… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/passwords/password_manager_url_collection_experiment.cc
diff --git a/chrome/browser/ui/passwords/password_manager_url_collection_experiment.cc b/chrome/browser/ui/passwords/password_manager_url_collection_experiment.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1f8f67f6b1d736822468403107f25d2345d81e20
--- /dev/null
+++ b/chrome/browser/ui/passwords/password_manager_url_collection_experiment.cc
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/passwords/password_manager_url_collection_experiment.h"
+
+#include "base/metrics/field_trial.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/common/pref_names.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+
+namespace password_manager {
+namespace urls_collection_experiment {
+
+namespace {
+
+bool MaybeShowBubbleExperiment(PrefService* prefs) {
+ // TODO(melandory): Make decision based on Finch experiment parameters.
+ return false;
+}
+
+} // namespace
+
+void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(
+ ::prefs::kWasAllowToCollectURLBubbleShown,
+ false, // bubble hasn't been shown yet
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+}
+
+const char kExperimentName[] = "AksToSubmitURLBubble";
+const char kGroupMaybeShowBubble[] = "ShowBubble";
+const char kGroupNeverShowBubble[] = "NeverShowBubble";
+
+bool ShouldShowBubble(PrefService* prefs) {
+ if (prefs->GetBoolean(::prefs::kWasAllowToCollectURLBubbleShown)) {
+ if (!base::FieldTrialList::TrialExists(kExperimentName))
+ return false;
+ std::string group_name =
+ base::FieldTrialList::FindFullName(kExperimentName);
+ if (group_name == kGroupMaybeShowBubble)
+ return MaybeShowBubbleExperiment(prefs);
+ }
+ // "Do not show" is the default case.
+ return false;
+}
+
+void RecordBubbleClosed(PrefService* prefs) {
+ prefs->SetBoolean(::prefs::kWasAllowToCollectURLBubbleShown, true);
+}
+
+} // namespace urls_collection_experiment
+} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698