Chromium Code Reviews| 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) { | |
|
dcheng
2017/06/06 23:33:38
Nit: let's just have NavigatorClipboard construct
garykac
2017/06/09 20:38:59
Done.
| |
| 23 supplement->m_clipboard = new Clipboard( | |
| 24 supplement->GetSupplementable()->GetFrame() | |
| 25 ? supplement->GetSupplementable()->GetFrame()->GetDocument() | |
| 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 |