#include "components/system_media_controls/linux/system_media_controls_linux.h"
#include <memory>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
#include "base/notimplemented.h"
#include "base/observer_list.h"
#include "base/process/process.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "components/dbus/properties/dbus_properties.h"
#include "components/dbus/properties/success_barrier_callback.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "components/system_media_controls/system_media_controls_observer.h"
#include "dbus/bus.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/property.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
namespace system_media_controls {
std::unique_ptr<SystemMediaControls> SystemMediaControls::Create(
const std::string& product_name,
int window) { … }
void SystemMediaControls::SetVisibilityChangedCallbackForTesting(
base::RepeatingCallback<void(bool)>*) { … }
namespace internal {
namespace {
constexpr int kNumMethodsToExport = …;
constexpr base::TimeDelta kUpdatePositionInterval = …;
const char kMprisAPINoTrackPath[] = …;
const char kMprisAPICurrentTrackPathFormatString[] = …;
std::pair<base::FilePath, base::SequenceBound<base::ScopedTempFile>>
WriteBitmapToTmpFile(const SkBitmap& bitmap) { … }
}
const char kMprisAPIServiceNameFormatString[] = …;
const char kMprisAPIObjectPath[] = …;
const char kMprisAPIInterfaceName[] = …;
const char kMprisAPIPlayerInterfaceName[] = …;
const char kMprisAPISignalSeeked[] = …;
SystemMediaControlsLinux::SystemMediaControlsLinux(
const std::string& product_name)
: … { … }
SystemMediaControlsLinux::~SystemMediaControlsLinux() { … }
void SystemMediaControlsLinux::StartService() { … }
void SystemMediaControlsLinux::AddObserver(
SystemMediaControlsObserver* observer) { … }
void SystemMediaControlsLinux::RemoveObserver(
SystemMediaControlsObserver* observer) { … }
void SystemMediaControlsLinux::SetIsNextEnabled(bool value) { … }
void SystemMediaControlsLinux::SetIsPreviousEnabled(bool value) { … }
void SystemMediaControlsLinux::SetIsPlayPauseEnabled(bool value) { … }
void SystemMediaControlsLinux::SetIsSeekToEnabled(bool value) { … }
void SystemMediaControlsLinux::SetPlaybackStatus(PlaybackStatus value) { … }
void SystemMediaControlsLinux::SetID(const std::string* value) { … }
void SystemMediaControlsLinux::SetTitle(const std::u16string& value) { … }
void SystemMediaControlsLinux::SetArtist(const std::u16string& value) { … }
void SystemMediaControlsLinux::SetAlbum(const std::u16string& value) { … }
void SystemMediaControlsLinux::SetThumbnail(const SkBitmap& bitmap) { … }
void SystemMediaControlsLinux::SetPosition(
const media_session::MediaPosition& position) { … }
void SystemMediaControlsLinux::ClearMetadata() { … }
bool SystemMediaControlsLinux::GetVisibilityForTesting() const { … }
std::string SystemMediaControlsLinux::GetServiceName() const { … }
void SystemMediaControlsLinux::InitializeProperties() { … }
void SystemMediaControlsLinux::InitializeDbusInterface() { … }
void SystemMediaControlsLinux::OnExported(const std::string& interface_name,
const std::string& method_name,
bool success) { … }
void SystemMediaControlsLinux::OnInitialized(bool success) { … }
void SystemMediaControlsLinux::OnOwnership(const std::string& service_name,
bool success) { … }
void SystemMediaControlsLinux::Next(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::Previous(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::Pause(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::PlayPause(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::Stop(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::Play(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::Seek(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::SetPositionMpris(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::DoNothing(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void SystemMediaControlsLinux::SetMetadataPropertyInternal(
const std::string& property_name,
DbusVariant&& new_value) { … }
void SystemMediaControlsLinux::ClearTrackId() { … }
void SystemMediaControlsLinux::ClearPosition() { … }
void SystemMediaControlsLinux::UpdatePosition(bool emit_signal) { … }
void SystemMediaControlsLinux::StartPositionUpdateTimer() { … }
void SystemMediaControlsLinux::StopPositionUpdateTimer() { … }
void SystemMediaControlsLinux::OnThumbnailFileWritten(
std::pair<base::FilePath, base::SequenceBound<base::ScopedTempFile>>
thumbnail) { … }
}
}