0

[Sync] Add favicon sync experiment

The old tab sync favicon experiment is deprecated. This patch updates the
strings to the fact that we now have a separate datatype, and hooks this
up to a new sync field.

BUG=154886


Review URL: https://chromiumcodereview.appspot.com/12700016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188974 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
zea@chromium.org
2013-03-19 09:58:38 +00:00
parent b71dbb0a4d
commit a5e9faaf38
7 changed files with 53 additions and 42 deletions

@ -6447,11 +6447,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_DISABLE_OVERSCROLL_HISTORY_NAVIGATION_DESCRIPTION" desc="Description for the flag to disable history navigation from horizontal overscroll.">
Disables experimental history navigation in response to horizontal overscroll.
</message>
<message name="IDS_FLAGS_SYNC_TAB_FAVICONS_NAME" desc="Title for the flag to enable syncing tab favicons with tab sync">
Enable tab favicon sync.
<message name="IDS_FLAGS_ENABLE_SYNC_FAVICONS_NAME" desc="Title for the flag to enable the favicon sync datatype">
Enable favicon sync.
</message>
<message name="IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION" desc="Description for the flag to enable syncing tab favicons with tab sync">
Enable syncing the favicons of open tabs as part of Open Tab sync.
<message name="IDS_FLAGS_ENABLE_SYNC_FAVICONS_DESCRIPTION" desc="Description for the flag to enable the favicon sync datatype">
Enable syncing the set of recent favicons.
</message>
<message name="IDS_FLAGS_SYNC_KEYSTORE_ENCRYPTION_NAME" desc="Title for the flag to enable sync's keystore encryption options">
Enable sync keystore encryption.

@ -545,11 +545,11 @@ const Experiment kExperiments[] = {
SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
},
{
"sync-tab-favicons",
IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
"enable-sync-favicons",
IDS_FLAGS_ENABLE_SYNC_FAVICONS_NAME,
IDS_FLAGS_ENABLE_SYNC_FAVICONS_DESCRIPTION,
kOsAll,
SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
SINGLE_VALUE_TYPE(switches::kEnableSyncFavicons)
},
{
"sync-keystore-encryption",

@ -958,18 +958,6 @@ void ProfileSyncService::OnExperimentsChanged(
}
// Now enable any non-datatype features.
if (experiments.sync_tab_favicons) {
DVLOG(1) << "Enabling syncing of tab favicons.";
about_flags::SetExperimentEnabled(g_browser_process->local_state(),
"sync-tab-favicons",
true);
#if defined(OS_ANDROID)
// Android does not support about:flags and experiments, so we need to force
// setting the experiments as command line switches.
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSyncTabFavicons);
#endif
}
if (experiments.keystore_encryption) {
about_flags::SetExperimentEnabled(g_browser_process->local_state(),
syncer::kKeystoreEncryptionFlag,
@ -982,6 +970,12 @@ void ProfileSyncService::OnExperimentsChanged(
true);
}
if (experiments.favicon_sync) {
about_flags::SetExperimentEnabled(g_browser_process->local_state(),
syncer::kFaviconSyncFlag,
true);
}
current_experiments_ = experiments;
}

@ -14,25 +14,23 @@ const char kKeystoreEncryptionFlag[] = "sync-keystore-encryption";
const char kAutofillCullingTag[] = "autofill_culling";
const char kFullHistorySyncTag[] = "history_delete_directives";
const char kFullHistorySyncFlag[] = "full-history-sync";
const char kFaviconSyncTag[] = "favicon_sync";
const char kFaviconSyncFlag[] = "enable-sync-favicons";
// A structure to hold the enable status of experimental sync features.
struct Experiments {
Experiments() : sync_tab_favicons(false),
keystore_encryption(false),
Experiments() : keystore_encryption(false),
autofill_culling(false),
full_history_sync(false) {}
full_history_sync(false),
favicon_sync(false) {}
bool Matches(const Experiments& rhs) {
return (sync_tab_favicons == rhs.sync_tab_favicons &&
keystore_encryption == rhs.keystore_encryption &&
return (keystore_encryption == rhs.keystore_encryption &&
autofill_culling == rhs.autofill_culling &&
full_history_sync == rhs.full_history_sync);
full_history_sync == rhs.full_history_sync &&
favicon_sync == rhs.favicon_sync);
}
// Enable syncing of favicons within tab sync (only has an effect if tab sync
// is already enabled). This takes effect on the next restart.
bool sync_tab_favicons;
// Enable keystore encryption logic and the new encryption UI.
bool keystore_encryption;
@ -41,6 +39,9 @@ struct Experiments {
// Enable full history sync (and history delete directives) for this client.
bool full_history_sync;
// Enable the favicons sync datatypes (favicon images and favicon tracking).
bool favicon_sync;
};
} // namespace syncer

@ -1347,10 +1347,6 @@ bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) {
return false;
}
bool found_experiment = false;
if (nigori_node.GetNigoriSpecifics().sync_tab_favicons()) {
experiments->sync_tab_favicons = true;
found_experiment = true;
}
ReadNode keystore_node(&trans);
if (keystore_node.InitByClientTagLookup(
@ -1381,6 +1377,15 @@ bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) {
found_experiment = true;
}
ReadNode favicon_sync_node(&trans);
if (favicon_sync_node.InitByClientTagLookup(
syncer::EXPERIMENTS,
syncer::kFaviconSyncTag) == BaseNode::INIT_OK &&
favicon_sync_node.GetExperimentsSpecifics().favicon_sync().enabled()) {
experiments->favicon_sync = true;
found_experiment = true;
}
return found_experiment;
}

@ -27,6 +27,11 @@ message AutofillCullingFlags {
optional bool enabled = 1;
}
// Whether the favicon sync datatypes are enabled.
message FaviconSyncFlags {
optional bool enabled = 1;
}
// Contains one flag or set of related flags. Each node of the experiments type
// will have a unique_client_tag identifying which flags it contains. By
// convention, the tag name should match the sub-message name.
@ -34,4 +39,5 @@ message ExperimentsSpecifics {
optional KeystoreEncryptionFlags keystore_encryption = 1;
optional HistoryDeleteDirectives history_delete_directives = 2;
optional AutofillCullingFlags autofill_culling = 3;
optional FaviconSyncFlags favicon_sync = 4;
}

@ -105,6 +105,15 @@ base::ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) {
std::string >, \
base::StringValue>(proto.field(), \
MakeStringValue))
#define SET_EXPERIMENT_ENABLED_FIELD(field) \
do { \
if (proto.has_##field() && \
proto.field().has_enabled()) { \
value->Set(#field, \
new base::FundamentalValue( \
proto.field().enabled())); \
} \
} while (0)
#define SET_FIELD(field, fn) \
do { \
@ -208,13 +217,6 @@ base::DictionaryValue* PasswordSpecificsDataToValue(
return value;
}
base::DictionaryValue* KeystoreEncryptionFlagsToValue(
const sync_pb::KeystoreEncryptionFlags& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
SET_BOOL(enabled);
return value;
}
base::DictionaryValue* GlobalIdDirectiveToValue(
const sync_pb::GlobalIdDirective& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
@ -339,7 +341,10 @@ base::DictionaryValue* DictionarySpecificsToValue(
base::DictionaryValue* ExperimentsSpecificsToValue(
const sync_pb::ExperimentsSpecifics& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
SET(keystore_encryption, KeystoreEncryptionFlagsToValue);
SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption);
SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives);
SET_EXPERIMENT_ENABLED_FIELD(autofill_culling);
SET_EXPERIMENT_ENABLED_FIELD(favicon_sync);
return value;
}