Commit 0be0df4f authored by wychen's avatar wychen Committed by Commit bot

Add mojo service for CopylessPaste in Blink

A CopylessPaste mojo service in Blink is added. The parsed data would
be forwarded to the app indexing service.

BUG=693650

Review-Url: https://codereview.chromium.org/2787703002
Cr-Commit-Position: refs/heads/master@{#462826}
parent 986188a9
......@@ -21,6 +21,7 @@
#include "modules/canvas2d/CanvasRenderingContext2D.h"
#include "modules/compositorworker/CompositorWorkerThread.h"
#include "modules/csspaint/CSSPaintImageGeneratorImpl.h"
#include "modules/document_metadata/CopylessPasteServer.h"
#include "modules/filesystem/DraggedIsolatedFileSystemImpl.h"
#include "modules/imagebitmap/ImageBitmapRenderingContext.h"
#include "modules/installation/InstallationServiceImpl.h"
......@@ -83,6 +84,10 @@ void ModulesInitializer::initialize() {
// Mojo Interfaces registered with LocalFrame
LocalFrame::registerInitializationCallback([](LocalFrame* frame) {
if (frame && frame->isMainFrame()) {
frame->interfaceRegistry()->addInterface(WTF::bind(
&CopylessPasteServer::bindMojoRequest, wrapWeakPersistent(frame)));
}
frame->interfaceRegistry()->addInterface(
WTF::bind(&InstallationServiceImpl::create, wrapWeakPersistent(frame)));
// TODO(dominickn): This interface should be document-scoped rather than
......
......@@ -8,6 +8,8 @@ blink_modules_sources("document_metadata") {
sources = [
"CopylessPasteExtractor.cpp",
"CopylessPasteExtractor.h",
"CopylessPasteServer.cpp",
"CopylessPasteServer.h",
]
deps = []
......
// 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::document_metadata::blink::CopylessPasteRequest request) {
DCHECK(frame);
// TODO(wychen): remove bindMojoRequest pattern, and make this a service
// associated with frame lifetime.
mojo::MakeStrongBinding(WTF::makeUnique<CopylessPasteServer>(*frame),
std::move(request));
}
void CopylessPasteServer::GetEntities(const GetEntitiesCallback& callback) {
if (!m_frame || !m_frame->document()) {
callback.Run(nullptr);
return;
}
// TODO(wychen): connect with CopylessPasteExtractor::extract() like:
// callback.Run(CopylessPasteExtractor::extract(*m_frame->document()));
callback.Run(nullptr);
}
} // namespace blink
// 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.
#ifndef CopylessPasteServer_h
#define CopylessPasteServer_h
#include "modules/ModulesExport.h"
#include "platform/heap/Persistent.h"
#include "public/platform/modules/document_metadata/copyless_paste.mojom-blink.h"
namespace blink {
class LocalFrame;
// Mojo interface to return extracted metadata for AppIndexing.
class MODULES_EXPORT CopylessPasteServer final
: public mojom::document_metadata::blink::CopylessPaste {
public:
explicit CopylessPasteServer(LocalFrame&);
static void bindMojoRequest(
LocalFrame*,
mojom::document_metadata::blink::CopylessPasteRequest);
void GetEntities(const GetEntitiesCallback&) override;
private:
WeakPersistent<LocalFrame> m_frame;
};
} // namespace blink
#endif // CopylessPasteServer_h
include_rules = [
"+mojo/public/cpp/bindings/binding.h",
"+mojo/public/cpp/bindings/strong_binding.h",
]
......@@ -34,3 +34,8 @@ struct WebPage {
string title;
array<Entity> entities;
};
// Null page denotes no results.
interface CopylessPaste {
GetEntities() => (WebPage? page);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment