chromium/chrome/browser/notifications/notification_platform_bridge_linux.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/notifications/notification_platform_bridge_linux.h"

#include <algorithm>
#include <memory>
#include <set>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#include "base/barrier_closure.h"
#include "base/callback_list.h"
#include "base/containers/contains.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_path_watcher.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_file.h"
#include "base/functional/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/escape.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/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/termination_notification.h"
#include "chrome/browser/notifications/notification_display_service_impl.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/notifications/notification_operation.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/generated_resources.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "components/url_formatter/elide_url.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "skia/ext/image_operations.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/message_center/public/cpp/notification.h"
#include "url/origin.h"

namespace {

// DBus name / path.
const char kFreedesktopNotificationsName[] =;
const char kFreedesktopNotificationsPath[] =;

// DBus methods.
const char kMethodCloseNotification[] =;
const char kMethodGetCapabilities[] =;
const char kMethodListActivatableNames[] =;
const char kMethodNameHasOwner[] =;
const char kMethodNotify[] =;
const char kMethodStartServiceByName[] =;

// DBus signals.
const char kSignalActionInvoked[] =;
const char kSignalNotificationClosed[] =;
const char kSignalNotificationReplied[] =;

// Capabilities.
const char kCapabilityActions[] =;
const char kCapabilityBody[] =;
const char kCapabilityBodyHyperlinks[] =;
const char kCapabilityBodyImages[] =;
const char kCapabilityBodyMarkup[] =;
const char kCapabilityInlineReply[] =;
const char kCapabilityPersistence[] =;
const char kCapabilityXKdeOriginName[] =;
const char kCapabilityXKdeReplyPlaceholderText[] =;

// Button IDs.
const char kCloseButtonId[] =;
const char kDefaultButtonId[] =;
const char kInlineReplyButtonId[] =;
const char kSettingsButtonId[] =;

// Max image size; specified in the FDO notification specification.
const int kMaxImageWidth =;
const int kMaxImageHeight =;

// Time to wait for the notification service to start.
constexpr base::TimeDelta kStartServiceTimeout =;

// Notification on-screen time, in milliseconds.
const int32_t kExpireTimeout =;

// The maximum amount of characters for displaying the full origin path.
const size_t kMaxAllowedOriginLength =;

// Notification urgency levels, as specified in the FDO notification spec.
enum FdoUrgency {};

// The values in this enumeration correspond to those of the
// Linux.NotificationPlatformBridge.InitializationStatus histogram, so
// the ordering should not be changed.  New error codes should be
// added at the end, before NUM_ITEMS.
enum class ConnectionInitializationStatusCode {};

std::u16string CreateNotificationTitle(
    const message_center::Notification& notification) {}

void EscapeUnsafeCharacters(std::string* message) {}

int NotificationPriorityToFdoUrgency(int priority) {}

// Constrain |image|'s size to |kMaxImageWidth|x|kMaxImageHeight|. If
// the image does not need to be resized, or the image is empty,
// returns |image| directly.
gfx::Image ResizeImageToFdoMaxSize(const gfx::Image& image) {}

bool ShouldAddCloseButton(const std::string& server_name,
                          const base::Version& server_version) {}

bool ShouldMarkPersistentNotificationsAsCritical(
    const std::string& server_name) {}

void ForwardNotificationOperationOnUiThread(
    NotificationOperation operation,
    NotificationHandler::Type notification_type,
    const GURL& origin,
    const std::string& notification_id,
    const std::optional<int>& action_index,
    const std::optional<bool>& by_user,
    const std::optional<std::u16string>& reply,
    const std::string& profile_id,
    bool is_incognito) {}

// Writes `data` to a new temporary file and returns the temporary file
base::ScopedTempFile WriteDataToTmpFile(
    const scoped_refptr<base::RefCountedMemory>& data) {}

bool CheckNotificationsNameHasOwnerOrIsActivatable(dbus::Bus* bus) {}

}  // namespace

// static
std::unique_ptr<NotificationPlatformBridge>
NotificationPlatformBridge::Create() {}

// static
bool NotificationPlatformBridge::CanHandleType(
    NotificationHandler::Type notification_type) {}

class NotificationPlatformBridgeLinuxImpl
    : public NotificationPlatformBridge,
      public base::RefCountedThreadSafe<NotificationPlatformBridgeLinuxImpl> {};

NotificationPlatformBridgeLinux::NotificationPlatformBridgeLinux()
    :{}

NotificationPlatformBridgeLinux::NotificationPlatformBridgeLinux(
    scoped_refptr<dbus::Bus> bus)
    :{}

NotificationPlatformBridgeLinux::~NotificationPlatformBridgeLinux() = default;

void NotificationPlatformBridgeLinux::Display(
    NotificationHandler::Type notification_type,
    Profile* profile,
    const message_center::Notification& notification,
    std::unique_ptr<NotificationCommon::Metadata> metadata) {}

void NotificationPlatformBridgeLinux::Close(
    Profile* profile,
    const std::string& notification_id) {}

void NotificationPlatformBridgeLinux::GetDisplayed(
    Profile* profile,
    GetDisplayedNotificationsCallback callback) const {}

void NotificationPlatformBridgeLinux::GetDisplayedForOrigin(
    Profile* profile,
    const GURL& origin,
    GetDisplayedNotificationsCallback callback) const {}

void NotificationPlatformBridgeLinux::SetReadyCallback(
    NotificationBridgeReadyCallback callback) {}

void NotificationPlatformBridgeLinux::DisplayServiceShutDown(Profile* profile) {}

void NotificationPlatformBridgeLinux::CleanUp() {}