Commit afede465 authored by Patrick Noland's avatar Patrick Noland Committed by Commit Bot

Revert "Rename CopylessPaste to DocumentMetadata to reuse the class for other purposes"

This reverts commit da0bf646.

Reason for revert: Breaks the downstream clank build

Original change's description:
> Rename CopylessPaste to DocumentMetadata to reuse the class for other purposes
> 
> Bug: 1044244
> Change-Id: I7af8208b8c5a25f247b09cc0cbe55d44934f1d2d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020604
> Reviewed-by: Becca Hughes <beccahughes@chromium.org>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Commit-Queue: Sam Bowen <sgbowen@google.com>
> Cr-Commit-Position: refs/heads/master@{#735612}

TBR=dcheng@chromium.org,haraken@chromium.org,beccahughes@chromium.org,sgbowen@google.com

Change-Id: I0cdec26603543fe5f50140c7e8bee9988229e36d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1044244
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024073Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735651}
parent 4e1db37e
...@@ -15,8 +15,8 @@ import androidx.annotation.VisibleForTesting; ...@@ -15,8 +15,8 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.SysUtils; import org.chromium.base.SysUtils;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.blink.mojom.DocumentMetadata; import org.chromium.blink.mojom.document_metadata.CopylessPaste;
import org.chromium.blink.mojom.WebPage; import org.chromium.blink.mojom.document_metadata.WebPage;
import org.chromium.chrome.browser.historyreport.AppIndexingReporter; import org.chromium.chrome.browser.historyreport.AppIndexingReporter;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
...@@ -59,7 +59,7 @@ public class AppIndexingUtil { ...@@ -59,7 +59,7 @@ public class AppIndexingUtil {
mObserver = new TabModelSelectorTabObserver(mTabModelSelectorImpl) { mObserver = new TabModelSelectorTabObserver(mTabModelSelectorImpl) {
@Override @Override
public void onPageLoadFinished(final Tab tab, String url) { public void onPageLoadFinished(final Tab tab, String url) {
extractDocumentMetadata(tab); extractCopylessPasteMetadata(tab);
} }
@Override @Override
...@@ -80,7 +80,7 @@ public class AppIndexingUtil { ...@@ -80,7 +80,7 @@ public class AppIndexingUtil {
* title of the page is reported to App Indexing. * title of the page is reported to App Indexing.
*/ */
@VisibleForTesting @VisibleForTesting
void extractDocumentMetadata(final Tab tab) { void extractCopylessPasteMetadata(final Tab tab) {
if (!isEnabledForTab(tab)) return; if (!isEnabledForTab(tab)) return;
// There are three conditions that can occur with respect to the cache. // There are three conditions that can occur with respect to the cache.
...@@ -103,12 +103,12 @@ public class AppIndexingUtil { ...@@ -103,12 +103,12 @@ public class AppIndexingUtil {
// Condition 3 // Condition 3
RecordHistogram.recordEnumeratedHistogram( RecordHistogram.recordEnumeratedHistogram(
"CopylessPaste.CacheHit", CacheHit.MISS, CacheHit.NUM_ENTRIES); "CopylessPaste.CacheHit", CacheHit.MISS, CacheHit.NUM_ENTRIES);
DocumentMetadata documentMetadata = getDocumentMetadataInterface(tab); CopylessPaste copylessPaste = getCopylessPasteInterface(tab);
if (documentMetadata == null) { if (copylessPaste == null) {
return; return;
} }
documentMetadata.getEntities(webpage -> { copylessPaste.getEntities(webpage -> {
documentMetadata.close(); copylessPaste.close();
putCacheEntry(url, webpage != null); putCacheEntry(url, webpage != null);
if (sCallbackForTesting != null) { if (sCallbackForTesting != null) {
sCallbackForTesting.onResult(webpage); sCallbackForTesting.onResult(webpage);
...@@ -165,7 +165,7 @@ public class AppIndexingUtil { ...@@ -165,7 +165,7 @@ public class AppIndexingUtil {
} }
@VisibleForTesting @VisibleForTesting
DocumentMetadata getDocumentMetadataInterface(Tab tab) { CopylessPaste getCopylessPasteInterface(Tab tab) {
WebContents webContents = tab.getWebContents(); WebContents webContents = tab.getWebContents();
if (webContents == null) return null; if (webContents == null) return null;
...@@ -175,7 +175,7 @@ public class AppIndexingUtil { ...@@ -175,7 +175,7 @@ public class AppIndexingUtil {
InterfaceProvider interfaces = mainFrame.getRemoteInterfaces(); InterfaceProvider interfaces = mainFrame.getRemoteInterfaces();
if (interfaces == null) return null; if (interfaces == null) return null;
return interfaces.getInterface(DocumentMetadata.MANAGER); return interfaces.getInterface(CopylessPaste.MANAGER);
} }
@VisibleForTesting @VisibleForTesting
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
package org.chromium.chrome.browser.historyreport; package org.chromium.chrome.browser.historyreport;
import org.chromium.blink.mojom.WebPage; import org.chromium.blink.mojom.document_metadata.WebPage;
import org.chromium.chrome.browser.AppHooks; import org.chromium.chrome.browser.AppHooks;
/** Base class for reporting entities to App Indexing. */ /** Base class for reporting entities to App Indexing. */
......
...@@ -19,10 +19,10 @@ import org.chromium.base.test.util.CommandLineFlags; ...@@ -19,10 +19,10 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.RetryOnFailure; import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.blink.mojom.Entity; import org.chromium.blink.mojom.document_metadata.Entity;
import org.chromium.blink.mojom.Property; import org.chromium.blink.mojom.document_metadata.Property;
import org.chromium.blink.mojom.Values; import org.chromium.blink.mojom.document_metadata.Values;
import org.chromium.blink.mojom.WebPage; import org.chromium.blink.mojom.document_metadata.WebPage;
import org.chromium.chrome.browser.firstrun.FirstRunStatus; import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.util.UrlConstants; import org.chromium.chrome.browser.util.UrlConstants;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
......
...@@ -24,8 +24,8 @@ import org.robolectric.annotation.Config; ...@@ -24,8 +24,8 @@ import org.robolectric.annotation.Config;
import org.chromium.base.metrics.test.DisableHistogramsRule; import org.chromium.base.metrics.test.DisableHistogramsRule;
import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.blink.mojom.DocumentMetadata; import org.chromium.blink.mojom.document_metadata.CopylessPaste;
import org.chromium.blink.mojom.WebPage; import org.chromium.blink.mojom.document_metadata.WebPage;
import org.chromium.chrome.browser.historyreport.AppIndexingReporter; import org.chromium.chrome.browser.historyreport.AppIndexingReporter;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.url.mojom.Url; import org.chromium.url.mojom.Url;
...@@ -43,7 +43,7 @@ public class AppIndexingUtilTest { ...@@ -43,7 +43,7 @@ public class AppIndexingUtilTest {
@Mock @Mock
private AppIndexingReporter mReporter; private AppIndexingReporter mReporter;
@Mock @Mock
private DocumentMetadataTestImpl mDocumentMetadata; private CopylessPasteTestImpl mCopylessPaste;
@Mock @Mock
private Tab mTab; private Tab mTab;
...@@ -51,7 +51,7 @@ public class AppIndexingUtilTest { ...@@ -51,7 +51,7 @@ public class AppIndexingUtilTest {
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
doReturn(mReporter).when(mUtil).getAppIndexingReporter(); doReturn(mReporter).when(mUtil).getAppIndexingReporter();
doReturn(mDocumentMetadata).when(mUtil).getDocumentMetadataInterface(any(Tab.class)); doReturn(mCopylessPaste).when(mUtil).getCopylessPasteInterface(any(Tab.class));
doReturn(true).when(mUtil).isEnabledForDevice(); doReturn(true).when(mUtil).isEnabledForDevice();
doReturn(false).when(mTab).isIncognito(); doReturn(false).when(mTab).isIncognito();
...@@ -59,73 +59,67 @@ public class AppIndexingUtilTest { ...@@ -59,73 +59,67 @@ public class AppIndexingUtilTest {
doReturn("My neat website").when(mTab).getTitle(); doReturn("My neat website").when(mTab).getTitle();
doReturn(0L).when(mUtil).getElapsedTime(); doReturn(0L).when(mUtil).getElapsedTime();
doAnswer(invocation -> { doAnswer(invocation -> {
DocumentMetadata.GetEntitiesResponse callback = CopylessPaste.GetEntitiesResponse callback =
(DocumentMetadata.GetEntitiesResponse) invocation.getArguments()[0]; (CopylessPaste.GetEntitiesResponse) invocation.getArguments()[0];
WebPage webpage = new WebPage(); WebPage webpage = new WebPage();
webpage.url = createUrl("http://www.test.com"); webpage.url = createUrl("http://www.test.com");
webpage.title = "My neat website"; webpage.title = "My neat website";
callback.call(webpage); callback.call(webpage);
return null; return null;
}) }).when(mCopylessPaste).getEntities(any(CopylessPaste.GetEntitiesResponse.class));
.when(mDocumentMetadata)
.getEntities(any(DocumentMetadata.GetEntitiesResponse.class));
} }
@Test @Test
public void testExtractDocumentMetadata_Incognito() { public void testExtractCopylessPasteMetadata_Incognito() {
doReturn(true).when(mTab).isIncognito(); doReturn(true).when(mTab).isIncognito();
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
verify(mDocumentMetadata, never()).getEntities(any()); verify(mCopylessPaste, never()).getEntities(any());
verify(mReporter, never()).reportWebPage(any()); verify(mReporter, never()).reportWebPage(any());
} }
@Test @Test
public void testExtractDocumentMetadata_NoCacheHit() { public void testExtractCopylessPasteMetadata_NoCacheHit() {
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
verify(mDocumentMetadata).getEntities(any(DocumentMetadata.GetEntitiesResponse.class)); verify(mCopylessPaste).getEntities(any(CopylessPaste.GetEntitiesResponse.class));
verify(mReporter).reportWebPage(any(WebPage.class)); verify(mReporter).reportWebPage(any(WebPage.class));
} }
@Test @Test
public void testExtractDocumentMetadata_CacheHit() { public void testExtractCopylessPasteMetadata_CacheHit() {
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
verify(mDocumentMetadata).getEntities(any(DocumentMetadata.GetEntitiesResponse.class)); verify(mCopylessPaste).getEntities(any(CopylessPaste.GetEntitiesResponse.class));
verify(mDocumentMetadata).close(); verify(mCopylessPaste).close();
verify(mReporter).reportWebPage(any(WebPage.class)); verify(mReporter).reportWebPage(any(WebPage.class));
doReturn(1L).when(mUtil).getElapsedTime(); doReturn(1L).when(mUtil).getElapsedTime();
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
verifyNoMoreInteractions(mDocumentMetadata); verifyNoMoreInteractions(mCopylessPaste);
verifyNoMoreInteractions(mReporter); verifyNoMoreInteractions(mReporter);
} }
@Test @Test
public void testExtractDocumentMetadata_CacheHit_Expired() { public void testExtractCopylessPasteMetadata_CacheHit_Expired() {
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
doReturn(60 * 60 * 1000L + 1).when(mUtil).getElapsedTime(); doReturn(60 * 60 * 1000L + 1).when(mUtil).getElapsedTime();
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
verify(mDocumentMetadata, times(2)) verify(mCopylessPaste, times(2)).getEntities(any(CopylessPaste.GetEntitiesResponse.class));
.getEntities(any(DocumentMetadata.GetEntitiesResponse.class));
} }
@Test @Test
public void testExtractDocumentMetadata_CacheHit_NoEntity() { public void testExtractCopylessPasteMetadata_CacheHit_NoEntity() {
doAnswer(invocation -> { doAnswer(invocation -> {
DocumentMetadata.GetEntitiesResponse callback = CopylessPaste.GetEntitiesResponse callback =
(DocumentMetadata.GetEntitiesResponse) invocation.getArguments()[0]; (CopylessPaste.GetEntitiesResponse) invocation.getArguments()[0];
callback.call(null); callback.call(null);
return null; return null;
}) }).when(mCopylessPaste).getEntities(any(CopylessPaste.GetEntitiesResponse.class));
.when(mDocumentMetadata) mUtil.extractCopylessPasteMetadata(mTab);
.getEntities(any(DocumentMetadata.GetEntitiesResponse.class));
mUtil.extractDocumentMetadata(mTab);
doReturn(1L).when(mUtil).getElapsedTime(); doReturn(1L).when(mUtil).getElapsedTime();
mUtil.extractDocumentMetadata(mTab); mUtil.extractCopylessPasteMetadata(mTab);
verify(mDocumentMetadata, times(1)) verify(mCopylessPaste, times(1)).getEntities(any(CopylessPaste.GetEntitiesResponse.class));
.getEntities(any(DocumentMetadata.GetEntitiesResponse.class));
verifyNoMoreInteractions(mReporter); verifyNoMoreInteractions(mReporter);
} }
...@@ -149,5 +143,5 @@ public class AppIndexingUtilTest { ...@@ -149,5 +143,5 @@ public class AppIndexingUtilTest {
return url; return url;
} }
abstract static class DocumentMetadataTestImpl implements DocumentMetadata {} abstract static class CopylessPasteTestImpl implements CopylessPaste {}
} }
...@@ -233,7 +233,7 @@ mojom("android_mojo_bindings") { ...@@ -233,7 +233,7 @@ mojom("android_mojo_bindings") {
"blob/blob_url_store.mojom", "blob/blob_url_store.mojom",
"blob/data_element.mojom", "blob/data_element.mojom",
"blob/serialized_blob.mojom", "blob/serialized_blob.mojom",
"document_metadata/document_metadata.mojom", "document_metadata/copyless_paste.mojom",
"font_unique_name_lookup/font_unique_name_lookup.mojom", "font_unique_name_lookup/font_unique_name_lookup.mojom",
"input/input_host.mojom", "input/input_host.mojom",
"input/input_messages.mojom", "input/input_messages.mojom",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
module blink.mojom; module blink.mojom.document_metadata;
import "url/mojom/url.mojom"; import "url/mojom/url.mojom";
...@@ -36,6 +36,6 @@ struct WebPage { ...@@ -36,6 +36,6 @@ struct WebPage {
}; };
// Null page denotes no results. // Null page denotes no results.
interface DocumentMetadata { interface CopylessPaste {
GetEntities() => (WebPage? page); GetEntities() => (WebPage? page);
}; };
...@@ -279,7 +279,7 @@ jumbo_source_set("unit_tests") { ...@@ -279,7 +279,7 @@ jumbo_source_set("unit_tests") {
"csspaint/paint_worklet_test.cc", "csspaint/paint_worklet_test.cc",
"device_orientation/device_motion_event_pump_unittest.cc", "device_orientation/device_motion_event_pump_unittest.cc",
"device_orientation/device_orientation_event_pump_unittest.cc", "device_orientation/device_orientation_event_pump_unittest.cc",
"document_metadata/document_metadata_extractor_test.cc", "document_metadata/copyless_paste_extractor_test.cc",
"eventsource/event_source_parser_test.cc", "eventsource/event_source_parser_test.cc",
"filesystem/dom_file_system_base_test.cc", "filesystem/dom_file_system_base_test.cc",
"filesystem/file_writer_test.cc", "filesystem/file_writer_test.cc",
......
# Copyright 2017 The Chromium Authors.All rights reserved. # Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -6,10 +6,10 @@ import("//third_party/blink/renderer/modules/modules.gni") ...@@ -6,10 +6,10 @@ import("//third_party/blink/renderer/modules/modules.gni")
blink_modules_sources("document_metadata") { blink_modules_sources("document_metadata") {
sources = [ sources = [
"document_metadata_extractor.cc", "copyless_paste_extractor.cc",
"document_metadata_extractor.h", "copyless_paste_extractor.h",
"document_metadata_server.cc", "copyless_paste_server.cc",
"document_metadata_server.h", "copyless_paste_server.h",
] ]
deps = [] deps = []
......
beccahughes@chromium.org
steimel@chromium.org
sgbowen@google.com
# COMPONENT: Blink>Media>Session
# TEAM: media-dev@chromium.org
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/modules/document_metadata/document_metadata_extractor.h" #include "third_party/blink/renderer/modules/document_metadata/copyless_paste_extractor.h"
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "third_party/blink/public/mojom/document_metadata/document_metadata.mojom-blink.h" #include "third_party/blink/public/mojom/document_metadata/copyless_paste.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h" #include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
...@@ -26,14 +26,14 @@ namespace blink { ...@@ -26,14 +26,14 @@ namespace blink {
namespace { namespace {
using mojom::blink::Entity; using mojom::document_metadata::blink::Entity;
using mojom::blink::EntityPtr; using mojom::document_metadata::blink::EntityPtr;
using mojom::blink::Property; using mojom::document_metadata::blink::Property;
using mojom::blink::PropertyPtr; using mojom::document_metadata::blink::PropertyPtr;
using mojom::blink::Values; using mojom::document_metadata::blink::Values;
using mojom::blink::ValuesPtr; using mojom::document_metadata::blink::ValuesPtr;
using mojom::blink::WebPage; using mojom::document_metadata::blink::WebPage;
using mojom::blink::WebPagePtr; using mojom::document_metadata::blink::WebPagePtr;
// App Indexing enforces a max nesting depth of 5. Our top level message // App Indexing enforces a max nesting depth of 5. Our top level message
// corresponds to the WebPage, so this only leaves 4 more levels. We will parse // corresponds to the WebPage, so this only leaves 4 more levels. We will parse
...@@ -284,8 +284,8 @@ ExtractionStatus ExtractMetadata(const Element& root, ...@@ -284,8 +284,8 @@ ExtractionStatus ExtractMetadata(const Element& root,
} // namespace } // namespace
WebPagePtr DocumentMetadataExtractor::Extract(const Document& document) { WebPagePtr CopylessPasteExtractor::Extract(const Document& document) {
TRACE_EVENT0("blink", "DocumentMetadataExtractor::Extract"); TRACE_EVENT0("blink", "CopylessPasteExtractor::Extract");
if (!document.GetFrame() || !document.GetFrame()->IsMainFrame()) if (!document.GetFrame() || !document.GetFrame()->IsMainFrame())
return nullptr; return nullptr;
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_DOCUMENT_METADATA_EXTRACTOR_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_COPYLESS_PASTE_EXTRACTOR_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_DOCUMENT_METADATA_EXTRACTOR_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_COPYLESS_PASTE_EXTRACTOR_H_
#include "third_party/blink/public/mojom/document_metadata/document_metadata.mojom-blink-forward.h" #include "third_party/blink/public/mojom/document_metadata/copyless_paste.mojom-blink-forward.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
...@@ -13,15 +13,16 @@ namespace blink { ...@@ -13,15 +13,16 @@ namespace blink {
class Document; class Document;
// Extract structured metadata (currently schema.org in JSON-LD). The extraction // Extract structured metadata (currently schema.org in JSON-LD) for the
// must be done after the document has finished parsing. // Copyless Paste feature. The extraction must be done after the document
class MODULES_EXPORT DocumentMetadataExtractor final { // has finished parsing.
STATIC_ONLY(DocumentMetadataExtractor); class MODULES_EXPORT CopylessPasteExtractor final {
STATIC_ONLY(CopylessPasteExtractor);
public: public:
static mojom::blink::WebPagePtr Extract(const Document&); static mojom::document_metadata::blink::WebPagePtr Extract(const Document&);
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_DOCUMENT_METADATA_EXTRACTOR_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_COPYLESS_PASTE_EXTRACTOR_H_
...@@ -2,38 +2,38 @@ ...@@ -2,38 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/modules/document_metadata/document_metadata_server.h" #include "third_party/blink/renderer/modules/document_metadata/copyless_paste_server.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/document_metadata/document_metadata_extractor.h" #include "third_party/blink/renderer/modules/document_metadata/copyless_paste_extractor.h"
namespace blink { namespace blink {
DocumentMetadataServer::DocumentMetadataServer(LocalFrame& frame) CopylessPasteServer::CopylessPasteServer(LocalFrame& frame) : frame_(frame) {}
: frame_(frame) {}
void DocumentMetadataServer::BindMojoReceiver( void CopylessPasteServer::BindMojoReceiver(
LocalFrame* frame, LocalFrame* frame,
mojo::PendingReceiver<mojom::blink::DocumentMetadata> receiver) { mojo::PendingReceiver<mojom::document_metadata::blink::CopylessPaste>
receiver) {
DCHECK(frame); DCHECK(frame);
// TODO(wychen): remove BindMojoReceiver pattern, and make this a service // TODO(wychen): remove BindMojoReceiver pattern, and make this a service
// associated with frame lifetime. // associated with frame lifetime.
mojo::MakeSelfOwnedReceiver(std::make_unique<DocumentMetadataServer>(*frame), mojo::MakeSelfOwnedReceiver(std::make_unique<CopylessPasteServer>(*frame),
std::move(receiver)); std::move(receiver));
} }
void DocumentMetadataServer::GetEntities(GetEntitiesCallback callback) { void CopylessPasteServer::GetEntities(GetEntitiesCallback callback) {
if (!frame_ || !frame_->GetDocument()) { if (!frame_ || !frame_->GetDocument()) {
std::move(callback).Run(nullptr); std::move(callback).Run(nullptr);
return; return;
} }
std::move(callback).Run( std::move(callback).Run(
DocumentMetadataExtractor::Extract(*frame_->GetDocument())); CopylessPasteExtractor::Extract(*frame_->GetDocument()));
} }
} // namespace blink } // namespace blink
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_DOCUMENT_METADATA_SERVER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_COPYLESS_PASTE_SERVER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_DOCUMENT_METADATA_SERVER_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_COPYLESS_PASTE_SERVER_H_
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/document_metadata/document_metadata.mojom-blink.h" #include "third_party/blink/public/mojom/document_metadata/copyless_paste.mojom-blink.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/platform/heap/persistent.h" #include "third_party/blink/renderer/platform/heap/persistent.h"
...@@ -15,14 +15,14 @@ namespace blink { ...@@ -15,14 +15,14 @@ namespace blink {
class LocalFrame; class LocalFrame;
// Mojo interface to return extracted metadata for AppIndexing. // Mojo interface to return extracted metadata for AppIndexing.
class MODULES_EXPORT DocumentMetadataServer final class MODULES_EXPORT CopylessPasteServer final
: public mojom::blink::DocumentMetadata { : public mojom::document_metadata::blink::CopylessPaste {
public: public:
explicit DocumentMetadataServer(LocalFrame&); explicit CopylessPasteServer(LocalFrame&);
static void BindMojoReceiver( static void BindMojoReceiver(
LocalFrame*, LocalFrame*,
mojo::PendingReceiver<mojom::blink::DocumentMetadata>); mojo::PendingReceiver<mojom::document_metadata::blink::CopylessPaste>);
void GetEntities(GetEntitiesCallback) override; void GetEntities(GetEntitiesCallback) override;
...@@ -32,4 +32,4 @@ class MODULES_EXPORT DocumentMetadataServer final ...@@ -32,4 +32,4 @@ class MODULES_EXPORT DocumentMetadataServer final
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_DOCUMENT_METADATA_SERVER_H_ #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_DOCUMENT_METADATA_COPYLESS_PASTE_SERVER_H_
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "third_party/blink/renderer/modules/device_orientation/device_orientation_absolute_controller.h" #include "third_party/blink/renderer/modules/device_orientation/device_orientation_absolute_controller.h"
#include "third_party/blink/renderer/modules/device_orientation/device_orientation_controller.h" #include "third_party/blink/renderer/modules/device_orientation/device_orientation_controller.h"
#include "third_party/blink/renderer/modules/device_orientation/device_orientation_inspector_agent.h" #include "third_party/blink/renderer/modules/device_orientation/device_orientation_inspector_agent.h"
#include "third_party/blink/renderer/modules/document_metadata/document_metadata_server.h" #include "third_party/blink/renderer/modules/document_metadata/copyless_paste_server.h"
#include "third_party/blink/renderer/modules/encryptedmedia/html_media_element_encrypted_media.h" #include "third_party/blink/renderer/modules/encryptedmedia/html_media_element_encrypted_media.h"
#include "third_party/blink/renderer/modules/encryptedmedia/media_keys_controller.h" #include "third_party/blink/renderer/modules/encryptedmedia/media_keys_controller.h"
#include "third_party/blink/renderer/modules/event_interface_modules_names.h" #include "third_party/blink/renderer/modules/event_interface_modules_names.h"
...@@ -160,7 +160,7 @@ void ModulesInitializer::Initialize() { ...@@ -160,7 +160,7 @@ void ModulesInitializer::Initialize() {
void ModulesInitializer::InitLocalFrame(LocalFrame& frame) const { void ModulesInitializer::InitLocalFrame(LocalFrame& frame) const {
if (frame.IsMainFrame()) { if (frame.IsMainFrame()) {
frame.GetInterfaceRegistry()->AddInterface(WTF::BindRepeating( frame.GetInterfaceRegistry()->AddInterface(WTF::BindRepeating(
&DocumentMetadataServer::BindMojoReceiver, WrapWeakPersistent(&frame))); &CopylessPasteServer::BindMojoReceiver, WrapWeakPersistent(&frame)));
} }
if (RuntimeEnabledFeatures::FileHandlingEnabled(frame.GetDocument())) { if (RuntimeEnabledFeatures::FileHandlingEnabled(frame.GetDocument())) {
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating( frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
......
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