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

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

Issue 8785016: Add menu option for disabling app notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix merge conflicts Created 9 years 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
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 6e40003404be398a10ee1bda9a8aa71f89de7bf0..02752d8e100722c357bfbf57cf7b64ba4a522048 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -149,6 +149,12 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension,
value->SetBoolean("is_webstore",
extension->id() == extension_misc::kWebStoreAppId);
+ if (extension->HasAPIPermission(ExtensionAPIPermission::kAppNotifications)) {
+ ExtensionPrefs* prefs = service->extension_prefs();
+ value->SetBoolean("notifications_disabled",
+ prefs->IsAppNotificationDisabled(extension->id()));
+ }
+
if (notification)
value->Set("notification", SerializeNotification(*notification));
@@ -221,6 +227,9 @@ void AppLauncherHandler::RegisterMessages() {
web_ui_->RegisterMessageCallback("closeNotification",
base::Bind(&AppLauncherHandler::HandleNotificationClose,
base::Unretained(this)));
+ web_ui_->RegisterMessageCallback("setNotificationsDisabled",
+ base::Bind(&AppLauncherHandler::HandleSetNotificationsDisabled,
+ base::Unretained(this)));
}
void AppLauncherHandler::Observe(int type,
@@ -238,10 +247,6 @@ void AppLauncherHandler::Observe(int type,
switch (type) {
case chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED: {
- Profile* profile = content::Source<Profile>(source).ptr();
- if (!Profile::FromWebUI(web_ui_)->IsSameProfile(profile))
- return;
-
const std::string& id =
*content::Details<const std::string>(details).ptr();
const AppNotification* notification =
@@ -468,7 +473,7 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
pref_change_registrar_.Add(prefs::kNTPAppPageNames, this);
registrar_.Add(this, chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED,
- content::NotificationService::AllSources());
+ content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -741,6 +746,20 @@ void AppLauncherHandler::HandleNotificationClose(const ListValue* args) {
notification_manager->ClearAll(extension_id);
}
+void AppLauncherHandler::HandleSetNotificationsDisabled(
+ const ListValue* args) {
+ std::string extension_id;
+ bool disabled = false;
+ CHECK(args->GetString(0, &extension_id));
+ CHECK(args->GetBoolean(1, &disabled));
+
+ const Extension* extension = extension_service_->GetExtensionById(
+ extension_id, true);
+ if (!extension)
+ return;
+ extension_service_->SetAppNotificationDisabled(extension_id, disabled);
+}
+
void AppLauncherHandler::OnFaviconForApp(FaviconService::Handle handle,
history::FaviconData data) {
scoped_ptr<AppInstallInfo> install_info(
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698