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

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

Issue 1292003004: Elide origins displayed on web notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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/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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (icon_bitmap_ptr) { 298 if (icon_bitmap_ptr) {
299 NotificationConversionHelper::NotificationBitmapToGfxImage( 299 NotificationConversionHelper::NotificationBitmapToGfxImage(
300 image_scale, bitmap_sizes.button_icon_size, *icon_bitmap_ptr, 300 image_scale, bitmap_sizes.button_icon_size, *icon_bitmap_ptr,
301 &info.icon); 301 &info.icon);
302 } 302 }
303 optional_fields.buttons.push_back(info); 303 optional_fields.buttons.push_back(info);
304 } 304 }
305 } 305 }
306 306
307 if (options->context_message) { 307 if (options->context_message) {
308 optional_fields.context_message = 308 optional_fields.context_message.message = *options->context_message;
309 base::UTF8ToUTF16(*options->context_message); 309 optional_fields.context_message.is_origin = false;
310 } 310 }
311 311
312 bool has_image = options->image_bitmap.get() && 312 bool has_image = options->image_bitmap.get() &&
313 NotificationConversionHelper::NotificationBitmapToGfxImage( 313 NotificationConversionHelper::NotificationBitmapToGfxImage(
314 image_scale, bitmap_sizes.image_size, 314 image_scale, bitmap_sizes.image_size,
315 *options->image_bitmap, &optional_fields.image); 315 *options->image_bitmap, &optional_fields.image);
316 316
317 // We should have an image if and only if the type is an image type. 317 // We should have an image if and only if the type is an image type.
318 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) { 318 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) {
319 SetError(kExtraImageProvided); 319 SetError(kExtraImageProvided);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 NotificationConversionHelper::NotificationBitmapToGfxImage( 435 NotificationConversionHelper::NotificationBitmapToGfxImage(
436 image_scale, bitmap_sizes.button_icon_size, *icon_bitmap_ptr, 436 image_scale, bitmap_sizes.button_icon_size, *icon_bitmap_ptr,
437 &button.icon); 437 &button.icon);
438 } 438 }
439 buttons.push_back(button); 439 buttons.push_back(button);
440 } 440 }
441 notification->set_buttons(buttons); 441 notification->set_buttons(buttons);
442 } 442 }
443 443
444 if (options->context_message) { 444 if (options->context_message) {
445 notification->set_context_message( 445 notification->set_context_message(*options->context_message,
446 base::UTF8ToUTF16(*options->context_message)); 446 false /* is_origin */);
447 } 447 }
448 448
449 gfx::Image image; 449 gfx::Image image;
450 bool has_image = 450 bool has_image =
451 options->image_bitmap.get() && 451 options->image_bitmap.get() &&
452 NotificationConversionHelper::NotificationBitmapToGfxImage( 452 NotificationConversionHelper::NotificationBitmapToGfxImage(
453 image_scale, bitmap_sizes.image_size, *options->image_bitmap, &image); 453 image_scale, bitmap_sizes.image_size, *options->image_bitmap, &image);
454 454
455 if (has_image) { 455 if (has_image) {
456 // We should have an image if and only if the type is an image type. 456 // We should have an image if and only if the type is an image type.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 ? api::notifications::PERMISSION_LEVEL_GRANTED 686 ? api::notifications::PERMISSION_LEVEL_GRANTED
687 : api::notifications::PERMISSION_LEVEL_DENIED; 687 : api::notifications::PERMISSION_LEVEL_DENIED;
688 688
689 SetResult(new base::StringValue(api::notifications::ToString(result))); 689 SetResult(new base::StringValue(api::notifications::ToString(result)));
690 SendResponse(true); 690 SendResponse(true);
691 691
692 return true; 692 return true;
693 } 693 }
694 694
695 } // namespace extensions 695 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/notification_conversion_helper.cc » ('j') | ui/message_center/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698