Commit 257a1d1b authored by peter@chromium.org's avatar peter@chromium.org

Allow compiling Android with notifications=1, add stubbed UI manager

This patch makes it possible to compile Android's chrome_shell_apk target
whilst setting notifications=1 in the GYP_DEFINES. It also adds a stubbed
version of the NotificationUIManagerAndroid, which will be responsible
for displaying notifcations (through the Android framework).

Chrome for Android will not be using the new Message Center, because
displaying notifications will be done by the platform directly.

BUG=90795

Review URL: https://codereview.chromium.org/247943003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267041 0039d316-1c4b-4281-b951-d872f2087c98
parent eba5a3dc
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "chrome/browser/content_settings/content_settings_details.h" #include "chrome/browser/content_settings/content_settings_details.h"
#include "chrome/browser/content_settings/content_settings_provider.h" #include "chrome/browser/content_settings/content_settings_provider.h"
#include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/extensions/api/notifications/notifications_api.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/infobars/confirm_infobar_delegate.h" #include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h"
...@@ -41,12 +39,6 @@ ...@@ -41,12 +39,6 @@
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/show_desktop_notification_params.h" #include "content/public/common/show_desktop_notification_params.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/info_map.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "grit/browser_resources.h" #include "grit/browser_resources.h"
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
...@@ -57,6 +49,17 @@ ...@@ -57,6 +49,17 @@
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
#include "ui/message_center/notifier_settings.h" #include "ui/message_center/notifier_settings.h"
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/notifications/notifications_api.h"
#include "chrome/browser/extensions/extension_service.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/info_map.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#endif
using blink::WebTextDirection; using blink::WebTextDirection;
using content::BrowserThread; using content::BrowserThread;
using content::RenderViewHost; using content::RenderViewHost;
...@@ -566,6 +569,7 @@ void DesktopNotificationService::ShowDesktopNotification( ...@@ -566,6 +569,7 @@ void DesktopNotificationService::ShowDesktopNotification(
base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId( base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId(
const GURL& origin, int process_id) { const GURL& origin, int process_id) {
#if defined(ENABLE_EXTENSIONS)
// If the source is an extension, lookup the display name. // If the source is an extension, lookup the display name.
if (origin.SchemeIs(extensions::kExtensionScheme)) { if (origin.SchemeIs(extensions::kExtensionScheme)) {
extensions::InfoMap* extension_info_map = extensions::InfoMap* extension_info_map =
...@@ -583,6 +587,8 @@ base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId( ...@@ -583,6 +587,8 @@ base::string16 DesktopNotificationService::DisplayNameForOriginInProcessId(
} }
} }
} }
#endif
return base::UTF8ToUTF16(origin.host()); return base::UTF8ToUTF16(origin.host());
} }
...@@ -706,6 +712,7 @@ void DesktopNotificationService::Observe( ...@@ -706,6 +712,7 @@ void DesktopNotificationService::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
#if defined(ENABLE_EXTENSIONS)
DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type); DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNINSTALLED, type);
extensions::Extension* extension = extensions::Extension* extension =
...@@ -719,10 +726,12 @@ void DesktopNotificationService::Observe( ...@@ -719,10 +726,12 @@ void DesktopNotificationService::Observe(
return; return;
SetNotifierEnabled(notifier_id, true); SetNotifierEnabled(notifier_id, true);
#endif
} }
void DesktopNotificationService::FirePermissionLevelChangedEvent( void DesktopNotificationService::FirePermissionLevelChangedEvent(
const NotifierId& notifier_id, bool enabled) { const NotifierId& notifier_id, bool enabled) {
#if defined(ENABLE_EXTENSIONS)
DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type); DCHECK_EQ(NotifierId::APPLICATION, notifier_id.type);
extensions::api::notifications::PermissionLevel permission = extensions::api::notifications::PermissionLevel permission =
enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED enabled ? extensions::api::notifications::PERMISSION_LEVEL_GRANTED
...@@ -744,5 +753,5 @@ void DesktopNotificationService::FirePermissionLevelChangedEvent( ...@@ -744,5 +753,5 @@ void DesktopNotificationService::FirePermissionLevelChangedEvent(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
base::Bind(&extensions::InfoMap::SetNotificationsDisabled, base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
extension_info_map, notifier_id.id, !enabled)); extension_info_map, notifier_id.id, !enabled));
#endif
} }
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/notification_ui_manager_android.h"
#include "base/logging.h"
// static
NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) {
return new NotificationUIManagerAndroid();
}
NotificationUIManagerAndroid::NotificationUIManagerAndroid() {
}
NotificationUIManagerAndroid::~NotificationUIManagerAndroid() {
}
void NotificationUIManagerAndroid::Add(const Notification& notification,
Profile* profile) {
// TODO(peter): Implement the NotificationUIManagerAndroid class.
NOTIMPLEMENTED();
}
bool NotificationUIManagerAndroid::Update(const Notification& notification,
Profile* profile) {
return false;
}
const Notification* NotificationUIManagerAndroid::FindById(
const std::string& notification_id) const {
return 0;
}
bool NotificationUIManagerAndroid::CancelById(
const std::string& notification_id) {
return false;
}
std::set<std::string>
NotificationUIManagerAndroid::GetAllIdsByProfileAndSourceOrigin(
Profile* profile,
const GURL& source) {
return std::set<std::string>();
}
bool NotificationUIManagerAndroid::CancelAllBySourceOrigin(
const GURL& source_origin) {
return false;
}
bool NotificationUIManagerAndroid::CancelAllByProfile(Profile* profile) {
return false;
}
void NotificationUIManagerAndroid::CancelAll() {
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
#include "chrome/browser/notifications/notification_ui_manager.h"
// Implementation of the Notification UI Manager for Android, which defers to
// the Android framework for displaying notifications.
class NotificationUIManagerAndroid : public NotificationUIManager {
public:
NotificationUIManagerAndroid();
virtual ~NotificationUIManagerAndroid();
// NotificationUIManager implementation;
virtual void Add(const Notification& notification, Profile* profile) OVERRIDE;
virtual bool Update(const Notification& notification,
Profile* profile) OVERRIDE;
virtual const Notification* FindById(
const std::string& notification_id) const OVERRIDE;
virtual bool CancelById(const std::string& notification_id) OVERRIDE;
virtual std::set<std::string> GetAllIdsByProfileAndSourceOrigin(
Profile* profile,
const GURL& source) OVERRIDE;
virtual bool CancelAllBySourceOrigin(const GURL& source_origin) OVERRIDE;
virtual bool CancelAllByProfile(Profile* profile) OVERRIDE;
virtual void CancelAll() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerAndroid);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_ANDROID_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
......
...@@ -259,7 +259,8 @@ void RegisterLocalState(PrefRegistrySimple* registry) { ...@@ -259,7 +259,8 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
policy::PolicyStatisticsCollector::RegisterPrefs(registry); policy::PolicyStatisticsCollector::RegisterPrefs(registry);
#endif #endif
#if defined(ENABLE_NOTIFICATIONS) #if defined(ENABLE_NOTIFICATIONS) && !defined(OS_ANDROID)
// Android does not use the message center for notifications.
MessageCenterNotificationManager::RegisterPrefs(registry); MessageCenterNotificationManager::RegisterPrefs(registry);
#endif #endif
......
...@@ -1374,8 +1374,10 @@ ...@@ -1374,8 +1374,10 @@
'browser/notifications/notification_object_proxy.h', 'browser/notifications/notification_object_proxy.h',
'browser/notifications/notification_system_observer.cc', 'browser/notifications/notification_system_observer.cc',
'browser/notifications/notification_system_observer.h', 'browser/notifications/notification_system_observer.h',
'browser/notifications/notification_ui_manager.cc',
'browser/notifications/notification_ui_manager.h', 'browser/notifications/notification_ui_manager.h',
'browser/notifications/notification_ui_manager_android.cc',
'browser/notifications/notification_ui_manager_android.h',
'browser/notifications/notification_ui_manager_desktop.cc',
'browser/notifications/sync_notifier/chrome_notifier_delegate.cc', 'browser/notifications/sync_notifier/chrome_notifier_delegate.cc',
'browser/notifications/sync_notifier/chrome_notifier_delegate.h', 'browser/notifications/sync_notifier/chrome_notifier_delegate.h',
'browser/notifications/sync_notifier/chrome_notifier_service.cc', 'browser/notifications/sync_notifier/chrome_notifier_service.cc',
...@@ -3229,6 +3231,10 @@ ...@@ -3229,6 +3231,10 @@
'browser/lifetime/application_lifetime_stub.cc', 'browser/lifetime/application_lifetime_stub.cc',
'browser/lifetime/browser_close_manager.cc', 'browser/lifetime/browser_close_manager.cc',
'browser/net/predictor_tab_helper.cc', 'browser/net/predictor_tab_helper.cc',
'browser/notifications/message_center_notification_manager.cc',
'browser/notifications/message_center_settings_controller.cc',
'browser/notifications/message_center_stats_collector.cc',
'browser/notifications/notification_ui_manager_desktop.cc',
'browser/parsers/metadata_parser_jpeg.cc', 'browser/parsers/metadata_parser_jpeg.cc',
'browser/parsers/metadata_parser_jpeg_factory.cc', 'browser/parsers/metadata_parser_jpeg_factory.cc',
'browser/parsers/metadata_parser_manager.cc', 'browser/parsers/metadata_parser_manager.cc',
...@@ -3273,6 +3279,7 @@ ...@@ -3273,6 +3279,7 @@
['exclude', '^browser/importer/'], ['exclude', '^browser/importer/'],
['exclude', '^browser/media_galleries/'], ['exclude', '^browser/media_galleries/'],
['exclude', '^browser/net/firefox_*'], ['exclude', '^browser/net/firefox_*'],
['exclude', '^browser/notifications/sync_notifier/'],
['exclude', '^browser/profile_resetter/'], ['exclude', '^browser/profile_resetter/'],
['exclude', '^browser/service/'], ['exclude', '^browser/service/'],
['exclude', '^browser/sync/glue/app_'], ['exclude', '^browser/sync/glue/app_'],
......
...@@ -132,7 +132,9 @@ ...@@ -132,7 +132,9 @@
'views/message_popup_bubble.h', 'views/message_popup_bubble.h',
], ],
}], }],
['notifications==0', { # Android and iOS. # iOS disables notifications altogether, Android implements its own
# notification UI manager instead of deferring to the message center.
['notifications==0 or OS=="android"', {
'sources/': [ 'sources/': [
# Exclude everything except dummy impl. # Exclude everything except dummy impl.
['exclude', '\\.(cc|mm)$'], ['exclude', '\\.(cc|mm)$'],
...@@ -142,6 +144,14 @@ ...@@ -142,6 +144,14 @@
}, { # notifications==1 }, { # notifications==1
'sources!': [ 'dummy_message_center.cc' ], 'sources!': [ 'dummy_message_center.cc' ],
}], }],
# Include a minimal set of files required for notifications on Android.
['OS=="android"', {
'sources/': [
['include', '^notification\\.cc$'],
['include', '^notification_delegate\\.cc$'],
['include', '^notifier_settings\\.cc$'],
],
}],
], ],
}, # target_name: message_center }, # target_name: message_center
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment