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

Unified Diff: chrome/browser/extensions/api/notification_getter/notification_getter_api.cc

Issue 356673003: Notification Provider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added notification getter to permission_set_unittest Created 6 years, 6 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/extensions/api/notification_getter/notification_getter_api.cc
diff --git a/chrome/browser/extensions/api/notification_getter/notification_getter_api.cc b/chrome/browser/extensions/api/notification_getter/notification_getter_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9976a28dd6515de1582381daca676aef4cff2ba7
--- /dev/null
+++ b/chrome/browser/extensions/api/notification_getter/notification_getter_api.cc
@@ -0,0 +1,161 @@
+// Copyright (c) 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/extensions/api/notification_getter/notification_getter_api.h"
+
+#include "base/callback.h"
+#include "base/guid.h"
+#include "base/rand_util.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/chrome_version_info.h"
+#include "extensions/browser/event_router.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/features/feature.h"
+#include "ui/base/layout.h"
+#include "url/gurl.h"
+
+namespace extensions {
+
+namespace notification_getter = api::notification_getter;
+
+NotificationGetterEventRouter::NotificationGetterEventRouter(Profile* profile)
+ : profile_(profile) {
+}
+
+NotificationGetterEventRouter::~NotificationGetterEventRouter() {
+}
+
+void NotificationGetterEventRouter::CreateNotificationForTest(
+ const std::string& extension_id,
+ const std::string& sender_id,
+ const std::string& notification_id,
+ const api::notification_getter::NotificationOptions& options) {
+ Create(extension_id, sender_id, notification_id, options);
+}
+
+void NotificationGetterEventRouter::UpdateNotificationForTest(
+ const std::string& extension_id,
+ const std::string& sender_id,
+ const std::string& notification_id,
+ const api::notification_getter::NotificationOptions& options) {
+ Update(extension_id, sender_id, notification_id, options);
+}
+void NotificationGetterEventRouter::CloseNotificationForTest(
+ const std::string& extension_id,
+ const std::string& sender_id,
+ const std::string& notification_id) {
+ Close(extension_id, sender_id, notification_id);
+}
+
+void NotificationGetterEventRouter::Create(
+ const std::string& extension_id,
+ const std::string& sender_id,
+ const std::string& notification_id,
+ const api::notification_getter::NotificationOptions& options) {
+ scoped_ptr<base::ListValue> args =
+ api::notification_getter::OnCreated::Create(
+ sender_id, notification_id, options);
+
+ scoped_ptr<Event> event(
+ new Event(api::notification_getter::OnCreated::kEventName, args.Pass()));
+
+ EventRouter::Get(profile_)
+ ->DispatchEventToExtension(extension_id, event.Pass());
Pete Williamson 2014/06/30 19:03:48 This seems to be sending the OnCreated event back
liyanhou 2014/07/14 17:44:44 It's sending the event to the new notification cen
+}
+
+void NotificationGetterEventRouter::Update(
+ const std::string& extension_id,
+ const std::string& sender_id,
+ const std::string& notification_id,
+ const extensions::api::notification_getter::NotificationOptions& options) {
+ scoped_ptr<base::ListValue> args =
+ api::notification_getter::OnUpdated::Create(
+ sender_id, notification_id, options);
+
+ scoped_ptr<Event> event(
+ new Event(notification_getter::OnUpdated::kEventName, args.Pass()));
+
+ EventRouter::Get(profile_)
+ ->DispatchEventToExtension(extension_id, event.Pass());
+}
+
+void NotificationGetterEventRouter::Close(const std::string& extension_id,
+ const std::string& sender_id,
+ const std::string& notification_id) {
+ scoped_ptr<base::ListValue> args =
+ api::notification_getter::OnClosed::Create(sender_id, notification_id);
+
+ scoped_ptr<Event> event(
+ new Event(notification_getter::OnClosed::kEventName, args.Pass()));
+
+ EventRouter::Get(profile_)
+ ->DispatchEventToExtension(extension_id, event.Pass());
+}
+
+NotificationGetterSendOnCloseFunction::NotificationGetterSendOnCloseFunction() {
+}
+
+NotificationGetterSendOnCloseFunction::
+ ~NotificationGetterSendOnCloseFunction() {
+}
+
+bool NotificationGetterSendOnCloseFunction::RunAsync() {
+ params_ = api::notification_getter::SendOnClose::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params_.get());
+
+ SendResponse(true);
+ return true;
+}
+
+NotificationGetterSendOnClickFunction::NotificationGetterSendOnClickFunction() {
+}
+
+NotificationGetterSendOnClickFunction::
+ ~NotificationGetterSendOnClickFunction() {
+}
+
+bool NotificationGetterSendOnClickFunction::RunAsync() {
+ params_ = api::notification_getter::SendOnClick::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params_.get());
+
+ SendResponse(true);
+ return true;
+}
+
+NotificationGetterSendOnClickButtonFunction::
+ NotificationGetterSendOnClickButtonFunction() {
+}
+
+NotificationGetterSendOnClickButtonFunction::
+ ~NotificationGetterSendOnClickButtonFunction() {
+}
+
+bool NotificationGetterSendOnClickButtonFunction::RunAsync() {
+ params_ = api::notification_getter::SendOnClickButton::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(params_.get());
+
+ SendResponse(true);
+ return true;
+}
+
+NotificationGetterNotifyPermissionLevelChangedFunction::
+ NotificationGetterNotifyPermissionLevelChangedFunction() {
+}
+
+NotificationGetterNotifyPermissionLevelChangedFunction::
+ ~NotificationGetterNotifyPermissionLevelChangedFunction() {
+}
+
+bool NotificationGetterNotifyPermissionLevelChangedFunction::RunAsync() {
+ params_ =
+ api::notification_getter::NotifyPermissionLevelChanged::Params::Create(
+ *args_);
+ EXTENSION_FUNCTION_VALIDATE(params_.get());
+
+ SendResponse(true);
+ return true;
+}
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698