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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 &info.icon); | 277 &info.icon); |
278 optional_fields.buttons.push_back(info); | 278 optional_fields.buttons.push_back(info); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 if (options->expanded_message.get()) { | 282 if (options->expanded_message.get()) { |
283 optional_fields.expanded_message = | 283 optional_fields.expanded_message = |
284 UTF8ToUTF16(*options->expanded_message); | 284 UTF8ToUTF16(*options->expanded_message); |
285 } | 285 } |
286 | 286 |
| 287 if (options->context_message) |
| 288 optional_fields.context_message = UTF8ToUTF16(*options->context_message); |
| 289 |
287 bool has_image = NotificationBitmapToGfxImage(options->image_bitmap.get(), | 290 bool has_image = NotificationBitmapToGfxImage(options->image_bitmap.get(), |
288 &optional_fields.image); | 291 &optional_fields.image); |
289 // We should have an image if and only if the type is an image type. | 292 // We should have an image if and only if the type is an image type. |
290 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) | 293 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) |
291 return false; | 294 return false; |
292 | 295 |
293 // We should have list items if and only if the type is a multiple type. | 296 // We should have list items if and only if the type is a multiple type. |
294 bool has_list_items = options->items.get() && options->items->size() > 0; | 297 bool has_list_items = options->items.get() && options->items->size() > 0; |
295 if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE)) | 298 if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE)) |
296 return false; | 299 return false; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 380 |
378 for (size_t i = 0; i < number_of_buttons; i++) { | 381 for (size_t i = 0; i < number_of_buttons; i++) { |
379 message_center::ButtonInfo info( | 382 message_center::ButtonInfo info( |
380 UTF8ToUTF16((*options->buttons)[i]->title)); | 383 UTF8ToUTF16((*options->buttons)[i]->title)); |
381 NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), | 384 NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), |
382 &info.icon); | 385 &info.icon); |
383 optional_fields.buttons.push_back(info); | 386 optional_fields.buttons.push_back(info); |
384 } | 387 } |
385 } | 388 } |
386 | 389 |
| 390 if (options->context_message) |
| 391 notification->set_context_message(UTF8ToUTF16(*options->context_message)); |
| 392 |
387 if (options->expanded_message) { | 393 if (options->expanded_message) { |
388 notification->set_expanded_message( | 394 notification->set_expanded_message( |
389 UTF8ToUTF16(*options->expanded_message)); | 395 UTF8ToUTF16(*options->expanded_message)); |
390 } | 396 } |
391 | 397 |
392 gfx::Image image; | 398 gfx::Image image; |
393 if (NotificationBitmapToGfxImage(options->image_bitmap.get(), &image)) { | 399 if (NotificationBitmapToGfxImage(options->image_bitmap.get(), &image)) { |
394 // We should have an image if and only if the type is an image type. | 400 // We should have an image if and only if the type is an image type. |
395 if (notification->type() != message_center::NOTIFICATION_TYPE_IMAGE) | 401 if (notification->type() != message_center::NOTIFICATION_TYPE_IMAGE) |
396 return false; | 402 return false; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 StripScopeFromIdentifier(extension_->id(), *iter), true); | 589 StripScopeFromIdentifier(extension_->id(), *iter), true); |
584 } | 590 } |
585 | 591 |
586 SetResult(result.release()); | 592 SetResult(result.release()); |
587 SendResponse(true); | 593 SendResponse(true); |
588 | 594 |
589 return true; | 595 return true; |
590 } | 596 } |
591 | 597 |
592 } // namespace extensions | 598 } // namespace extensions |
OLD | NEW |