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..4fdd50b034a9f46665adbbcd627302691c9fa991 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/frame/NavigatorClipboard.cpp |
@@ -0,0 +1,44 @@ |
+// 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* scriptState, |
+ Navigator& navigator) { |
+ NavigatorClipboard* supplement = static_cast<NavigatorClipboard*>( |
+ Supplement<Navigator>::From(navigator, SupplementName())); |
+ if (!supplement) { |
+ supplement = new NavigatorClipboard(navigator); |
+ ProvideTo(navigator, SupplementName(), supplement); |
+ } |
+ |
+ if (!supplement->m_clipboard) { |
dcheng
2017/06/06 23:33:38
Nit: let's just have NavigatorClipboard construct
garykac
2017/06/09 20:38:59
Done.
|
+ supplement->m_clipboard = new Clipboard( |
+ supplement->GetSupplementable()->GetFrame() |
+ ? supplement->GetSupplementable()->GetFrame()->GetDocument() |
+ : nullptr); |
+ } |
+ |
+ return supplement->m_clipboard; |
+} |
+ |
+DEFINE_TRACE(NavigatorClipboard) { |
+ visitor->Trace(m_clipboard); |
+ Supplement<Navigator>::Trace(visitor); |
+} |
+ |
+NavigatorClipboard::NavigatorClipboard(Navigator& navigator) |
+ : Supplement<Navigator>(navigator) {} |
+ |
+const char* NavigatorClipboard::SupplementName() { |
+ return "NavigatorClipboard"; |
+} |
+ |
+} // namespace blink |