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

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

Issue 2624193004: Submit a sample of notification images to Safe Browsing (Closed)
Patch Set: Report net_error codes to UMA Created 3 years, 11 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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/user_metrics_action.h" 11 #include "base/metrics/user_metrics_action.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/notifications/notification_display_service_factory.h" 16 #include "chrome/browser/notifications/notification_display_service_factory.h"
17 #include "chrome/browser/notifications/notification_object_proxy.h" 17 #include "chrome/browser/notifications/notification_object_proxy.h"
18 #include "chrome/browser/notifications/persistent_notification_delegate.h" 18 #include "chrome/browser/notifications/persistent_notification_delegate.h"
19 #include "chrome/browser/permissions/permission_manager.h" 19 #include "chrome/browser/permissions/permission_manager.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_attributes_storage.h" 21 #include "chrome/browser/profiles/profile_attributes_storage.h"
22 #include "chrome/browser/profiles/profile_io_data.h" 22 #include "chrome/browser/profiles/profile_io_data.h"
23 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/safe_browsing/ping_manager.h"
25 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
24 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
26 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
27 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
28 #include "components/content_settings/core/common/content_settings.h" 30 #include "components/content_settings/core/common/content_settings.h"
29 #include "components/content_settings/core/common/content_settings_types.h" 31 #include "components/content_settings/core/common/content_settings_types.h"
30 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/desktop_notification_delegate.h" 34 #include "content/public/browser/desktop_notification_delegate.h"
33 #include "content/public/browser/notification_event_dispatcher.h" 35 #include "content/public/browser/notification_event_dispatcher.h"
34 #include "content/public/browser/permission_type.h" 36 #include "content/public/browser/permission_type.h"
35 #include "content/public/browser/user_metrics.h" 37 #include "content/public/browser/user_metrics.h"
36 #include "content/public/common/notification_resources.h" 38 #include "content/public/common/notification_resources.h"
37 #include "content/public/common/platform_notification_data.h" 39 #include "content/public/common/platform_notification_data.h"
38 #include "extensions/features/features.h" 40 #include "extensions/features/features.h"
41 #include "third_party/skia/include/core/SkBitmap.h"
39 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
41 #include "ui/message_center/notification.h" 44 #include "ui/message_center/notification.h"
42 #include "ui/message_center/notification_types.h" 45 #include "ui/message_center/notification_types.h"
43 #include "ui/message_center/notifier_settings.h" 46 #include "ui/message_center/notifier_settings.h"
44 #include "url/url_constants.h" 47 #include "url/url_constants.h"
45 48
46 #if BUILDFLAG(ENABLE_BACKGROUND) 49 #if BUILDFLAG(ENABLE_BACKGROUND)
47 #include "chrome/browser/lifetime/keep_alive_types.h" 50 #include "chrome/browser/lifetime/keep_alive_types.h"
48 #include "chrome/browser/lifetime/scoped_keep_alive.h" 51 #include "chrome/browser/lifetime/scoped_keep_alive.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 std::string profile_id, 83 std::string profile_id,
81 bool incognito) { 84 bool incognito) {
82 ProfileManager* profile_manager = g_browser_process->profile_manager(); 85 ProfileManager* profile_manager = g_browser_process->profile_manager();
83 DCHECK(profile_manager); 86 DCHECK(profile_manager);
84 profile_manager->LoadProfile( 87 profile_manager->LoadProfile(
85 profile_id, incognito, 88 profile_id, incognito,
86 base::Bind(&OnCloseNonPersistentNotificationProfileLoaded, 89 base::Bind(&OnCloseNonPersistentNotificationProfileLoaded,
87 notification_id)); 90 notification_id));
88 } 91 }
89 92
93 void ReportNotificationImageOnIOThread(
94 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service,
95 Profile* profile,
96 const GURL& origin,
97 const SkBitmap& image) {
98 DCHECK_CURRENTLY_ON(BrowserThread::IO);
99 if (!safe_browsing_service || !safe_browsing_service->enabled())
100 return;
101 safe_browsing_service->ping_manager()->ReportNotificationImage(
102 profile, safe_browsing_service->database_manager(), origin, image);
103 }
104
90 } // namespace 105 } // namespace
91 106
92 // static 107 // static
93 PlatformNotificationServiceImpl* 108 PlatformNotificationServiceImpl*
94 PlatformNotificationServiceImpl::GetInstance() { 109 PlatformNotificationServiceImpl::GetInstance() {
95 return base::Singleton<PlatformNotificationServiceImpl>::get(); 110 return base::Singleton<PlatformNotificationServiceImpl>::get();
96 } 111 }
97 112
98 PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() 113 PlatformNotificationServiceImpl::PlatformNotificationServiceImpl()
99 : test_display_service_(nullptr) { 114 : test_display_service_(nullptr) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 DisplayNameForContextMessage(profile, origin)); 436 DisplayNameForContextMessage(profile, origin));
422 notification.set_vibration_pattern(notification_data.vibration_pattern); 437 notification.set_vibration_pattern(notification_data.vibration_pattern);
423 notification.set_timestamp(notification_data.timestamp); 438 notification.set_timestamp(notification_data.timestamp);
424 notification.set_renotify(notification_data.renotify); 439 notification.set_renotify(notification_data.renotify);
425 notification.set_silent(notification_data.silent); 440 notification.set_silent(notification_data.silent);
426 441
427 if (!notification_resources.image.drawsNothing()) { 442 if (!notification_resources.image.drawsNothing()) {
428 notification.set_type(message_center::NOTIFICATION_TYPE_IMAGE); 443 notification.set_type(message_center::NOTIFICATION_TYPE_IMAGE);
429 notification.set_image( 444 notification.set_image(
430 gfx::Image::CreateFrom1xBitmap(notification_resources.image)); 445 gfx::Image::CreateFrom1xBitmap(notification_resources.image));
446 // n.b. this should only be posted once per notification.
447 BrowserThread::PostTask(
448 BrowserThread::IO, FROM_HERE,
449 base::Bind(
450 &ReportNotificationImageOnIOThread,
451 make_scoped_refptr(g_browser_process->safe_browsing_service()),
452 profile, origin, notification_resources.image));
431 } 453 }
432 454
433 // Badges are only supported on Android, primarily because it's the only 455 // Badges are only supported on Android, primarily because it's the only
434 // platform that makes good use of them in the status bar. 456 // platform that makes good use of them in the status bar.
435 #if defined(OS_ANDROID) 457 #if defined(OS_ANDROID)
436 // TODO(peter): Handle different screen densities instead of always using the 458 // TODO(peter): Handle different screen densities instead of always using the
437 // 1x bitmap - crbug.com/585815. 459 // 1x bitmap - crbug.com/585815.
438 notification.set_small_image( 460 notification.set_small_image(
439 gfx::Image::CreateFrom1xBitmap(notification_resources.badge)); 461 gfx::Image::CreateFrom1xBitmap(notification_resources.badge));
440 #endif // defined(OS_ANDROID) 462 #endif // defined(OS_ANDROID)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 } 519 }
498 #endif 520 #endif
499 521
500 return base::string16(); 522 return base::string16();
501 } 523 }
502 524
503 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 525 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
504 NotificationDisplayService* display_service) { 526 NotificationDisplayService* display_service) {
505 test_display_service_ = display_service; 527 test_display_service_ = display_service;
506 } 528 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698