OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 NotificationsApiFunction::NotificationsApiFunction() { | 247 NotificationsApiFunction::NotificationsApiFunction() { |
248 } | 248 } |
249 | 249 |
250 NotificationsApiFunction::~NotificationsApiFunction() { | 250 NotificationsApiFunction::~NotificationsApiFunction() { |
251 } | 251 } |
252 | 252 |
253 bool NotificationsApiFunction::CreateNotification( | 253 bool NotificationsApiFunction::CreateNotification( |
254 const std::string& id, | 254 const std::string& id, |
255 api::notifications::NotificationOptions* options) { | 255 api::notifications::NotificationOptions* options) { |
256 // First, make sure the required fields exist: type, title, message, icon. | 256 // First, make sure the required fields exist: type, title, message, icon. |
257 // These fields are defined as optional in IDL such that they can be used as | 257 // These fields are defined as optional in IDL such that they can be used as |
258 // optional for notification updates. But for notification creations, they | 258 // optional for notification updates. But for notification creations, they |
259 // should be present. | 259 // should be present. |
260 if (options->type == api::notifications::TEMPLATE_TYPE_NONE || | 260 if (options->type == api::notifications::TEMPLATE_TYPE_NONE || |
261 !options->icon_url || !options->title || !options->message) { | 261 !options->icon_url || !options->title || !options->message) { |
262 SetError(kMissingRequiredPropertiesForCreateNotification); | 262 SetError(kMissingRequiredPropertiesForCreateNotification); |
263 return false; | 263 return false; |
264 } | 264 } |
265 | 265 |
266 NotificationBitmapSizes bitmap_sizes = GetNotificationBitmapSizes(); | 266 NotificationBitmapSizes bitmap_sizes = GetNotificationBitmapSizes(); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 ? api::notifications::PERMISSION_LEVEL_GRANTED | 684 ? api::notifications::PERMISSION_LEVEL_GRANTED |
685 : api::notifications::PERMISSION_LEVEL_DENIED; | 685 : api::notifications::PERMISSION_LEVEL_DENIED; |
686 | 686 |
687 SetResult(new base::StringValue(api::notifications::ToString(result))); | 687 SetResult(new base::StringValue(api::notifications::ToString(result))); |
688 SendResponse(true); | 688 SendResponse(true); |
689 | 689 |
690 return true; | 690 return true; |
691 } | 691 } |
692 | 692 |
693 } // namespace extensions | 693 } // namespace extensions |
OLD | NEW |