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

Unified Diff: third_party/WebKit/Source/core/frame/NavigatorClipboard.cpp

Issue 2695593006: Initial stub version of Async Clipboard API (Closed)
Patch Set: Address review comments Created 3 years, 6 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
Index: third_party/WebKit/Source/core/frame/NavigatorClipboard.cpp
diff --git a/third_party/WebKit/Source/core/frame/NavigatorClipboard.cpp b/third_party/WebKit/Source/core/frame/NavigatorClipboard.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df12ca8c522973fdabb6758936fa1803720a227f
--- /dev/null
+++ b/third_party/WebKit/Source/core/frame/NavigatorClipboard.cpp
@@ -0,0 +1,42 @@
+// Copyright 2017 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 "core/frame/NavigatorClipboard.h"
+
+#include "core/clipboard/Clipboard.h"
+#include "core/dom/Document.h"
+#include "core/frame/LocalFrame.h"
+
+namespace blink {
+
+Clipboard* NavigatorClipboard::clipboard(ScriptState* script_state,
+ Navigator& navigator) {
+ NavigatorClipboard* supplement = static_cast<NavigatorClipboard*>(
+ Supplement<Navigator>::From(navigator, SupplementName()));
+ if (!supplement) {
+ supplement = new NavigatorClipboard(navigator);
+ ProvideTo(navigator, SupplementName(), supplement);
+ }
+
+ return supplement->clipboard_;
+}
+
+DEFINE_TRACE(NavigatorClipboard) {
+ visitor->Trace(clipboard_);
+ Supplement<Navigator>::Trace(visitor);
+}
+
+NavigatorClipboard::NavigatorClipboard(Navigator& navigator)
+ : Supplement<Navigator>(navigator) {
+ clipboard_ =
+ new Clipboard(GetSupplementable()->GetFrame()
+ ? GetSupplementable()->GetFrame()->GetDocument()
+ : nullptr);
dcheng 2017/06/14 18:56:22 Btw, can we combine Clipboard and NavigatorClipboa
garykac 2017/06/29 01:37:26 We have 2 separate IDL files (Navigator supplement
dcheng1 2017/06/29 05:08:17 OK, that's a good reason =)
+}
+
+const char* NavigatorClipboard::SupplementName() {
+ return "NavigatorClipboard";
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698