OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/download/notification/download_item_notification.h" | 5 #include "chrome/browser/download/notification/download_item_notification.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
8 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" |
10 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/download/download_crx_util.h" | 15 #include "chrome/browser/download/download_crx_util.h" |
12 #include "chrome/browser/download/download_item_model.h" | 16 #include "chrome/browser/download/download_item_model.h" |
13 #include "chrome/browser/download/notification/download_notification_manager.h" | 17 #include "chrome/browser/download/notification/download_notification_manager.h" |
14 #include "chrome/browser/notifications/notification.h" | 18 #include "chrome/browser/notifications/notification.h" |
15 #include "chrome/browser/notifications/notification_ui_manager.h" | 19 #include "chrome/browser/notifications/notification_ui_manager.h" |
16 #include "chrome/browser/notifications/profile_notification.h" | 20 #include "chrome/browser/notifications/profile_notification.h" |
17 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
18 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
19 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
(...skipping 28 matching lines...) Expand all Loading... |
48 namespace { | 52 namespace { |
49 | 53 |
50 const char kDownloadNotificationNotifierId[] = | 54 const char kDownloadNotificationNotifierId[] = |
51 "chrome://downloads/notification/id-notifier"; | 55 "chrome://downloads/notification/id-notifier"; |
52 | 56 |
53 // Background color of the preview images | 57 // Background color of the preview images |
54 const SkColor kImageBackgroundColor = SK_ColorWHITE; | 58 const SkColor kImageBackgroundColor = SK_ColorWHITE; |
55 | 59 |
56 // Maximum size of preview image. If the image exceeds this size, don't show the | 60 // Maximum size of preview image. If the image exceeds this size, don't show the |
57 // preview image. | 61 // preview image. |
58 const int64 kMaxImagePreviewSize = 10 * 1024 * 1024; // 10 MB | 62 const int64_t kMaxImagePreviewSize = 10 * 1024 * 1024; // 10 MB |
59 | 63 |
60 std::string ReadNotificationImage(const base::FilePath& file_path) { | 64 std::string ReadNotificationImage(const base::FilePath& file_path) { |
61 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 65 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
62 | 66 |
63 std::string data; | 67 std::string data; |
64 bool ret = base::ReadFileToString(file_path, &data); | 68 bool ret = base::ReadFileToString(file_path, &data); |
65 if (!ret) | 69 if (!ret) |
66 return std::string(); | 70 return std::string(); |
67 | 71 |
68 DCHECK_LE(data.size(), static_cast<size_t>(kMaxImagePreviewSize)); | 72 DCHECK_LE(data.size(), static_cast<size_t>(kMaxImagePreviewSize)); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 const std::string notification_id_in_message_center = notification->id(); | 940 const std::string notification_id_in_message_center = notification->id(); |
937 | 941 |
938 message_center::NotificationList::Notifications visible_notifications = | 942 message_center::NotificationList::Notifications visible_notifications = |
939 message_center_->GetVisibleNotifications(); | 943 message_center_->GetVisibleNotifications(); |
940 for (const auto& notification : visible_notifications) { | 944 for (const auto& notification : visible_notifications) { |
941 if (notification->id() == notification_id_in_message_center) | 945 if (notification->id() == notification_id_in_message_center) |
942 return true; | 946 return true; |
943 } | 947 } |
944 return false; | 948 return false; |
945 } | 949 } |
OLD | NEW |