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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 1395093002: Fix system notifications incorrectly marked as type WEB_PAGE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timeout
Patch Set: Created 5 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/platform_notification_service_impl.h" 5 #include "chrome/browser/notifications/platform_notification_service_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/metrics/user_metrics_action.h" 9 #include "base/metrics/user_metrics_action.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 18 matching lines...) Expand all
29 #include "components/url_formatter/url_formatter.h" 29 #include "components/url_formatter/url_formatter.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/desktop_notification_delegate.h" 31 #include "content/public/browser/desktop_notification_delegate.h"
32 #include "content/public/browser/notification_event_dispatcher.h" 32 #include "content/public/browser/notification_event_dispatcher.h"
33 #include "content/public/browser/platform_notification_context.h" 33 #include "content/public/browser/platform_notification_context.h"
34 #include "content/public/browser/storage_partition.h" 34 #include "content/public/browser/storage_partition.h"
35 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
36 #include "content/public/common/platform_notification_data.h" 36 #include "content/public/common/platform_notification_data.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/message_center/notification_types.h"
39 #include "ui/message_center/notifier_settings.h" 40 #include "ui/message_center/notifier_settings.h"
40 #include "ui/resources/grit/ui_resources.h" 41 #include "ui/resources/grit/ui_resources.h"
41 #include "url/url_constants.h" 42 #include "url/url_constants.h"
42 43
43 #if defined(ENABLE_EXTENSIONS) 44 #if defined(ENABLE_EXTENSIONS)
44 #include "chrome/browser/notifications/notifier_state_tracker.h" 45 #include "chrome/browser/notifications/notifier_state_tracker.h"
45 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" 46 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
46 #include "extensions/browser/extension_registry.h" 47 #include "extensions/browser/extension_registry.h"
47 #include "extensions/browser/info_map.h" 48 #include "extensions/browser/info_map.h"
48 #include "extensions/common/constants.h" 49 #include "extensions/common/constants.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 Profile* profile, 349 Profile* profile,
349 const GURL& origin, 350 const GURL& origin,
350 const SkBitmap& icon, 351 const SkBitmap& icon,
351 const content::PlatformNotificationData& notification_data, 352 const content::PlatformNotificationData& notification_data,
352 NotificationDelegate* delegate) const { 353 NotificationDelegate* delegate) const {
353 // TODO(peter): Icons for Web Notifications are currently always requested for 354 // TODO(peter): Icons for Web Notifications are currently always requested for
354 // 1x scale, whereas the displays on which they can be displayed can have a 355 // 1x scale, whereas the displays on which they can be displayed can have a
355 // different pixel density. Be smarter about this when the API gets updated 356 // different pixel density. Be smarter about this when the API gets updated
356 // with a way for developers to specify images of different resolutions. 357 // with a way for developers to specify images of different resolutions.
357 Notification notification( 358 Notification notification(
358 origin, notification_data.title, notification_data.body, 359 message_center::NOTIFICATION_TYPE_SIMPLE, notification_data.title,
359 gfx::Image::CreateFrom1xBitmap(icon), base::UTF8ToUTF16(origin.host()), 360 notification_data.body, gfx::Image::CreateFrom1xBitmap(icon),
360 notification_data.tag, delegate); 361 message_center::NotifierId(origin), base::UTF8ToUTF16(origin.host()),
362 origin, notification_data.tag, message_center::RichNotificationData(),
363 delegate);
361 364
362 notification.set_context_message( 365 notification.set_context_message(
363 DisplayNameForContextMessage(profile, origin)); 366 DisplayNameForContextMessage(profile, origin));
364 notification.set_vibration_pattern(notification_data.vibration_pattern); 367 notification.set_vibration_pattern(notification_data.vibration_pattern);
365 notification.set_silent(notification_data.silent); 368 notification.set_silent(notification_data.silent);
366 369
367 std::vector<message_center::ButtonInfo> buttons; 370 std::vector<message_center::ButtonInfo> buttons;
368 371
369 // Developer supplied buttons. 372 // Developer supplied buttons.
370 for (const auto& action : notification_data.actions) 373 for (const auto& action : notification_data.actions)
371 buttons.push_back(message_center::ButtonInfo(action.title)); 374 buttons.push_back(message_center::ButtonInfo(action.title));
372 375
373 // Android always includes the settings button in all notifications, whereas for 376 // Android always includes the settings button in all notifications, whereas for
374 // desktop only web (not extensions) notifications do. 377 // desktop only web (not extensions) notifications do.
375 #if !defined(OS_ANDROID) 378 #if !defined(OS_ANDROID)
376 // The notification Settings button always comes at the end. 379 // The notification Settings button always comes at the end.
377 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 380 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
378 switches::kNotificationSettingsButton)) { 381 switches::kNotificationSettingsButton)) {
379 message_center::ButtonInfo settings_button = message_center::ButtonInfo( 382 message_center::ButtonInfo settings_button = message_center::ButtonInfo(
380 l10n_util::GetStringUTF16(IDS_NOTIFICATION_SETTINGS)); 383 l10n_util::GetStringUTF16(IDS_NOTIFICATION_SETTINGS));
381 settings_button.icon = 384 settings_button.icon =
382 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 385 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
383 IDR_NOTIFICATION_SETTINGS); 386 IDR_NOTIFICATION_SETTINGS);
384 buttons.push_back(settings_button); 387 buttons.push_back(settings_button);
385 } 388 }
386 #endif // !defined(OS_ANDROID) 389 #endif // !defined(OS_ANDROID)
387 390
388 notification.set_buttons(buttons); 391 notification.set_buttons(buttons);
389 392
390 notification.set_is_web_notification(true);
391
392 // On desktop, notifications with require_interaction==true stay on-screen 393 // On desktop, notifications with require_interaction==true stay on-screen
393 // rather than minimizing to the notification center after a timeout. 394 // rather than minimizing to the notification center after a timeout.
394 // On mobile, this is ignored (notifications are minimized at all times). 395 // On mobile, this is ignored (notifications are minimized at all times).
395 if (notification_data.require_interaction) 396 if (notification_data.require_interaction)
396 notification.set_never_timeout(true); 397 notification.set_never_timeout(true);
397 398
398 return notification; 399 return notification;
399 } 400 }
400 401
401 NotificationUIManager* 402 NotificationUIManager*
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( 439 extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
439 origin.host(), extensions::ExtensionRegistry::EVERYTHING); 440 origin.host(), extensions::ExtensionRegistry::EVERYTHING);
440 DCHECK(extension); 441 DCHECK(extension);
441 442
442 return base::UTF8ToUTF16(extension->name()); 443 return base::UTF8ToUTF16(extension->name());
443 } 444 }
444 #endif 445 #endif
445 446
446 return base::string16(); 447 return base::string16();
447 } 448 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698