Chromium Code Reviews| Index: third_party/WebKit/Source/modules/document_metadata/CopylessPasteServer.cpp |
| diff --git a/third_party/WebKit/Source/modules/document_metadata/CopylessPasteServer.cpp b/third_party/WebKit/Source/modules/document_metadata/CopylessPasteServer.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0fe76d25425294392f32585963c4bf8bc4a15bcc |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/document_metadata/CopylessPasteServer.cpp |
| @@ -0,0 +1,35 @@ |
| +// 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 "modules/document_metadata/CopylessPasteServer.h" |
| + |
| +#include "core/frame/LocalFrame.h" |
| +#include "modules/document_metadata/CopylessPasteExtractor.h" |
| +#include "mojo/public/cpp/bindings/strong_binding.h" |
| + |
| +namespace blink { |
| + |
| +CopylessPasteServer::CopylessPasteServer(LocalFrame& frame) : m_frame(frame) {} |
| + |
| +void CopylessPasteServer::bindMojoRequest( |
| + LocalFrame* frame, |
| + mojom::blink::CopylessPasteRequest request) { |
| + DCHECK(frame); |
| + |
| + mojo::MakeStrongBinding(WTF::wrapUnique(new CopylessPasteServer(*frame)), |
|
dcheng
2017/03/30 21:21:00
Nit: WTF::makeUnique?
wychen
2017/03/31 07:51:54
Done.
|
| + std::move(request)); |
| +} |
| + |
| +void CopylessPasteServer::GetEntities(const GetEntitiesCallback& callback) { |
|
dcheng
2017/03/30 21:21:00
What's the expected lifetime of this service? Is i
wychen
2017/03/30 21:33:28
This service is stateless. When getting a request
wychen
2017/04/05 19:25:50
Most of the Mojo things in Blink are Mojo clients,
|
| + if (!m_frame || !m_frame->document()) { |
| + callback.Run(mojom::blink::WebPage::New()); |
| + return; |
| + } |
| + mojom::blink::WebPagePtr webpage = mojom::blink::WebPage::New(); |
| + // TODO(wychen): connect with CopylessPasteExtractor::extract() like: |
| + // CopylessPasteExtractor::extract(*m_frame->document(), webpage); |
| + callback.Run(std::move(webpage)); |
| +} |
| + |
| +} // namespace blink |