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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_linux.cc

Issue 2868433004: Linux native notifications: use image_path instead of image-path for spec 1.1 (Closed)
Patch Set: use base::Version Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/notification_platform_bridge_linux.cc
diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.cc b/chrome/browser/notifications/notification_platform_bridge_linux.cc
index dfd306ce06c18476918e433156a6a8a0a5fc4d6f..aa3a6efc57271c5443f25d7acfd1bbb44f051a31 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.cc
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc
@@ -17,9 +17,11 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_scheduler/post_task.h"
+#include "base/version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/notifications/native_notification_display_service.h"
@@ -51,6 +53,7 @@ enum class ConnectionInitializationStatusCode {
NATIVE_NOTIFICATIONS_NOT_SUPPORTED = 1,
MISSING_REQUIRED_CAPABILITIES = 2,
COULD_NOT_CONNECT_TO_SIGNALS = 3,
+ INCOMPATIBLE_SPEC_VERSION = 4,
NUM_ITEMS
};
@@ -347,6 +350,30 @@ class NotificationPlatformBridgeLinuxImpl
}
RecordMetricsForCapabilities();
+ dbus::MethodCall get_server_information_call(kFreedesktopNotificationsName,
+ "GetServerInformation");
+ std::unique_ptr<dbus::Response> server_information_response =
+ notification_proxy_->CallMethodAndBlock(
+ &get_server_information_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
+ if (server_information_response) {
+ dbus::MessageReader reader(server_information_response.get());
+ std::string spec_version;
+ reader.PopString(&spec_version); // name
+ reader.PopString(&spec_version); // vendor
+ reader.PopString(&spec_version); // version
+ reader.PopString(&spec_version); // spec_version
+ spec_version_ = base::Version(spec_version);
+ }
+ // The minimum supported spec version is 1.1, because this was the
+ // version that added image hints.
+ if (!spec_version_.IsValid() ||
+ spec_version_ < base::Version(std::vector<uint32_t>{1, 1})) {
+ OnConnectionInitializationFinishedOnTaskRunner(
+ ConnectionInitializationStatusCode::INCOMPATIBLE_SPEC_VERSION);
+ return;
+ }
+
connected_signals_barrier_ = base::BarrierClosure(
2, base::Bind(&NotificationPlatformBridgeLinuxImpl::
OnConnectionInitializationFinishedOnTaskRunner,
@@ -472,7 +499,10 @@ class NotificationPlatformBridgeLinuxImpl
if (icon_file) {
dbus::MessageWriter image_path_writer(nullptr);
hints_writer.OpenDictEntry(&image_path_writer);
- image_path_writer.AppendString("image-path");
+ image_path_writer.AppendString(
+ spec_version_ == base::Version(std::vector<uint32_t>{1, 1})
+ ? "image_path"
+ : "image-path");
image_path_writer.AppendVariantOfString(icon_file->file_path().value());
hints_writer.CloseContainer(&image_path_writer);
data->resource_files.push_back(std::move(icon_file));
@@ -700,6 +730,8 @@ class NotificationPlatformBridgeLinuxImpl
std::unordered_set<std::string> capabilities_;
+ base::Version spec_version_;
+
base::Closure connected_signals_barrier_;
// A std::set<std::unique_ptr<T>> doesn't work well because
« no previous file with comments | « no previous file | chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698