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

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

Issue 12680004: Remove chrome/ code to handle App Notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts. Created 7 years, 9 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
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 772b4c049fca145c622425f287e9bb03046bc46d..83e24d10199704da5eb312d967902a7148d6800b 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -15,8 +15,6 @@
#include "base/prefs/pref_service.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/extensions/app_notification.h"
-#include "chrome/browser/extensions/app_notification_manager.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -89,23 +87,8 @@ AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service)
AppLauncherHandler::~AppLauncherHandler() {}
-// Serializes |notification| into a new DictionaryValue which the caller then
-// owns.
-static DictionaryValue* SerializeNotification(
- const extensions::AppNotification& notification) {
- DictionaryValue* dictionary = new DictionaryValue();
- dictionary->SetString("title", notification.title());
- dictionary->SetString("body", notification.body());
- if (!notification.link_url().is_empty()) {
- dictionary->SetString("linkUrl", notification.link_url().spec());
- dictionary->SetString("linkText", notification.link_text());
- }
- return dictionary;
-}
-
void AppLauncherHandler::CreateAppInfo(
const Extension* extension,
- const extensions::AppNotification* notification,
ExtensionService* service,
DictionaryValue* value) {
value->Clear();
@@ -151,15 +134,6 @@ void AppLauncherHandler::CreateAppInfo(
value->SetBoolean("is_webstore",
extension->id() == extension_misc::kWebStoreAppId);
- if (extension->HasAPIPermission(
- extensions::APIPermission::kAppNotifications)) {
- value->SetBoolean("notifications_disabled",
- prefs->IsAppNotificationDisabled(extension->id()));
- }
-
- if (notification)
- value->Set("notification", SerializeNotification(*notification));
-
ExtensionSorting* sorting = prefs->extension_sorting();
syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id());
if (!page_ordinal.IsValid()) {
@@ -221,12 +195,6 @@ void AppLauncherHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("recordAppLaunchByURL",
base::Bind(&AppLauncherHandler::HandleRecordAppLaunchByUrl,
base::Unretained(this)));
- 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,
@@ -243,24 +211,6 @@ void AppLauncherHandler::Observe(int type,
return;
switch (type) {
- case chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED: {
- const std::string& id =
- *content::Details<const std::string>(details).ptr();
- const extensions::AppNotification* notification =
- extension_service_->app_notification_manager()->GetLast(id);
- base::StringValue id_value(id);
- if (notification) {
- scoped_ptr<DictionaryValue> notification_value(
- SerializeNotification(*notification));
- web_ui()->CallJavascriptFunction("ntp.appNotificationChanged",
- id_value, *notification_value.get());
- } else {
- web_ui()->CallJavascriptFunction("ntp.appNotificationChanged",
- id_value);
- }
- break;
- }
-
case chrome::NOTIFICATION_EXTENSION_LOADED: {
const Extension* extension =
content::Details<const Extension>(details).ptr();
@@ -312,7 +262,6 @@ void AppLauncherHandler::Observe(int type,
extension_service_->GetExtensionById(*id, false);
DictionaryValue app_info;
CreateAppInfo(extension,
- NULL,
extension_service_,
&app_info);
web_ui()->CallJavascriptFunction("ntp.appMoved", app_info);
@@ -391,13 +340,10 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
}
DictionaryValue* AppLauncherHandler::GetAppInfo(const Extension* extension) {
- extensions::AppNotificationManager* notification_manager =
- extension_service_->app_notification_manager();
DictionaryValue* app_info = new DictionaryValue();
// CreateAppInfo can change the extension prefs.
base::AutoReset<bool> auto_reset(&ignore_changes_, true);
CreateAppInfo(extension,
- notification_manager->GetLast(extension->id()),
extension_service_,
app_info);
return app_info;
@@ -453,8 +399,6 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) {
pref_change_registrar_.Add(ExtensionPrefs::kExtensionsPref, callback);
pref_change_registrar_.Add(prefs::kNtpAppPageNames, callback);
- registrar_.Add(this, chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED,
- content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
@@ -718,36 +662,6 @@ void AppLauncherHandler::HandleRecordAppLaunchByUrl(
RecordAppLaunchByUrl(Profile::FromWebUI(web_ui()), url, bucket);
}
-void AppLauncherHandler::HandleNotificationClose(const ListValue* args) {
- std::string extension_id;
- CHECK(args->GetString(0, &extension_id));
-
- const Extension* extension = extension_service_->GetExtensionById(
- extension_id, true);
- if (!extension)
- return;
-
- UMA_HISTOGRAM_COUNTS("AppNotification.NTPNotificationClosed", 1);
-
- extensions::AppNotificationManager* notification_manager =
- extension_service_->app_notification_manager();
- 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(
scoped_ptr<AppInstallInfo> install_info,
const history::FaviconImageResult& image_result) {
« 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