| Index: chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.cc
|
| diff --git a/chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.cc b/chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fc554223b4fef1840086df83414695dfc1c0a811
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/custom_notification_center/custom_notification_center_api.cc
|
| @@ -0,0 +1,167 @@
|
| +// 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/custom_notification_center/custom_notification_center_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 {
|
| +
|
| +CustomNotificationCenterEventRouter::CustomNotificationCenterEventRouter(
|
| + Profile* profile)
|
| + : profile_(profile) {
|
| +}
|
| +
|
| +CustomNotificationCenterEventRouter::~CustomNotificationCenterEventRouter() {
|
| +}
|
| +
|
| +void CustomNotificationCenterEventRouter::CreateNotification(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const api::custom_notification_center::NotificationContent& content) {
|
| + Create(custom_notification_center_id, sender_id, notification_id, content);
|
| +}
|
| +
|
| +void CustomNotificationCenterEventRouter::UpdateNotification(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const api::custom_notification_center::NotificationContent& content) {
|
| + Update(custom_notification_center_id, sender_id, notification_id, content);
|
| +}
|
| +void CustomNotificationCenterEventRouter::ClearNotification(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id) {
|
| + Clear(custom_notification_center_id, sender_id, notification_id);
|
| +}
|
| +
|
| +void CustomNotificationCenterEventRouter::Create(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const api::custom_notification_center::NotificationContent& content) {
|
| + scoped_ptr<base::ListValue> args =
|
| + api::custom_notification_center::OnCreated::Create(
|
| + sender_id, notification_id, content);
|
| +
|
| + scoped_ptr<Event> event(new Event(
|
| + api::custom_notification_center::OnCreated::kEventName, args.Pass()));
|
| +
|
| + EventRouter::Get(profile_)
|
| + ->DispatchEventToExtension(custom_notification_center_id, event.Pass());
|
| +}
|
| +
|
| +void CustomNotificationCenterEventRouter::Update(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id,
|
| + const extensions::api::custom_notification_center::NotificationContent&
|
| + content) {
|
| + scoped_ptr<base::ListValue> args =
|
| + api::custom_notification_center::OnUpdated::Create(
|
| + sender_id, notification_id, content);
|
| +
|
| + scoped_ptr<Event> event(new Event(
|
| + api::custom_notification_center::OnUpdated::kEventName, args.Pass()));
|
| +
|
| + EventRouter::Get(profile_)
|
| + ->DispatchEventToExtension(custom_notification_center_id, event.Pass());
|
| +}
|
| +
|
| +void CustomNotificationCenterEventRouter::Clear(
|
| + const std::string& custom_notification_center_id,
|
| + const std::string& sender_id,
|
| + const std::string& notification_id) {
|
| + scoped_ptr<base::ListValue> args =
|
| + api::custom_notification_center::OnCleared::Create(sender_id,
|
| + notification_id);
|
| +
|
| + scoped_ptr<Event> event(new Event(
|
| + api::custom_notification_center::OnCleared::kEventName, args.Pass()));
|
| +
|
| + EventRouter::Get(profile_)
|
| + ->DispatchEventToExtension(custom_notification_center_id, event.Pass());
|
| +}
|
| +
|
| +CustomNotificationCenterSendOnClearFunction::
|
| + CustomNotificationCenterSendOnClearFunction() {
|
| +}
|
| +
|
| +CustomNotificationCenterSendOnClearFunction::
|
| + ~CustomNotificationCenterSendOnClearFunction() {
|
| +}
|
| +
|
| +bool CustomNotificationCenterSendOnClearFunction::RunAsync() {
|
| + params_ =
|
| + api::custom_notification_center::SendOnClear::Params::Create(*args_);
|
| + EXTENSION_FUNCTION_VALIDATE(params_.get());
|
| +
|
| + SendResponse(true);
|
| + return true;
|
| +}
|
| +
|
| +CustomNotificationCenterSendOnClickFunction::
|
| + CustomNotificationCenterSendOnClickFunction() {
|
| +}
|
| +
|
| +CustomNotificationCenterSendOnClickFunction::
|
| + ~CustomNotificationCenterSendOnClickFunction() {
|
| +}
|
| +
|
| +bool CustomNotificationCenterSendOnClickFunction::RunAsync() {
|
| + params_ =
|
| + api::custom_notification_center::SendOnClick::Params::Create(*args_);
|
| + EXTENSION_FUNCTION_VALIDATE(params_.get());
|
| +
|
| + SendResponse(true);
|
| + return true;
|
| +}
|
| +
|
| +CustomNotificationCenterSendOnButtonClickFunction::
|
| + CustomNotificationCenterSendOnButtonClickFunction() {
|
| +}
|
| +
|
| +CustomNotificationCenterSendOnButtonClickFunction::
|
| + ~CustomNotificationCenterSendOnButtonClickFunction() {
|
| +}
|
| +
|
| +bool CustomNotificationCenterSendOnButtonClickFunction::RunAsync() {
|
| + params_ = api::custom_notification_center::SendOnButtonClick::Params::Create(
|
| + *args_);
|
| + EXTENSION_FUNCTION_VALIDATE(params_.get());
|
| +
|
| + SendResponse(true);
|
| + return true;
|
| +}
|
| +
|
| +CustomNotificationCenterNotifyPermissionLevelChangedFunction::
|
| + CustomNotificationCenterNotifyPermissionLevelChangedFunction() {
|
| +}
|
| +
|
| +CustomNotificationCenterNotifyPermissionLevelChangedFunction::
|
| + ~CustomNotificationCenterNotifyPermissionLevelChangedFunction() {
|
| +}
|
| +
|
| +bool CustomNotificationCenterNotifyPermissionLevelChangedFunction::RunAsync() {
|
| + params_ = api::custom_notification_center::NotifyPermissionLevelChanged::
|
| + Params::Create(*args_);
|
| + EXTENSION_FUNCTION_VALIDATE(params_.get());
|
| +
|
| + SendResponse(true);
|
| + return true;
|
| +}
|
| +} // namespace extensions
|
|
|