diff options
author | tedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-27 00:20:22 +0000 |
---|---|---|
committer | tedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-27 00:20:22 +0000 |
commit | 5e3c7c876e3d69ad89e32a6c89a8e20383829c3a (patch) | |
tree | 86fe08b7822e3a7c53cb1fa6fe8f9e82fdf2b822 | |
parent | 1b5826c62d1112bbf6d4a56a801e68dcf7af485e (diff) | |
download | chromium_src-5e3c7c876e3d69ad89e32a6c89a8e20383829c3a.zip chromium_src-5e3c7c876e3d69ad89e32a6c89a8e20383829c3a.tar.gz chromium_src-5e3c7c876e3d69ad89e32a6c89a8e20383829c3a.tar.bz2 |
Merge 212950 "Add an experiment for showing the new tab button i..."
> Add an experiment for showing the new tab button in the mobile toolbar.
>
> Creates a utility class to access field trial information in Java.
>
> BUG=226870
>
> Review URL: https://chromiumcodereview.appspot.com/18938003
TBR=tedchoc@chromium.org
Review URL: https://codereview.chromium.org/20784003
git-svn-id: svn://svn.chromium.org/chrome/branches/1547/src@214007 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java | 24 | ||||
-rw-r--r-- | chrome/browser/android/chrome_jni_registrar.cc | 2 | ||||
-rw-r--r-- | chrome/browser/android/field_trial_helper.cc | 33 | ||||
-rw-r--r-- | chrome/browser/android/field_trial_helper.h | 18 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_field_trials_mobile.cc | 44 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 |
6 files changed, 124 insertions, 0 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java new file mode 100644 index 0000000..fbacd26 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java @@ -0,0 +1,24 @@ +// Copyright 2013 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. + +package org.chromium.chrome.browser; + +/** + * Helper to get field trial information. + */ +public class FieldTrialHelper { + + private FieldTrialHelper() {} + + /** + * @param trialName The name of the trial to get the group for. + * @return The group name chosen for the named trial, or the empty string if the trial does + * not exist. + */ + public static String getFieldTrialFullName(String trialName) { + return nativeGetFieldTrialFullName(trialName); + } + + private static native String nativeGetFieldTrialFullName(String trialName); +} diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc index 7bd9e40..a573c58 100644 --- a/chrome/browser/android/chrome_jni_registrar.cc +++ b/chrome/browser/android/chrome_jni_registrar.cc @@ -10,6 +10,7 @@ #include "chrome/browser/android/chrome_web_contents_delegate_android.h" #include "chrome/browser/android/content_view_util.h" #include "chrome/browser/android/dev_tools_server.h" +#include "chrome/browser/android/field_trial_helper.h" #include "chrome/browser/android/intent_helper.h" #include "chrome/browser/android/provider/chrome_browser_provider.h" #include "chrome/browser/android/tab_android.h" @@ -59,6 +60,7 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = { RegisterChromeWebContentsDelegateAndroid }, { "ContentViewUtil", RegisterContentViewUtil }, { "DevToolsServer", RegisterDevToolsServer }, + { "FieldTrialHelper", RegisterFieldTrialHelper }, { "IntentHelper", RegisterIntentHelper }, { "JavascriptAppModalDialog", JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog }, diff --git a/chrome/browser/android/field_trial_helper.cc b/chrome/browser/android/field_trial_helper.cc new file mode 100644 index 0000000..b3be6d2 --- /dev/null +++ b/chrome/browser/android/field_trial_helper.cc @@ -0,0 +1,33 @@ +// Copyright 2013 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/android/field_trial_helper.h" + +#include <jni.h> + +#include "base/android/jni_string.h" +#include "base/metrics/field_trial.h" +#include "jni/FieldTrialHelper_jni.h" + +using base::android::ConvertJavaStringToUTF8; +using base::android::ConvertUTF8ToJavaString; + +static jstring GetFieldTrialFullName(JNIEnv* env, + jclass clazz, + jstring jtrial_name) { + std::string trial_name(ConvertJavaStringToUTF8(env, jtrial_name)); + return ConvertUTF8ToJavaString( + env, + base::FieldTrialList::FindFullName(trial_name)).Release(); +} + +namespace chrome { +namespace android { + +bool RegisterFieldTrialHelper(JNIEnv* env) { + return RegisterNativesImpl(env); +} + +} // namespace android +} // namespace chrome diff --git a/chrome/browser/android/field_trial_helper.h b/chrome/browser/android/field_trial_helper.h new file mode 100644 index 0000000..6f92ac0 --- /dev/null +++ b/chrome/browser/android/field_trial_helper.h @@ -0,0 +1,18 @@ +// Copyright 2013 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. + +#ifndef CHROME_BROWSER_ANDROID_FIELD_TRIAL_HELPER_H_ +#define CHROME_BROWSER_ANDROID_FIELD_TRIAL_HELPER_H_ + +#include <jni.h> + +namespace chrome { +namespace android { + +bool RegisterFieldTrialHelper(JNIEnv* env); + +} // namespace android +} // namespace chrome + +#endif // CHROME_BROWSER_ANDROID_FIELD_TRIAL_HELPER_H_ diff --git a/chrome/browser/chrome_browser_field_trials_mobile.cc b/chrome/browser/chrome_browser_field_trials_mobile.cc index 7fb1896..5e17ca7 100644 --- a/chrome/browser/chrome_browser_field_trials_mobile.cc +++ b/chrome/browser/chrome_browser_field_trials_mobile.cc @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/metrics/field_trial.h" #include "base/prefs/pref_service.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" namespace chrome { @@ -51,12 +52,55 @@ void DataCompressionProxyFieldTrial() { << ". Selected group id: " << v; } +void NewTabButtonInToolbarFieldTrial(const CommandLine& parsed_command_line) { + // Do not enable this field trials for tablet devices. + if (parsed_command_line.HasSwitch(switches::kTabletUI)) + return; + + const char kPhoneNewTabToolbarButtonFieldTrialName[] = + "PhoneNewTabToolbarButton"; + const base::FieldTrial::Probability kPhoneNewTabToolbarButtonDivisor = 100; + + // 50/100 = 50% for Non-Stable users. + // 0/100 = 0% for Stable users. + const base::FieldTrial::Probability kPhoneNewTabToolbarButtonNonStable = 50; + const base::FieldTrial::Probability kPhoneNewTabToolbarButtonStable = 0; + const char kEnabled[] = "Enabled"; + const char kDisabled[] = "Disabled"; + + // Find out if this is a stable channel. + const bool kIsStableChannel = + chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE; + + // Experiment enabled until Jan 1, 2015. By default, disabled. + scoped_refptr<base::FieldTrial> trial( + base::FieldTrialList::FactoryGetFieldTrial( + kPhoneNewTabToolbarButtonFieldTrialName, + kPhoneNewTabToolbarButtonDivisor, + kDisabled, 2015, 1, 1, NULL)); + + // We want our trial results to be persistent. + trial->UseOneTimeRandomization(); + const int kEnabledGroup = trial->AppendGroup( + kEnabled, + kIsStableChannel ? + kPhoneNewTabToolbarButtonStable : kPhoneNewTabToolbarButtonNonStable); + + const int v = trial->group(); + VLOG(1) << "Phone NewTab toolbar button enabled group id: " << kEnabledGroup + << ". Selected group id: " << v; +} + } // namespace void SetupMobileFieldTrials(const CommandLine& parsed_command_line, const base::Time& install_time, PrefService* local_state) { DataCompressionProxyFieldTrial(); + +#if defined(OS_ANDROID) + NewTabButtonInToolbarFieldTrial(parsed_command_line); +#endif } } // namespace chrome diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index e0d5a7c..fda4e7f 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -96,6 +96,8 @@ 'browser/android/crash_dump_manager.h', 'browser/android/dev_tools_server.cc', 'browser/android/dev_tools_server.h', + 'browser/android/field_trial_helper.cc', + 'browser/android/field_trial_helper.h', 'browser/android/google_location_settings_helper.h', 'browser/android/infobar_stubs.cc', 'browser/android/intent_helper.cc', @@ -3287,6 +3289,7 @@ 'android/java/src/org/chromium/chrome/browser/ContentViewUtil.java', 'android/java/src/org/chromium/chrome/browser/DevToolsServer.java', 'android/java/src/org/chromium/chrome/browser/database/SQLiteCursor.java', + 'android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java', 'android/java/src/org/chromium/chrome/browser/IntentHelper.java', 'android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java', 'android/java/src/org/chromium/chrome/browser/NavigationPopup.java', |