| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/notification_platform_bridge_linux.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <sstream> | 10 #include <sstream> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 #include <unordered_set> | 12 #include <unordered_set> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/barrier_closure.h" | 16 #include "base/barrier_closure.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/i18n/number_formatting.h" | 18 #include "base/i18n/number_formatting.h" |
| 19 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/strings/nullable_string16.h" | 20 #include "base/strings/nullable_string16.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/task_scheduler/post_task.h" | 25 #include "base/task_scheduler/post_task.h" |
| 26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
| 28 #include "chrome/browser/notifications/native_notification_display_service.h" | |
| 29 #include "chrome/browser/notifications/notification.h" | 28 #include "chrome/browser/notifications/notification.h" |
| 29 #include "chrome/browser/notifications/notification_display_service.h" |
| 30 #include "chrome/browser/notifications/notification_display_service_factory.h" | 30 #include "chrome/browser/notifications/notification_display_service_factory.h" |
| 31 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 32 #include "chrome/browser/shell_integration_linux.h" | 32 #include "chrome/browser/shell_integration_linux.h" |
| 33 #include "chrome/grit/generated_resources.h" | 33 #include "chrome/grit/generated_resources.h" |
| 34 #include "components/url_formatter/elide_url.h" | 34 #include "components/url_formatter/elide_url.h" |
| 35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "dbus/bus.h" | 37 #include "dbus/bus.h" |
| 38 #include "dbus/message.h" | 38 #include "dbus/message.h" |
| 39 #include "dbus/object_proxy.h" | 39 #include "dbus/object_proxy.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void ProfileLoadedCallback(NotificationCommon::Operation operation, | 159 void ProfileLoadedCallback(NotificationCommon::Operation operation, |
| 160 NotificationCommon::Type notification_type, | 160 NotificationCommon::Type notification_type, |
| 161 const std::string& origin, | 161 const std::string& origin, |
| 162 const std::string& notification_id, | 162 const std::string& notification_id, |
| 163 int action_index, | 163 int action_index, |
| 164 const base::NullableString16& reply, | 164 const base::NullableString16& reply, |
| 165 Profile* profile) { | 165 Profile* profile) { |
| 166 if (!profile) | 166 if (!profile) |
| 167 return; | 167 return; |
| 168 | 168 |
| 169 auto* display_service = static_cast<NativeNotificationDisplayService*>( | 169 auto* display_service = |
| 170 NotificationDisplayServiceFactory::GetForProfile(profile)); | 170 NotificationDisplayServiceFactory::GetForProfile(profile); |
| 171 display_service->ProcessNotificationOperation(operation, notification_type, | 171 display_service->ProcessNotificationOperation(operation, notification_type, |
| 172 origin, notification_id, | 172 origin, notification_id, |
| 173 action_index, reply); | 173 action_index, reply); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void ForwardNotificationOperationOnUiThread( | 176 void ForwardNotificationOperationOnUiThread( |
| 177 NotificationCommon::Operation operation, | 177 NotificationCommon::Operation operation, |
| 178 NotificationCommon::Type notification_type, | 178 NotificationCommon::Type notification_type, |
| 179 const std::string& origin, | 179 const std::string& origin, |
| 180 const std::string& notification_id, | 180 const std::string& notification_id, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 uint32_t dbus_id = 0; | 334 uint32_t dbus_id = 0; |
| 335 | 335 |
| 336 // Same parameters used by NotificationPlatformBridge::Display(). | 336 // Same parameters used by NotificationPlatformBridge::Display(). |
| 337 NotificationCommon::Type notification_type; | 337 NotificationCommon::Type notification_type; |
| 338 const std::string notification_id; | 338 const std::string notification_id; |
| 339 const std::string profile_id; | 339 const std::string profile_id; |
| 340 const bool is_incognito; | 340 const bool is_incognito; |
| 341 | 341 |
| 342 // A copy of the origin_url from the underlying | 342 // A copy of the origin_url from the underlying |
| 343 // message_center::Notification. Used to pass back to | 343 // message_center::Notification. Used to pass back to |
| 344 // NativeNotificationDisplayService. | 344 // NotificationDisplayService. |
| 345 const GURL origin_url; | 345 const GURL origin_url; |
| 346 | 346 |
| 347 // Used to keep track of the IDs of the buttons currently displayed | 347 // Used to keep track of the IDs of the buttons currently displayed |
| 348 // on this notification. The valid range of action IDs is | 348 // on this notification. The valid range of action IDs is |
| 349 // [action_start, action_end). | 349 // [action_start, action_end). |
| 350 size_t action_start = 0; | 350 size_t action_start = 0; |
| 351 size_t action_end = 0; | 351 size_t action_end = 0; |
| 352 | 352 |
| 353 // Temporary resource files associated with the notification that | 353 // Temporary resource files associated with the notification that |
| 354 // should be cleaned up when the notification is closed or on | 354 // should be cleaned up when the notification is closed or on |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 } | 903 } |
| 904 | 904 |
| 905 void NotificationPlatformBridgeLinux::SetReadyCallback( | 905 void NotificationPlatformBridgeLinux::SetReadyCallback( |
| 906 NotificationBridgeReadyCallback callback) { | 906 NotificationBridgeReadyCallback callback) { |
| 907 impl_->SetReadyCallback(std::move(callback)); | 907 impl_->SetReadyCallback(std::move(callback)); |
| 908 } | 908 } |
| 909 | 909 |
| 910 void NotificationPlatformBridgeLinux::CleanUp() { | 910 void NotificationPlatformBridgeLinux::CleanUp() { |
| 911 impl_->CleanUp(); | 911 impl_->CleanUp(); |
| 912 } | 912 } |
| OLD | NEW |