mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove clipboard mojo service (#3143)
All the clients have migrated to platform messages.
This commit is contained in:
parent
be9761268a
commit
808009d411
@ -26,7 +26,6 @@ if (is_android) {
|
||||
|
||||
android_library("editing_lib") {
|
||||
java_files = [
|
||||
"src/org/domokit/editing/ClipboardImpl.java",
|
||||
"src/org/domokit/editing/KeyboardImpl.java",
|
||||
"src/org/domokit/editing/KeyboardViewState.java",
|
||||
"src/org/domokit/editing/InputConnectionAdaptor.java",
|
||||
@ -46,8 +45,6 @@ if (is_ios) {
|
||||
sources = [
|
||||
"ios/keyboard_impl.h",
|
||||
"ios/keyboard_impl.mm",
|
||||
"ios/clipboard_impl.h",
|
||||
"ios/clipboard_impl.mm",
|
||||
]
|
||||
deps = [
|
||||
"//base:base",
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FLUTTER_SERVICES_CLIPBOARD_IOS_CLIPBOARD_SERVICE_IMPL_H_
|
||||
#define FLUTTER_SERVICES_CLIPBOARD_IOS_CLIPBOARD_SERVICE_IMPL_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||
#include "flutter/services/editing/editing.mojom.h"
|
||||
|
||||
namespace sky {
|
||||
namespace services {
|
||||
namespace editing {
|
||||
|
||||
class ClipboardImpl : public ::editing::Clipboard {
|
||||
public:
|
||||
explicit ClipboardImpl(mojo::InterfaceRequest<::editing::Clipboard> request);
|
||||
~ClipboardImpl() override;
|
||||
void SetClipboardData(::editing::ClipboardDataPtr clip) override;
|
||||
void GetClipboardData(
|
||||
const mojo::String& format,
|
||||
const ::editing::Clipboard::GetClipboardDataCallback& callback) override;
|
||||
|
||||
private:
|
||||
mojo::StrongBinding<::editing::Clipboard> binding_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ClipboardImpl);
|
||||
};
|
||||
|
||||
} // namespace editing
|
||||
} // namespace services
|
||||
} // namespace sky
|
||||
|
||||
#endif /* defined(FLUTTER_SERVICES_CLIPBOARD_IOS_CLIPBOARD_SERVICE_IMPL_H__) */
|
||||
@ -1,51 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/services/editing/ios/clipboard_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include <UIKit/UIKit.h>
|
||||
#include <unicode/utf16.h>
|
||||
|
||||
namespace {
|
||||
|
||||
static const char kTextPlainFormat[] = "text/plain";
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace sky {
|
||||
namespace services {
|
||||
namespace editing {
|
||||
|
||||
ClipboardImpl::ClipboardImpl(
|
||||
mojo::InterfaceRequest<::editing::Clipboard> request)
|
||||
: binding_(this, request.Pass()) {}
|
||||
|
||||
ClipboardImpl::~ClipboardImpl() {
|
||||
}
|
||||
|
||||
void ClipboardImpl::SetClipboardData(::editing::ClipboardDataPtr clip) {
|
||||
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
|
||||
pasteboard.string = @(clip->text.data());
|
||||
}
|
||||
|
||||
void ClipboardImpl::GetClipboardData(
|
||||
const mojo::String& format,
|
||||
const ::editing::Clipboard::GetClipboardDataCallback& callback) {
|
||||
::editing::ClipboardDataPtr clip;
|
||||
|
||||
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
|
||||
if ((format.is_null() || format == kTextPlainFormat) && pasteboard.string) {
|
||||
clip = ::editing::ClipboardData::New();
|
||||
clip->text = pasteboard.string.UTF8String;
|
||||
}
|
||||
|
||||
callback.Run(clip.Pass());
|
||||
}
|
||||
|
||||
} // namespace editing
|
||||
} // namespace services
|
||||
} // namespace sky
|
||||
@ -1,64 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package org.domokit.editing;
|
||||
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipDescription;
|
||||
import android.content.Context;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import org.chromium.mojo.system.MojoException;
|
||||
import org.chromium.mojom.editing.ClipboardData;
|
||||
import org.chromium.mojom.editing.Clipboard;
|
||||
|
||||
/**
|
||||
* Android implementation of Clipboard.
|
||||
*/
|
||||
public class ClipboardImpl implements Clipboard {
|
||||
private Context mContext;
|
||||
private static final String kTextPlainFormat = "text/plain";
|
||||
|
||||
public ClipboardImpl(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionError(MojoException e) {}
|
||||
|
||||
@Override
|
||||
public void setClipboardData(ClipboardData incomingClip) {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("text label?", incomingClip.text);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getClipboardData(String format, GetClipboardDataResponse callback) {
|
||||
ClipboardManager clipboard =
|
||||
(ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = clipboard.getPrimaryClip();
|
||||
if (clip == null) {
|
||||
callback.call(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((format == null || format.equals(kTextPlainFormat)) &&
|
||||
clip.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
|
||||
ClipboardData clipResult = new ClipboardData();
|
||||
clipResult.text = clip.getItemAt(0).getText().toString();
|
||||
callback.call(clipResult);
|
||||
return;
|
||||
}
|
||||
|
||||
// Unsupported or incompatible format.
|
||||
callback.call(null);
|
||||
}
|
||||
}
|
||||
@ -34,9 +34,7 @@ import org.chromium.mojo.bindings.Interface.Binding;
|
||||
import org.chromium.mojo.system.Core;
|
||||
import org.chromium.mojo.system.impl.CoreImpl;
|
||||
import org.chromium.mojo.system.MessagePipeHandle;
|
||||
import org.chromium.mojom.editing.Clipboard;
|
||||
import org.chromium.mojom.vsync.VSyncProvider;
|
||||
import org.domokit.editing.ClipboardImpl;
|
||||
import org.domokit.vsync.VSyncProviderImpl;
|
||||
|
||||
/**
|
||||
@ -182,13 +180,6 @@ public class FlutterMain {
|
||||
private static native void nativeRecordStartTimestamp(long initTimeMillis);
|
||||
|
||||
private static void onServiceRegistryAvailable(final Context applicationContext, ServiceRegistry registry) {
|
||||
registry.register(Clipboard.MANAGER.getName(), new ServiceFactory() {
|
||||
@Override
|
||||
public Binding connectToService(FlutterView view, Core core, MessagePipeHandle pipe) {
|
||||
return Clipboard.MANAGER.bind(new ClipboardImpl(view.getContext()), pipe);
|
||||
}
|
||||
});
|
||||
|
||||
registry.register(VSyncProvider.MANAGER.getName(), new ServiceFactory() {
|
||||
@Override
|
||||
public Binding connectToService(FlutterView view, Core core, MessagePipeHandle pipe) {
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#include "flutter/shell/platform/darwin/common/platform_service_provider.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#include "flutter/services/editing/ios/clipboard_impl.h"
|
||||
#include "flutter/services/vsync/ios/vsync_provider_ios_impl.h"
|
||||
#else
|
||||
#include "flutter/services/vsync/mac/vsync_provider_mac_impl.h"
|
||||
@ -23,11 +22,6 @@ void PlatformServiceProvider::ConnectToService(
|
||||
const mojo::String& service_name,
|
||||
mojo::ScopedMessagePipeHandle client_handle) {
|
||||
#if TARGET_OS_IPHONE
|
||||
if (service_name == ::editing::Clipboard::Name_) {
|
||||
new sky::services::editing::ClipboardImpl(
|
||||
mojo::InterfaceRequest<::editing::Clipboard>(client_handle.Pass()));
|
||||
return;
|
||||
}
|
||||
if (service_name == ::vsync::VSyncProvider::Name_) {
|
||||
new sky::services::vsync::VsyncProviderIOSImpl(
|
||||
mojo::InterfaceRequest<::vsync::VSyncProvider>(client_handle.Pass()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user