OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/frame/NavigatorClipboard.h" |
| 6 |
| 7 #include "core/clipboard/Clipboard.h" |
| 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/LocalFrame.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 Clipboard* NavigatorClipboard::clipboard(ScriptState* scriptState, |
| 14 Navigator& navigator) { |
| 15 NavigatorClipboard* supplement = static_cast<NavigatorClipboard*>( |
| 16 Supplement<Navigator>::from(navigator, supplementName())); |
| 17 if (!supplement) { |
| 18 supplement = new NavigatorClipboard(navigator); |
| 19 provideTo(navigator, supplementName(), supplement); |
| 20 } |
| 21 |
| 22 if (!supplement->m_clipboard) { |
| 23 supplement->m_clipboard = |
| 24 new Clipboard(supplement->supplementable()->frame() |
| 25 ? supplement->supplementable()->frame()->document() |
| 26 : nullptr); |
| 27 } |
| 28 |
| 29 return supplement->m_clipboard; |
| 30 } |
| 31 |
| 32 DEFINE_TRACE(NavigatorClipboard) { |
| 33 visitor->trace(m_clipboard); |
| 34 Supplement<Navigator>::trace(visitor); |
| 35 } |
| 36 |
| 37 NavigatorClipboard::NavigatorClipboard(Navigator& navigator) |
| 38 : Supplement<Navigator>(navigator) {} |
| 39 |
| 40 const char* NavigatorClipboard::supplementName() { |
| 41 return "NavigatorClipboard"; |
| 42 } |
| 43 |
| 44 } // namespace blink |
OLD | NEW |