Skip to content

Commit

Permalink
[DoNotCarryForward] Implement Clipboard for Ozone platforms.
Browse files Browse the repository at this point in the history
This patch provides a general clipboard implementation for Ozone.

The initialization happens automatically:
Clipboard::Create->ClipboardOzone::ClipboardOzone()->
AsyncClipboardOzone::AsyncClipboardOzone()->ClipboardDelegate::GetInstance().

where ClipboardOzone is a derived class from base::Clipboard,
AsyncClipboardOzone is a private helper class of ClipboardOzone, which
gets calls from it, makes requests and sends them to ClipboardDelegate.

TL;DR:
The ClipboardDelegate::GetInstance stores a singleton delegate instance,
which is stored automatically once clipboard delegate is created.
Each ozone platform, which uses clipboard, is responsible to create
own instance of ClipboardDelegate, which communicates with a system
clipboard. If a platform does not have own, the ClipboardDelegate::GetInstance
creates a FakeClipboardDelegate, which emulates the system clipboard in
such a way that it can pass unittests and provide copy/paste
functionality within browser.

The flow is asynchronous and based on requests.That is,
whenever a ClipboardOzone receives a Read/Write/GetMime
call, it forwards it to the helper AsyncClipboardOzone class, which
then creates a request (used for internal usage and holding
data filled by the ClipboardDelegate), calls to the delegate
and start an abort timer to make sure the request is not stalled.

What is more the clipboard data is cached and removed only when another
chunk of data iss written to a system clipboard. And whenever the chromium browser is the
selection owner, the cached data is used.

Bug: 875168
Test: interactive_ui_tests --gtest_filter=ClipboardTest*
components_unittests --gtest_filter=BookmarkUtilsTest*
Change-Id: I0101aebe47cf2cac666f0434b6be2a9a11e2418c
  • Loading branch information
msisov authored and jkim-julie committed Dec 10, 2018
1 parent 873dde0 commit 3649506
Show file tree
Hide file tree
Showing 10 changed files with 638 additions and 10 deletions.
21 changes: 15 additions & 6 deletions ui/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,21 @@ jumbo_component("base") {

if (use_aura) {
# Aura clipboard.
if (use_x11 && is_desktop_linux) {
sources += [
"clipboard/clipboard_aura_linux.cc",
"clipboard/clipboard_aurax11.cc",
"clipboard/clipboard_aurax11.h",
]
if (is_desktop_linux) {
if (use_x11 || use_ozone) {
sources += [ "clipboard/clipboard_aura_linux.cc" ]
}
if (use_ozone) {
sources += [
"clipboard/clipboard_ozone.cc",
"clipboard/clipboard_ozone.h",
]
} else if (use_x11) {
sources += [
"clipboard/clipboard_aurax11.cc",
"clipboard/clipboard_aurax11.h",
]
}
} else if (!is_win) {
# This file is used for all non-X11, non-Windows aura Builds.
sources += [
Expand Down
1 change: 1 addition & 0 deletions ui/base/clipboard/DEPS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_rules = [
"+jni",
"+third_party/mozilla",
"+ui/ozone/public/clipboard_delegate.h",
]
Loading

0 comments on commit 3649506

Please sign in to comment.