Commit 0729852d authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Only render img or table tags

For clipboard history, only render img or table tags
when a new flag is enabled. This flag will be enabled via
finch at a later date so we can compare usage.

Bug: 1131691
Change-Id: I21aa05c4daa5a80f0037c8507e0e32eda1f04bc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441258
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarDavid Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#812904}
parent f0a63ab9
......@@ -228,8 +228,10 @@ void ClipboardHistoryResourceManager::OnClipboardHistoryItemAdded(
const ClipboardHistoryItem& item) {
// For items that will be represented by their rendered HTML, we need to do
// some prep work to pre-render and cache an image model.
if (!item.data().bitmap().isNull() || item.data().markup_data().empty())
if (ClipboardHistoryUtil::CalculateMainFormat(item.data()) !=
ui::ClipboardInternalFormat::kHtml) {
return;
}
const auto& items = clipboard_history_->GetItems();
......
......@@ -9,6 +9,7 @@
#include "ash/clipboard/clipboard_history_item.h"
#include "ash/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chromeos/constants/chromeos_features.h"
#include "ui/base/clipboard/clipboard_data.h"
#include "ui/base/clipboard/custom_data_helper.h"
......@@ -31,8 +32,16 @@ constexpr ui::ClipboardInternalFormat kPrioritizedFormats[] = {
base::Optional<ui::ClipboardInternalFormat> CalculateMainFormat(
const ui::ClipboardData& data) {
for (const auto& format : kPrioritizedFormats) {
if (ContainsFormat(data, format))
if (ContainsFormat(data, format)) {
if (chromeos::features::IsClipboardHistorySimpleRenderEnabled()) {
if (format == ui::ClipboardInternalFormat::kHtml &&
(data.markup_data().find("<img") == std::string::npos) &&
(data.markup_data().find("<table") == std::string::npos)) {
continue;
}
}
return format;
}
}
return base::nullopt;
}
......
......@@ -2423,6 +2423,11 @@
"owners": ["newcomer@chromium.org", "tbarzic@chromium.org"],
"expiry_milestone": 90
},
{
"name": "enhanced_clipboard_simple_render",
"owners":["newcomer@chromium.org", "gzadina@google.com"],
"expiry_milestone": 90
},
{
"name": "enhanced-desk-animations",
"owners": ["sammiequon", "tclaiborne"],
......
......@@ -3901,6 +3901,12 @@ const char kEnhancedClipboardDescription[] =
"history. Selecting something from the menu will result in a paste to the "
"active window.";
const char kEnhancedClipboardSimpleRenderName[] =
"Only renders html in the Enhanced Clipboard if there are img or table "
"tags";
const char kEnhancedClipboardSimpleRenderDescription[] =
"This will result in less HTML rendering in the Enhanced Clipboard menu.";
const char kMultiDisplayOverviewAndSplitViewName[] =
"Enable multi-display overview and split view.";
const char kMultiDisplayOverviewAndSplitViewDescription[] =
......
......@@ -2246,6 +2246,9 @@ extern const char kDragToSnapInClamshellModeDescription[];
extern const char kEnhancedClipboardName[];
extern const char kEnhancedClipboardDescription[];
extern const char kEnhancedClipboardSimpleRenderName[];
extern const char kEnhancedClipboardSimpleRenderDescription[];
extern const char kMultiDisplayOverviewAndSplitViewName[];
extern const char kMultiDisplayOverviewAndSplitViewDescription[];
......
......@@ -302,6 +302,11 @@ const base::Feature kMojoDBusRelay{"MojoDBusRelay",
const base::Feature kClipboardHistory{"ClipboardHistory",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables rendering html in Clipboard History only if an img or table tag is
// present.
const base::Feature kClipboardHistorySimpleRender{
"ClipboardHistorySimpleRender", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables copying an image to the system clipboard to support pasting onto
// different surfaces
const base::Feature kEnableFilesAppCopyImage{"EnableFilesAppCopyImage",
......@@ -670,7 +675,12 @@ bool IsMinimumChromeVersionEnabled() {
}
bool IsClipboardHistoryEnabled() {
return base::FeatureList::IsEnabled(kClipboardHistory);
return base::FeatureList::IsEnabled(kClipboardHistory) ||
base::FeatureList::IsEnabled(kClipboardHistorySimpleRender);
}
bool IsClipboardHistorySimpleRenderEnabled() {
return base::FeatureList::IsEnabled(kClipboardHistorySimpleRender);
}
bool IsParentalControlsSettingsEnabled() {
......
......@@ -140,6 +140,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const base::Feature kMojoDBusRelay;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kClipboardHistory;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kClipboardHistorySimpleRender;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kEnableFilesAppCopyImage;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kEnableImeSandbox;
......@@ -295,6 +297,8 @@ bool IsLoginDeviceManagementDisclosureEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsLoginDisplayPasswordButtonEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsMinimumChromeVersionEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsClipboardHistoryEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
bool IsClipboardHistorySimpleRenderEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsOobeScreensPriorityEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsParentalControlsSettingsEnabled();
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) bool IsPhoneHubEnabled();
......
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