| Index: chrome/browser/ui/webui/ntp/app_launcher_handler.cc
|
| diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
|
| index 53c68cf8f26dfb7e8275ee04e5dd6694acd457dc..8db4a2d5913b31828e82e5f9eaff716e45cb630b 100644
|
| --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
|
| +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
|
| @@ -74,7 +74,8 @@ extension_misc::AppLaunchBucket ParseLaunchSource(
|
| AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service)
|
| : extension_service_(extension_service),
|
| promo_active_(false),
|
| - ignore_changes_(false) {
|
| + ignore_changes_(false),
|
| + attempted_bookmark_app_install_(false) {
|
| }
|
|
|
| AppLauncherHandler::~AppLauncherHandler() {}
|
| @@ -260,27 +261,42 @@ void AppLauncherHandler::Observe(int type,
|
| web_ui_->CallJavascriptFunction("appNotificationChanged", args);
|
| break;
|
| }
|
| - case chrome::NOTIFICATION_EXTENSION_LOADED:
|
| + case chrome::NOTIFICATION_EXTENSION_LOADED: {
|
| + const Extension* extension = Details<const Extension>(details).ptr();
|
| + if (!extension->is_app())
|
| + return;
|
| +
|
| + if (!NewTabUI::NTP4Enabled()) {
|
| + HandleGetApps(NULL);
|
| + break;
|
| + }
|
| +
|
| + scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
|
| + if (app_info.get()) {
|
| + ExtensionPrefs* prefs = extension_service_->extension_prefs();
|
| + scoped_ptr<base::FundamentalValue> highlight(Value::CreateBooleanValue(
|
| + prefs->IsFromBookmark(extension->id()) &&
|
| + attempted_bookmark_app_install_));
|
| + attempted_bookmark_app_install_ = false;
|
| + web_ui_->CallJavascriptFunction("ntp4.appAdded", *app_info, *highlight);
|
| + }
|
| +
|
| + break;
|
| + }
|
| case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
|
| const Extension* extension =
|
| - type == chrome::NOTIFICATION_EXTENSION_LOADED ?
|
| - Details<const Extension>(details).ptr() :
|
| - Details<UnloadedExtensionInfo>(details)->extension;
|
| + Details<UnloadedExtensionInfo>(details)->extension;
|
| if (!extension->is_app())
|
| - break;
|
| + return;
|
|
|
| - if (NewTabUI::NTP4Enabled()) {
|
| - scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
|
| - if (app_info.get()) {
|
| - std::string function =
|
| - type == chrome::NOTIFICATION_EXTENSION_LOADED ?
|
| - "ntp4.appAdded" : "ntp4.appRemoved";
|
| - web_ui_->CallJavascriptFunction(function, *app_info);
|
| - }
|
| - } else if (web_ui_->tab_contents()) {
|
| + if (!NewTabUI::NTP4Enabled()) {
|
| HandleGetApps(NULL);
|
| + break;
|
| }
|
|
|
| + scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
|
| + if (app_info.get())
|
| + web_ui_->CallJavascriptFunction("ntp4.appRemoved", *app_info);
|
| break;
|
| }
|
| case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED:
|
| @@ -306,6 +322,10 @@ void AppLauncherHandler::Observe(int type,
|
| }
|
| break;
|
| }
|
| + case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: {
|
| + attempted_bookmark_app_install_ = false;
|
| + break;
|
| + }
|
| default:
|
| NOTREACHED();
|
| }
|
| @@ -446,6 +466,8 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
|
| NotificationService::AllSources());
|
| registrar_.Add(this, chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED,
|
| NotificationService::AllSources());
|
| + registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
|
| + NotificationService::AllSources());
|
| }
|
| if (pref_change_registrar_.IsEmpty()) {
|
| pref_change_registrar_.Init(
|
| @@ -757,6 +779,7 @@ void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle,
|
| extension_service_->MakeCrxInstaller(NULL));
|
| installer->set_page_index(install_info->page_index);
|
| installer->InstallWebApp(*web_app);
|
| + attempted_bookmark_app_install_ = true;
|
| }
|
|
|
| // static
|
|
|