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

Unified Diff: chrome/browser/extensions/api/app/app_api.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
« no previous file with comments | « chrome/browser/extensions/api/app/app_api.h ('k') | chrome/browser/extensions/api/app/app_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/app/app_api.cc
diff --git a/chrome/browser/extensions/api/app/app_api.cc b/chrome/browser/extensions/api/app/app_api.cc
deleted file mode 100644
index 3c0a584001a30abfd4848bc19a1f552fc767f3cf..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/api/app/app_api.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2012 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/app/app_api.h"
-
-#include "base/time.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/app_notification_manager.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "googleurl/src/gurl.h"
-
-namespace {
-
-const char kBodyTextKey[] = "bodyText";
-const char kExtensionIdKey[] = "extensionId";
-const char kLinkTextKey[] = "linkText";
-const char kLinkUrlKey[] = "linkUrl";
-const char kTitleKey[] = "title";
-
-const char kInvalidExtensionIdError[] =
- "Invalid extension id";
-const char kMissingLinkTextError[] =
- "You must specify linkText if you use linkUrl";
-
-} // anonymous namespace
-
-namespace extensions {
-
-bool AppNotifyFunction::RunImpl() {
- if (!include_incognito() && profile_->IsOffTheRecord()) {
- error_ = extension_misc::kAppNotificationsIncognitoError;
- return false;
- }
-
- DictionaryValue* details;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
- EXTENSION_FUNCTION_VALIDATE(details != NULL);
-
- // TODO(asargent) remove this before the API leaves experimental.
- std::string id = extension_id();
- if (details->HasKey(kExtensionIdKey)) {
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id));
- if (!extensions::ExtensionSystem::Get(profile())->extension_service()->
- GetExtensionById(id, true)) {
- error_ = kInvalidExtensionIdError;
- return false;
- }
- }
-
- std::string title;
- if (details->HasKey(kTitleKey))
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kTitleKey, &title));
-
- std::string body;
- if (details->HasKey(kBodyTextKey))
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kBodyTextKey, &body));
-
- scoped_ptr<AppNotification> item(new AppNotification(
- true, base::Time::Now(), "", id, title, body));
-
- if (details->HasKey(kLinkUrlKey)) {
- std::string link_url;
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkUrlKey, &link_url));
- item->set_link_url(GURL(link_url));
- if (!item->link_url().is_valid()) {
- error_ = "Invalid url: " + link_url;
- return false;
- }
- if (!details->HasKey(kLinkTextKey)) {
- error_ = kMissingLinkTextError;
- return false;
- }
- std::string link_text;
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkTextKey,
- &link_text));
- item->set_link_text(link_text);
- }
-
- AppNotificationManager* manager = extensions::ExtensionSystem::Get(
- profile())->extension_service()->app_notification_manager();
-
- // TODO(beaudoin) We should probably report an error if Add returns false.
- manager->Add(item.release());
-
- return true;
-}
-
-bool AppClearAllNotificationsFunction::RunImpl() {
- if (!include_incognito() && profile_->IsOffTheRecord()) {
- error_ = extension_misc::kAppNotificationsIncognitoError;
- return false;
- }
-
- std::string id = extension_id();
- DictionaryValue* details = NULL;
- if (args_->GetDictionary(0, &details) && details->HasKey(kExtensionIdKey)) {
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id));
- if (!extensions::ExtensionSystem::Get(profile())->extension_service()->
- GetExtensionById(id, true)) {
- error_ = kInvalidExtensionIdError;
- return false;
- }
- }
-
- AppNotificationManager* manager = extensions::ExtensionSystem::Get(
- profile())->extension_service()->app_notification_manager();
- manager->ClearAll(id);
- return true;
-}
-
-} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/app/app_api.h ('k') | chrome/browser/extensions/api/app/app_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698