summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui
diff options
context:
space:
mode:
authorjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 16:03:38 +0000
committerjstritar@chromium.org <jstritar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 16:03:38 +0000
commit18cc5a578b6bc5eca8854cf6da68ff9878975d8b (patch)
treefaba06827e3621ca1f915c7442452ff6b4b94c92 /chrome/browser/ui/webui
parentb5d20c2e5f1ccf983bc49259b553f3acd9d1c18a (diff)
downloadchromium_src-18cc5a578b6bc5eca8854cf6da68ff9878975d8b.zip
chromium_src-18cc5a578b6bc5eca8854cf6da68ff9878975d8b.tar.gz
chromium_src-18cc5a578b6bc5eca8854cf6da68ff9878975d8b.tar.bz2
Update the web store promo to be clearer and configurable at run-time.
The promo now behaves like this: a) Promo is fetched 5 seconds after first launch. b) Promo is shown whenever no apps are installed, or if only default apps are installed (from old Chrome versions). c) Clicking "hide this" puts the apps section into menu mode. d) Switching locales will fetch a new promo in that locale. e) We no longer install default apps, but they'll expire and be uninstalled the same as before. BUG=78358 TEST=PromoResourceServiceTest, ExtensionAppsPromo Review URL: http://codereview.chromium.org/6825052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui')
-rw-r--r--chrome/browser/ui/webui/app_launcher_handler.cc68
-rw-r--r--chrome/browser/ui/webui/app_launcher_handler.h6
-rw-r--r--chrome/browser/ui/webui/ntp_resource_cache.cc10
3 files changed, 50 insertions, 34 deletions
diff --git a/chrome/browser/ui/webui/app_launcher_handler.cc b/chrome/browser/ui/webui/app_launcher_handler.cc
index b71e113..67ee56c 100644
--- a/chrome/browser/ui/webui/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/app_launcher_handler.cc
@@ -13,7 +13,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/extensions/default_apps.h"
+#include "chrome/browser/extensions/apps_promo.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/platform_util.h"
@@ -145,7 +145,7 @@ bool AppLauncherHandler::HandlePing(Profile* profile, const std::string& path) {
// promo if its still displayed.
if (is_promo_active) {
DCHECK(profile->GetExtensionService());
- profile->GetExtensionService()->default_apps()->SetPromoHidden();
+ profile->GetExtensionService()->apps_promo()->ExpireDefaultApps();
}
if (is_web_store_ping) {
@@ -180,6 +180,8 @@ void AppLauncherHandler::RegisterMessages() {
NewCallback(this, &AppLauncherHandler::HandleReorderApps));
web_ui_->RegisterMessageCallback("setPageIndex",
NewCallback(this, &AppLauncherHandler::HandleSetPageIndex));
+ web_ui_->RegisterMessageCallback("promoSeen",
+ NewCallback(this, &AppLauncherHandler::HandlePromoSeen));
}
void AppLauncherHandler::Observe(NotificationType type,
@@ -192,6 +194,9 @@ void AppLauncherHandler::Observe(NotificationType type,
case NotificationType::EXTENSION_LOADED:
case NotificationType::EXTENSION_UNLOADED:
case NotificationType::EXTENSION_LAUNCHER_REORDERED:
+ // The promo may not load until a couple seconds after the first NTP view,
+ // so we listen for the load notification and notify the NTP when ready.
+ case NotificationType::WEB_STORE_PROMO_LOADED:
if (web_ui_->tab_contents())
HandleGetApps(NULL);
break;
@@ -248,10 +253,17 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
dictionary->SetBoolean(
"showLauncher",
- extensions_service_->default_apps()->ShouldShowAppLauncher(
+ extensions_service_->apps_promo()->ShouldShowAppLauncher(
extensions_service_->GetAppIds()));
}
+void AppLauncherHandler::FillPromoDictionary(DictionaryValue* dictionary) {
+ dictionary->SetString("promoHeader", AppsPromo::GetPromoHeaderText());
+ dictionary->SetString("promoButton", AppsPromo::GetPromoButtonText());
+ dictionary->SetString("promoLink", AppsPromo::GetPromoLink().spec());
+ dictionary->SetString("promoExpire", AppsPromo::GetPromoExpireText());
+}
+
void AppLauncherHandler::HandleGetApps(const ListValue* args) {
DictionaryValue dictionary;
@@ -263,24 +275,30 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
// expired.
// b) Conceptually, it doesn't really make sense to count a
// prefchange-triggered refresh as a promo 'view'.
- DefaultApps* default_apps = extensions_service_->default_apps();
- bool promo_just_expired = false;
- if (default_apps->ShouldShowPromo(extensions_service_->GetAppIds(),
- &promo_just_expired)) {
+ AppsPromo* apps_promo = extensions_service_->apps_promo();
+ PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
+ bool apps_promo_just_expired = false;
+ if (apps_promo->ShouldShowPromo(extensions_service_->GetAppIds(),
+ &apps_promo_just_expired)) {
+ // Maximize the apps section on the first promo view.
+ apps_promo->MaximizeAppsIfFirstView();
dictionary.SetBoolean("showPromo", true);
+ FillPromoDictionary(&dictionary);
promo_active_ = true;
} else {
- if (promo_just_expired) {
- ignore_changes_ = true;
- UninstallDefaultApps();
- ignore_changes_ = false;
- ShownSectionsHandler::SetShownSection(web_ui_->GetProfile()->GetPrefs(),
- THUMB);
- }
dictionary.SetBoolean("showPromo", false);
promo_active_ = false;
}
+ // If the default apps have just expired (user viewed them too many times with
+ // no interaction), then we uninstall them and focus the recent sites section.
+ if (apps_promo_just_expired) {
+ ignore_changes_ = true;
+ UninstallDefaultApps();
+ ignore_changes_ = false;
+ ShownSectionsHandler::SetShownSection(prefs, THUMB);
+ }
+
FillAppDictionary(&dictionary);
web_ui_->CallJavascriptFunction("getAppsCallback", dictionary);
@@ -293,6 +311,8 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
NotificationService::AllSources());
registrar_.Add(this, NotificationType::EXTENSION_LAUNCHER_REORDERED,
NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::WEB_STORE_PROMO_LOADED,
+ NotificationService::AllSources());
}
if (pref_change_registrar_.IsEmpty()) {
pref_change_registrar_.Init(
@@ -346,7 +366,7 @@ void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
if (extension_id != extension_misc::kWebStoreAppId) {
RecordAppLaunchByID(promo_active_, launch_bucket);
- extensions_service_->default_apps()->SetPromoHidden();
+ extensions_service_->apps_promo()->ExpireDefaultApps();
}
if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) {
@@ -420,15 +440,9 @@ void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
// If the user has intentionally hidden the promotion, we'll uninstall all the
// default apps (we know the user hasn't installed any apps on their own at
// this point, or the promotion wouldn't have been shown).
- UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
- extension_misc::PROMO_CLOSE,
- extension_misc::PROMO_BUCKET_BOUNDARY);
-
- ShownSectionsHandler::SetShownSection(web_ui_->GetProfile()->GetPrefs(),
- THUMB);
ignore_changes_ = true;
UninstallDefaultApps();
- extensions_service_->default_apps()->SetPromoHidden();
+ extensions_service_->apps_promo()->HidePromo();
ignore_changes_ = false;
HandleGetApps(NULL);
}
@@ -480,6 +494,12 @@ void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) {
static_cast<int>(page_index));
}
+void AppLauncherHandler::HandlePromoSeen(const ListValue* args) {
+ UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppsPromoHistogram,
+ extension_misc::PROMO_SEEN,
+ extension_misc::PROMO_BUCKET_BOUNDARY);
+}
+
// static
void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) {
UMA_HISTOGRAM_ENUMERATION(extension_misc::kAppLaunchHistogram,
@@ -612,8 +632,8 @@ ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() {
}
void AppLauncherHandler::UninstallDefaultApps() {
- DefaultApps* default_apps = extensions_service_->default_apps();
- const ExtensionIdSet& app_ids = default_apps->default_apps();
+ AppsPromo* apps_promo = extensions_service_->apps_promo();
+ const ExtensionIdSet& app_ids = apps_promo->old_default_apps();
for (ExtensionIdSet::const_iterator iter = app_ids.begin();
iter != app_ids.end(); ++iter) {
if (extensions_service_->GetExtensionById(*iter, true))
diff --git a/chrome/browser/ui/webui/app_launcher_handler.h b/chrome/browser/ui/webui/app_launcher_handler.h
index f25b555..2d0e328 100644
--- a/chrome/browser/ui/webui/app_launcher_handler.h
+++ b/chrome/browser/ui/webui/app_launcher_handler.h
@@ -55,6 +55,9 @@ class AppLauncherHandler : public WebUIMessageHandler,
// Populate the given dictionary with all installed app info.
void FillAppDictionary(DictionaryValue* value);
+ // Populate the given dictionary with the web store promo content.
+ void FillPromoDictionary(DictionaryValue* value);
+
// Callback for the "getApps" message.
void HandleGetApps(const ListValue* args);
@@ -79,6 +82,9 @@ class AppLauncherHandler : public WebUIMessageHandler,
// Callback for the "setPageIndex" message.
void HandleSetPageIndex(const ListValue* args);
+ // Callback for the "promoSeen" message.
+ void HandlePromoSeen(const ListValue* args);
+
private:
// Records a web store launch in the appropriate histograms. |promo_active|
// specifies if the web store promotion was active.
diff --git a/chrome/browser/ui/webui/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp_resource_cache.cc
index d93acb1..b3910ed 100644
--- a/chrome/browser/ui/webui/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp_resource_cache.cc
@@ -301,8 +301,6 @@ void NTPResourceCache::CreateNewTabHTML() {
l10n_util::GetStringUTF16(IDS_NEW_TAB_SHOW_HIDE_LIST_TOOLTIP));
localized_strings.SetString("pagedisplaytooltip",
l10n_util::GetStringUTF16(IDS_NEW_TAB_PAGE_DISPLAY_TOOLTIP));
- localized_strings.SetString("firstrunnotification",
- l10n_util::GetStringUTF16(IDS_NEW_TAB_FIRST_RUN_NOTIFICATION));
localized_strings.SetString("closefirstrunnotification",
l10n_util::GetStringUTF16(IDS_NEW_TAB_CLOSE_FIRST_RUN_NOTIFICATION));
localized_strings.SetString("close", l10n_util::GetStringUTF16(IDS_CLOSE));
@@ -334,14 +332,6 @@ void NTPResourceCache::CreateNewTabHTML() {
l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE));
localized_strings.SetString("web_store_url",
GetUrlWithLang(GURL(Extension::ChromeStoreLaunchURL())));
- localized_strings.SetString("appspromohide",
- l10n_util::GetStringUTF16(IDS_APPS_PROMO_HIDE));
- localized_strings.SetString("appspromoheader",
- l10n_util::GetStringUTF16(IDS_APPS_PROMO_HEADER));
- localized_strings.SetString("appspromotext1",
- l10n_util::GetStringUTF16(IDS_APPS_PROMO_TEXT_1));
- localized_strings.SetString("appspromotext2",
- l10n_util::GetStringUTF16(IDS_APPS_PROMO_TEXT_2));
localized_strings.SetString("syncpromotext",
l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL));
#if defined(OS_CHROMEOS)