mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-09 13:18:29 +08:00
For all comments that contained both the unrestricted annotation and any other potential annotation, remove only the unrestricted annotation. R=szuend@chromium.org No-Presubmit: True Bug: 1011811 Change-Id: I27dd67f657cdb1a9233d768eea81cabe2591f5f7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2569759 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
// Copyright 2014 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.
|
|
|
|
import * as Common from '../common/common.js'; // eslint-disable-line no-unused-vars
|
|
|
|
import {ContentProvider, DeferredContent, SearchMatch} from './ContentProvider.js'; // eslint-disable-line no-unused-vars
|
|
import {performSearchInContent} from './TextUtils.js';
|
|
|
|
/**
|
|
* @implements {ContentProvider}
|
|
*/
|
|
export class StaticContentProvider {
|
|
/**
|
|
* @param {string} contentURL
|
|
* @param {!Common.ResourceType.ResourceType} contentType
|
|
* @param {function():!Promise<!DeferredContent>} lazyContent
|
|
*/
|
|
constructor(contentURL, contentType, lazyContent) {
|
|
this._contentURL = contentURL;
|
|
this._contentType = contentType;
|
|
this._lazyContent = lazyContent;
|
|
}
|
|
|
|
/**
|
|
* @param {string} contentURL
|
|
* @param {!Common.ResourceType.ResourceType} contentType
|
|
* @param {string} content
|
|
* @return {!StaticContentProvider}
|
|
*/
|
|
static fromString(contentURL, contentType, content) {
|
|
const lazyContent = () => Promise.resolve({content, isEncoded: false});
|
|
return new StaticContentProvider(contentURL, contentType, lazyContent);
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {string}
|
|
*/
|
|
contentURL() {
|
|
return this._contentURL;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {!Common.ResourceType.ResourceType}
|
|
*/
|
|
contentType() {
|
|
return this._contentType;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {!Promise<boolean>}
|
|
*/
|
|
contentEncoded() {
|
|
return Promise.resolve(false);
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {!Promise<!DeferredContent>}
|
|
*/
|
|
requestContent() {
|
|
return this._lazyContent();
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {string} query
|
|
* @param {boolean} caseSensitive
|
|
* @param {boolean} isRegex
|
|
* @return {!Promise<!Array<!SearchMatch>>}
|
|
*/
|
|
async searchInContent(query, caseSensitive, isRegex) {
|
|
const {content} = /** @type { {content: string, isEncoded: boolean} }*/ (await this._lazyContent());
|
|
return content ? performSearchInContent(content, query, caseSensitive, isRegex) : [];
|
|
}
|
|
}
|