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

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

Issue 23769003: Revert 220500 "Adds the contextMessage field to notifications." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/src/chrome/common/extensions/api/notifications.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
290 bool has_image = NotificationBitmapToGfxImage(options->image_bitmap.get(), 287 bool has_image = NotificationBitmapToGfxImage(options->image_bitmap.get(),
291 &optional_fields.image); 288 &optional_fields.image);
292 // We should have an image if and only if the type is an image type. 289 // We should have an image if and only if the type is an image type.
293 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) 290 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE))
294 return false; 291 return false;
295 292
296 // We should have list items if and only if the type is a multiple type. 293 // We should have list items if and only if the type is a multiple type.
297 bool has_list_items = options->items.get() && options->items->size() > 0; 294 bool has_list_items = options->items.get() && options->items->size() > 0;
298 if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE)) 295 if (has_list_items != (type == message_center::NOTIFICATION_TYPE_MULTIPLE))
299 return false; 296 return false;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 377
381 for (size_t i = 0; i < number_of_buttons; i++) { 378 for (size_t i = 0; i < number_of_buttons; i++) {
382 message_center::ButtonInfo info( 379 message_center::ButtonInfo info(
383 UTF8ToUTF16((*options->buttons)[i]->title)); 380 UTF8ToUTF16((*options->buttons)[i]->title));
384 NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(), 381 NotificationBitmapToGfxImage((*options->buttons)[i]->icon_bitmap.get(),
385 &info.icon); 382 &info.icon);
386 optional_fields.buttons.push_back(info); 383 optional_fields.buttons.push_back(info);
387 } 384 }
388 } 385 }
389 386
390 if (options->context_message)
391 notification->set_context_message(UTF8ToUTF16(*options->context_message));
392
393 if (options->expanded_message) { 387 if (options->expanded_message) {
394 notification->set_expanded_message( 388 notification->set_expanded_message(
395 UTF8ToUTF16(*options->expanded_message)); 389 UTF8ToUTF16(*options->expanded_message));
396 } 390 }
397 391
398 gfx::Image image; 392 gfx::Image image;
399 if (NotificationBitmapToGfxImage(options->image_bitmap.get(), &image)) { 393 if (NotificationBitmapToGfxImage(options->image_bitmap.get(), &image)) {
400 // We should have an image if and only if the type is an image type. 394 // We should have an image if and only if the type is an image type.
401 if (notification->type() != message_center::NOTIFICATION_TYPE_IMAGE) 395 if (notification->type() != message_center::NOTIFICATION_TYPE_IMAGE)
402 return false; 396 return false;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 StripScopeFromIdentifier(extension_->id(), *iter), true); 583 StripScopeFromIdentifier(extension_->id(), *iter), true);
590 } 584 }
591 585
592 SetResult(result.release()); 586 SetResult(result.release());
593 SendResponse(true); 587 SendResponse(true);
594 588
595 return true; 589 return true;
596 } 590 }
597 591
598 } // namespace extensions 592 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | trunk/src/chrome/common/extensions/api/notifications.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698