Commit 9c6a91f6 authored by Collin Baker's avatar Collin Baker Committed by Commit Bot

Enable touch drag-and-drop in WebUI tab strip

Touch drag-and-drop is enabled or disabled through WebPreferences
instead of a switch check in the renderer. The setting defaults to
the switch state but can be overridden.

The WebUI tab strip enables it always.

Bug: 229301
Change-Id: Ie3be6167f3c3c5d1fe21beb0238d6b2e0bdf05fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270848Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788679}
parent 46a51f4e
...@@ -36,4 +36,5 @@ void ChromeContentBrowserClientTabStripPart::OverrideWebkitPrefs( ...@@ -36,4 +36,5 @@ void ChromeContentBrowserClientTabStripPart::OverrideWebkitPrefs(
web_prefs->minimum_font_size = default_prefs.minimum_font_size; web_prefs->minimum_font_size = default_prefs.minimum_font_size;
web_prefs->minimum_logical_font_size = web_prefs->minimum_logical_font_size =
default_prefs.minimum_logical_font_size; default_prefs.minimum_logical_font_size;
web_prefs->touch_drag_drop_enabled = true;
} }
...@@ -247,6 +247,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences) ...@@ -247,6 +247,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(lazy_image_first_k_fully_load) IPC_STRUCT_TRAITS_MEMBER(lazy_image_first_k_fully_load)
IPC_STRUCT_TRAITS_MEMBER(allow_mixed_content_upgrades) IPC_STRUCT_TRAITS_MEMBER(allow_mixed_content_upgrades)
IPC_STRUCT_TRAITS_MEMBER(always_show_focus) IPC_STRUCT_TRAITS_MEMBER(always_show_focus)
IPC_STRUCT_TRAITS_MEMBER(touch_drag_drop_enabled)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(blink::mojom::WindowFeatures) IPC_STRUCT_TRAITS_BEGIN(blink::mojom::WindowFeatures)
......
...@@ -8,9 +8,21 @@ ...@@ -8,9 +8,21 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "third_party/blink/public/web/web_settings.h" #include "third_party/blink/public/web/web_settings.h"
#include "ui/base/ui_base_switches_util.h"
using blink::WebSettings; using blink::WebSettings;
namespace {
bool IsTouchDragDropEnabled() {
// Cache the enabled state so it isn't queried on every WebPreferences
// creation. Note that this means unit tests can't override the state.
static const bool enabled = switches::IsTouchDragDropEnabled();
return enabled;
}
} // namespace
namespace content { namespace content {
// "Zyyy" is the ISO 15924 script code for undetermined script aka Common. // "Zyyy" is the ISO 15924 script code for undetermined script aka Common.
...@@ -228,7 +240,8 @@ WebPreferences::WebPreferences() ...@@ -228,7 +240,8 @@ WebPreferences::WebPreferences()
network_quality_estimator_web_holdback( network_quality_estimator_web_holdback(
net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN), net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
allow_mixed_content_upgrades(true), allow_mixed_content_upgrades(true),
always_show_focus(false) { always_show_focus(false),
touch_drag_drop_enabled(IsTouchDragDropEnabled()) {
standard_font_family_map[kCommonScript] = standard_font_family_map[kCommonScript] =
base::ASCIIToUTF16("Times New Roman"); base::ASCIIToUTF16("Times New Roman");
fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier New"); fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier New");
......
...@@ -360,6 +360,10 @@ struct CONTENT_EXPORT WebPreferences { ...@@ -360,6 +360,10 @@ struct CONTENT_EXPORT WebPreferences {
// forcing :focus-visible to match regardless of focus method). // forcing :focus-visible to match regardless of focus method).
bool always_show_focus; bool always_show_focus;
// Whether touch input can trigger HTML drag-and-drop operations. The
// default value depends on the platform.
bool touch_drag_drop_enabled;
// We try to keep the default values the same as the default values in // We try to keep the default values the same as the default values in
// chrome, except for the cases where it would require lots of extra work for // chrome, except for the cases where it would require lots of extra work for
// the embedder to use the same default value. // the embedder to use the same default value.
......
...@@ -351,9 +351,6 @@ void ApplyCommandLineToSettings(WebSettings* settings) { ...@@ -351,9 +351,6 @@ void ApplyCommandLineToSettings(WebSettings* settings) {
settings->SetThreadedScrollingEnabled( settings->SetThreadedScrollingEnabled(
!command_line.HasSwitch(switches::kDisableThreadedScrolling)); !command_line.HasSwitch(switches::kDisableThreadedScrolling));
if (switches::IsTouchDragDropEnabled())
settings->SetTouchDragDropEnabled(true);
WebSettings::SelectionStrategyType selection_strategy; WebSettings::SelectionStrategyType selection_strategy;
if (command_line.GetSwitchValueASCII(switches::kTouchTextSelectionStrategy) == if (command_line.GetSwitchValueASCII(switches::kTouchTextSelectionStrategy) ==
"direction") "direction")
...@@ -954,6 +951,8 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs, ...@@ -954,6 +951,8 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
NOTREACHED(); NOTREACHED();
} }
settings->SetTouchDragDropEnabled(prefs.touch_drag_drop_enabled);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
web_view->SetMaximumLegibleScale(prefs.default_maximum_page_scale_factor); web_view->SetMaximumLegibleScale(prefs.default_maximum_page_scale_factor);
#endif #endif
......
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