Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7999)

Unified Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 7685049: ntp4: app install improvements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rbyers suggestions Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698