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

Unified Diff: trunk/src/chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 15925003: Revert 201932 "Add API function chrome.notifications.getAll" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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: trunk/src/chrome/browser/extensions/api/notifications/notifications_api.cc
===================================================================
--- trunk/src/chrome/browser/extensions/api/notifications/notifications_api.cc (revision 201968)
+++ trunk/src/chrome/browser/extensions/api/notifications/notifications_api.cc (working copy)
@@ -29,23 +29,6 @@
const char kResultKey[] = "result";
-// Given an extension id and another id, returns an id that is unique
-// relative to other extensions.
-std::string CreateScopedIdentifier(const std::string& extension_id,
- const std::string& id) {
- return extension_id + "-" + id;
-}
-
-// Removes the unique internal identifier to send the ID as the
-// extension expects it.
-std::string StripScopeFromIdentifier(const std::string& extension_id,
- const std::string& id) {
- size_t index_of_separator = extension_id.length() + 1;
- DCHECK_LT(index_of_separator, id.length());
-
- return id.substr(index_of_separator);
-}
-
class NotificationsApiDelegate : public NotificationDelegate {
public:
NotificationsApiDelegate(ApiFunction* api_function,
@@ -63,6 +46,13 @@
process_id_ = api_function->render_view_host()->GetProcess()->GetID();
}
+ // Given an extension id and another id, returns an id that is unique
+ // relative to other extensions.
+ static std::string CreateScopedIdentifier(const std::string& extension_id,
+ const std::string& id) {
+ return extension_id + "-" + id;
+ }
+
virtual void Display() OVERRIDE { }
virtual void Error() OVERRIDE {
@@ -145,7 +135,10 @@
// We need to check this explicitly rather than letting
// _permission_features.json enforce it, because we're sharing the
// chrome.notifications permissions namespace with WebKit notifications.
- return GetExtension()->is_platform_app() || GetExtension()->is_extension();
+ if (!(GetExtension()->is_platform_app() || GetExtension()->is_extension()))
+ return false;
+
+ return true;
}
NotificationsApiFunction::NotificationsApiFunction() {
@@ -340,8 +333,9 @@
params_ = api::notifications::Update::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
- if (g_browser_process->notification_ui_manager()->DoesIdExist(
- CreateScopedIdentifier(extension_->id(), params_->notification_id))) {
+ if (g_browser_process->notification_ui_manager()->
+ DoesIdExist(NotificationsApiDelegate::CreateScopedIdentifier(
+ extension_->id(), params_->notification_id))) {
CreateNotification(params_->notification_id, &params_->options);
SetResult(Value::CreateBooleanValue(true));
} else {
@@ -363,8 +357,9 @@
params_ = api::notifications::Clear::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
- bool cancel_result = g_browser_process->notification_ui_manager()->CancelById(
- CreateScopedIdentifier(extension_->id(), params_->notification_id));
+ bool cancel_result = g_browser_process->notification_ui_manager()->
+ CancelById(NotificationsApiDelegate::CreateScopedIdentifier(
+ extension_->id(), params_->notification_id));
SetResult(Value::CreateBooleanValue(cancel_result));
SendResponse(true);
@@ -372,29 +367,4 @@
return true;
}
-NotificationsGetAllFunction::NotificationsGetAllFunction() {}
-
-NotificationsGetAllFunction::~NotificationsGetAllFunction() {}
-
-bool NotificationsGetAllFunction::RunNotificationsApi() {
- NotificationUIManager* notification_ui_manager =
- g_browser_process->notification_ui_manager();
- std::set<std::string> notification_ids =
- notification_ui_manager->GetAllIdsByProfileAndSourceOrigin(
- profile_, extension_->url());
-
- scoped_ptr<DictionaryValue> result(new DictionaryValue());
-
- for (std::set<std::string>::iterator iter = notification_ids.begin();
- iter != notification_ids.end(); iter++) {
- result->SetBooleanWithoutPathExpansion(
- StripScopeFromIdentifier(extension_->id(), *iter), true);
- }
-
- SetResult(result.release());
- SendResponse(true);
-
- return true;
-}
-
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698