From a7c94bc9887ce9ab4afbaa7149b403db81940cac Mon Sep 17 00:00:00 2001 From: "mad@chromium.org" Date: Tue, 26 Mar 2013 21:38:15 +0000 Subject: Add a new App launcher promo to the apps page / NTP. Simple change in chrome/browser/chrome_browser_main.cc TBR=ben@chromium.org BUG=180475 TEST=Make sure the apps promo only show on apps page of the NTP (or chrome://apps) and that it links to webstore (specific page to be added later on the webstore) and that it doesn't come back on a given installation of Chrome once dismissed with the X close button. That dimiss state can be reset with the command line switch --reset-show-apps-promo to help test it. Also, this shouldn't show when the App Launcher is installer... since no apps page should be shown anyway (tested with --show-app-list-shortcut) Review URL: https://chromiumcodereview.appspot.com/12985002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190772 0039d316-1c4b-4281-b951-d872f2087c98 --- apps/apps.gypi | 2 + apps/field_trial_names.cc | 19 +++++++ apps/field_trial_names.h | 18 ++++++ apps/pref_names.cc | 3 + apps/pref_names.h | 1 + apps/prefs.cc | 6 +- chrome/app/generated_resources.grd | 4 ++ chrome/browser/chrome_browser_field_trials.cc | 24 ++++++-- chrome/browser/chrome_browser_field_trials.h | 16 ++++-- chrome/browser/chrome_browser_main.cc | 6 +- .../browser/resources/ntp4/app_launcher_promo.png | 0 chrome/browser/resources/ntp4/apps_page.css | 62 +++++++++++++++++++++ chrome/browser/resources/ntp4/new_tab.html | 11 ++++ chrome/browser/resources/ntp4/new_tab.js | 13 ++++- chrome/browser/resources/ntp4/page_list_view.js | 64 +++++++++++++++++----- .../browser/ui/webui/ntp/app_launcher_handler.cc | 37 +++++++++++-- chrome/browser/ui/webui/ntp/app_launcher_handler.h | 12 +++- chrome/browser/ui/webui/ntp/ntp_resource_cache.cc | 34 ++++++++++-- chrome/browser/ui/webui/ntp/ntp_resource_cache.h | 3 +- 19 files changed, 291 insertions(+), 44 deletions(-) create mode 100644 apps/field_trial_names.cc create mode 100644 apps/field_trial_names.h create mode 100644 chrome/browser/resources/ntp4/app_launcher_promo.png diff --git a/apps/apps.gypi b/apps/apps.gypi index 8760e17..61f42e9 100644 --- a/apps/apps.gypi +++ b/apps/apps.gypi @@ -34,6 +34,8 @@ 'app_shim/app_shim_host_mac.h', 'app_shim/app_shim_host_manager_mac.h', 'app_shim/app_shim_host_manager_mac.mm', + 'field_trial_names.cc', + 'field_trial_names.h', 'pref_names.cc', 'pref_names.h', 'prefs.cc', diff --git a/apps/field_trial_names.cc b/apps/field_trial_names.cc new file mode 100644 index 0000000..9e5cbcf --- /dev/null +++ b/apps/field_trial_names.cc @@ -0,0 +1,19 @@ +// 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 "apps/field_trial_names.h" + +namespace apps { + +// The field trial group name that enables showing the promo. +const char kShowLauncherPromoOnceGroupName[] = "ShowPromoUntilDismissed"; + +// The field trial group name that resets the pref to show the app launcher +// promo on every session startup. +const char kResetShowLauncherPromoPrefGroupName[] = "ResetShowPromoPref"; + +// The name of the field trial that controls showing the app launcher promo. +const char kLauncherPromoTrialName[] = "ShowAppLauncherPromo"; + +} // namespace apps diff --git a/apps/field_trial_names.h b/apps/field_trial_names.h new file mode 100644 index 0000000..568ae43d --- /dev/null +++ b/apps/field_trial_names.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 APPS_FIELD_TRIAL_NAMES_H_ +#define APPS_FIELD_TRIAL_NAMES_H_ + +namespace apps { + +// Alphabetical list of field trial names specific to Apps component. +// Keep alphabetized and document each one in the source file. +extern const char kShowLauncherPromoOnceGroupName[]; +extern const char kResetShowLauncherPromoPrefGroupName[]; +extern const char kLauncherPromoTrialName[]; + +} // namespace apps + +#endif // APPS_FIELD_TRIAL_NAMES_H_ diff --git a/apps/pref_names.cc b/apps/pref_names.cc index d4ac6fa..cb1cf93 100644 --- a/apps/pref_names.cc +++ b/apps/pref_names.cc @@ -21,6 +21,9 @@ const char kAppLaunchForMetroRestart[] = "apps.app_launch_for_metro_restart"; const char kAppLaunchForMetroRestartProfile[] = "apps.app_launch_for_metro_restart_profile"; +// A boolean identifying if we should show the app launcher promo or not. +const char kShowAppLauncherPromo[] = "app_launcher.show_promo"; + } // namespace prefs } // namespace apps diff --git a/apps/pref_names.h b/apps/pref_names.h index db6ad7c..db5d7c2 100644 --- a/apps/pref_names.h +++ b/apps/pref_names.h @@ -13,6 +13,7 @@ namespace prefs { extern const char kAppLauncherIsEnabled[]; extern const char kAppLaunchForMetroRestart[]; extern const char kAppLaunchForMetroRestartProfile[]; +extern const char kShowAppLauncherPromo[]; } // namespace prefs } // namespace apps diff --git a/apps/prefs.cc b/apps/prefs.cc index edaf119..2685860 100644 --- a/apps/prefs.cc +++ b/apps/prefs.cc @@ -20,11 +20,15 @@ void RegisterPrefs(PrefRegistrySimple* registry) { // GetIsAppLauncherEnabled(). registry->RegisterBooleanPref(prefs::kAppLauncherIsEnabled, MaybeIsAppLauncherEnabled()); - #if defined(OS_WIN) registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, ""); registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, ""); #endif + + // Identifies whether we should show the app launcher promo or not. + // Now that a field trial also controls the showing, so the promo won't show + // unless the pref is set AND the field trial is set to a proper group. + registry->RegisterBooleanPref(prefs::kShowAppLauncherPromo, true); } } // namespace apps diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f6769d8..0b631ce 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -11520,6 +11520,10 @@ experiment id: "$5ar1" desc="Title for accessibility of the 'page-switcher-start' or 'page-switcher-end' button when switching between pages which have the same title"> More $1Apps + + Discover the Chrome App Launcher + diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc index 0a0c9a8..3c53c56 100644 --- a/chrome/browser/chrome_browser_field_trials.cc +++ b/chrome/browser/chrome_browser_field_trials.cc @@ -6,8 +6,11 @@ #include +#include "apps/field_trial_names.h" +#include "apps/pref_names.h" #include "base/command_line.h" #include "base/metrics/field_trial.h" +#include "base/prefs/pref_service.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "base/strings/string_number_conversions.h" @@ -26,6 +29,7 @@ #include "chrome/common/chrome_version_info.h" #include "chrome/common/metrics/variations/uniformity_field_trials.h" #include "chrome/common/metrics/variations/variations_util.h" +#include "chrome/common/pref_names.h" #include "net/socket/client_socket_pool_base.h" #include "net/spdy/spdy_session.h" #include "ui/base/layout.h" @@ -56,16 +60,19 @@ ChromeBrowserFieldTrials::ChromeBrowserFieldTrials( ChromeBrowserFieldTrials::~ChromeBrowserFieldTrials() { } -void ChromeBrowserFieldTrials::SetupFieldTrials( - const base::Time& install_time) { +void ChromeBrowserFieldTrials::SetupFieldTrials(PrefService* local_state) { + const base::Time install_time = base::Time::FromTimeT( + local_state->GetInt64(prefs::kInstallDate)); + DCHECK(!install_time.is_null()); chrome_variations::SetupUniformityFieldTrials(install_time); SetUpSimpleCacheFieldTrial(); #if !defined(OS_ANDROID) - SetupDesktopFieldTrials(); + SetupDesktopFieldTrials(local_state); #endif // defined(OS_ANDROID) } -void ChromeBrowserFieldTrials::SetupDesktopFieldTrials() { +void ChromeBrowserFieldTrials::SetupDesktopFieldTrials( + PrefService* local_state) { prerender::ConfigurePrefetchAndPrerender(parsed_command_line_); SpdyFieldTrial(); WarmConnectionFieldTrial(); @@ -80,6 +87,15 @@ void ChromeBrowserFieldTrials::SetupDesktopFieldTrials() { OneClickSigninHelper::InitializeFieldTrial(); #endif InstantiateDynamicTrials(); + SetupAppLauncherFieldTrial(local_state); +} + +void ChromeBrowserFieldTrials::SetupAppLauncherFieldTrial( + PrefService* local_state) { + if (base::FieldTrialList::FindFullName(apps::kLauncherPromoTrialName) == + apps::kResetShowLauncherPromoPrefGroupName) { + local_state->SetBoolean(apps::prefs::kShowAppLauncherPromo, true); + } } // When --use-spdy not set, users will be in A/B test for spdy. diff --git a/chrome/browser/chrome_browser_field_trials.h b/chrome/browser/chrome_browser_field_trials.h index dc92241..bd0cf62 100644 --- a/chrome/browser/chrome_browser_field_trials.h +++ b/chrome/browser/chrome_browser_field_trials.h @@ -10,16 +10,16 @@ #include "base/gtest_prod_util.h" #include "base/time.h" +class PrefService; + class ChromeBrowserFieldTrials { public: explicit ChromeBrowserFieldTrials(const CommandLine& command_line); ~ChromeBrowserFieldTrials(); // Called by the browser main sequence to set up Field Trials for this client. - // |install_time| is the time this browser was installed (or the last time - // prefs was reset). |install_time| is used by trials that are only created - // for new installs of the browser. - void SetupFieldTrials(const base::Time& install_time); + // |local_state| is used to extract properties like install time. + void SetupFieldTrials(PrefService* local_state); private: FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, @@ -30,7 +30,13 @@ class ChromeBrowserFieldTrials { // Sets up common desktop-only field trials. // Add an invocation of your field trial init function to this method, or to // SetupFieldTrials if it is for all platforms. - void SetupDesktopFieldTrials(); + // |local_state| is needed by some other methods called from within this one. + void SetupDesktopFieldTrials(PrefService* local_state); + + // This is not quite a field trial initialization, but it's an initialization + // that depends on a field trial, so why not? :-) + // |local_state| is needed to reset a local pref based on the chosen group. + void SetupAppLauncherFieldTrial(PrefService* local_state); // A/B test for spdy when --use-spdy not set. void SpdyFieldTrial(); diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index d7f2f648..4df00b0 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -680,10 +680,8 @@ void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { if (variations_service) variations_service->CreateTrialsFromSeed(); - const int64 install_date = local_state_->GetInt64(prefs::kInstallDate); - // This must be called after the pref is initialized. - DCHECK(install_date); - browser_field_trials_.SetupFieldTrials(base::Time::FromTimeT(install_date)); + // This must be called after the local state is initialized. + browser_field_trials_.SetupFieldTrials(local_state_); SetupPlatformFieldTrials(); diff --git a/chrome/browser/resources/ntp4/app_launcher_promo.png b/chrome/browser/resources/ntp4/app_launcher_promo.png new file mode 100644 index 0000000..e69de29 diff --git a/chrome/browser/resources/ntp4/apps_page.css b/chrome/browser/resources/ntp4/apps_page.css index dbea2ba..bd2e9cc 100644 --- a/chrome/browser/resources/ntp4/apps_page.css +++ b/chrome/browser/resources/ntp4/apps_page.css @@ -99,3 +99,65 @@ .app .invisible { visibility: hidden; } + +#app-launcher-promo { + background-color: white; + border: 1px solid lightgray; + border-bottom-width: 3px; + border-radius: 2px; + border-top-width: 2px; + bottom: 90px; + font-family: Arial, Helvetica, sans-serif; + height: 120px; + left: 50%; + margin-left: -300px; + position: fixed; + width: 600px; +} + +#app-launcher-promo > .close-button { + position: absolute; + right: 10px; + top: 10px; + width: 14px; +} + +.apps-promo-text { + color: #222; + font-size: 16px; + left: 30px; + line-height: 24px; + position: absolute; + top: 30px; +} + +.apps-promo-learn-more { + background-color: rgb(77, 144, 254); + border: 1px solid rgb(47, 91, 183); + border-radius: 2px; + color: white; + cursor: default; + font-size: 11px; + font-weight: bold; + height: 27px; + left: 30px; + line-height: 27px; + padding: 0 8px; + position: absolute; + text-align: center; + text-decoration: none; + top: 70px; + width: 90px; +} + +.apps-promo-learn-more:hover { + background-image: -webkit-linear-gradient( + top, rgb(77, 144, 254), rgb(53, 122, 232)); + border: 1px solid rgb(47, 91, 183); +} + +#app-launcher-promo > img { + bottom: 0; + position: absolute; + right: 30px; +} diff --git a/chrome/browser/resources/ntp4/new_tab.html b/chrome/browser/resources/ntp4/new_tab.html index e5bb3e3..99f8fa7 100644 --- a/chrome/browser/resources/ntp4/new_tab.html +++ b/chrome/browser/resources/ntp4/new_tab.html @@ -93,6 +93,17 @@ + +