Commit 831241e7 authored by Ingvar Stepanyan's avatar Ingvar Stepanyan Committed by Commit Bot

Enable copyText in hosted mode

Now that new clipboard API is available in stable Chrome, it can be used
to enable copy actions by default even in hosted mode.

Change-Id: Ifacb15f7db990c03df21f97560a6e81e9b7746f0
Reviewed-on: https://chromium-review.googlesource.com/1068946Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565076}
parent 9b8061fe
...@@ -1027,3 +1027,17 @@ DetailsRenderer.NodeDetailsJSON; ...@@ -1027,3 +1027,17 @@ DetailsRenderer.NodeDetailsJSON;
* }} * }}
*/ */
DetailsRenderer.OpportunitySummary; DetailsRenderer.OpportunitySummary;
// Clipboard API
/** @constructor */
const Clipboard = function() {};
/**
* @param {string} data
* @return {!Promise}
*/
Clipboard.prototype.writeText = function(data) {};
/** @type {Clipboard} */
Navigator.prototype.clipboard;
...@@ -157,9 +157,21 @@ Host.InspectorFrontendHostStub = class { ...@@ -157,9 +157,21 @@ Host.InspectorFrontendHostStub = class {
/** /**
* @override * @override
* @param {string} text * @param {string} text
* @suppressGlobalPropertiesCheck
*/ */
copyText(text) { copyText(text) {
Common.console.error('Clipboard is not enabled in hosted mode. Please inspect using chrome://inspect'); if (navigator.clipboard) {
navigator.clipboard.writeText(text);
} else if (document.queryCommandSupported('copy')) {
const input = document.createElement('input');
input.value = text;
document.body.appendChild(input);
input.select();
document.execCommand('copy');
document.body.removeChild(input);
} else {
Common.console.error('Clipboard is not enabled in hosted mode. Please inspect using chrome://inspect');
}
} }
/** /**
......
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