diff options
author | bokan@chromium.org <bokan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-05 21:48:17 +0000 |
---|---|---|
committer | bokan@chromium.org <bokan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-05 21:48:17 +0000 |
commit | bdc06d4e26e9835c8f6459ceaec2600907ab8a70 (patch) | |
tree | caa18758be1120c5520b53ff2bc381b0c3656286 | |
parent | d9413a3e9d350f5e7ec7fc19ad3576cad8ae6100 (diff) | |
download | chromium_src-bdc06d4e26e9835c8f6459ceaec2600907ab8a70.zip chromium_src-bdc06d4e26e9835c8f6459ceaec2600907ab8a70.tar.gz chromium_src-bdc06d4e26e9835c8f6459ceaec2600907ab8a70.tar.bz2 |
Enable pinch-to-zoom on CrOS by default.
Enabled old (Android-style) pinch-to-zoom by default in CrOS to match
Windows 8 change in r247390. Also made it so that it can be disabled
with --disable-pinch on both CrOS and Win8.
BUG=338498
Review URL: https://codereview.chromium.org/154403003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249124 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 34 insertions, 38 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 5d2626c..31b4d335 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -1481,11 +1481,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( chromeos::switches::kLoginProfile, login_profile); #endif -#if defined(OS_WIN) - if (base::win::GetVersion() >= base::win::VERSION_WIN8) - command_line->AppendSwitch(switches::kEnablePinch); -#endif - #if defined(ENABLE_WEBRTC) if (VersionInfo::GetChannel() <= VersionInfo::CHANNEL_DEV) { static const char* const kWebRtcDevSwitchNames[] = { diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc index 59d1af6..98409cd 100644 --- a/content/browser/frame_host/render_widget_host_view_guest.cc +++ b/content/browser/frame_host/render_widget_host_view_guest.cc @@ -22,10 +22,6 @@ #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_helper.h" #endif -#if defined(OS_WIN) -#include "base/win/windows_version.h" -#endif - #if defined(OS_WIN) || defined(USE_AURA) #include "content/browser/renderer_host/ui_events_helper.h" #endif @@ -35,17 +31,6 @@ namespace content { namespace { #if defined(OS_WIN) || defined(USE_AURA) -bool ShouldSendPinchGesture() { -#if defined(OS_WIN) - if (base::win::GetVersion() >= base::win::VERSION_WIN8) - return true; -#endif - static bool pinch_allowed = - CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || - CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); - return pinch_allowed; -} - blink::WebGestureEvent CreateFlingCancelEvent(double time_stamp) { blink::WebGestureEvent gesture_event; gesture_event.timeStampSeconds = time_stamp; @@ -514,12 +499,9 @@ bool RenderWidgetHostViewGuest::ForwardGestureEventToRenderer( if (!host_) return false; - // Pinch gestures are disabled by default on windows desktop. See - // crbug.com/128477 and crbug.com/148816 if ((gesture->type() == ui::ET_GESTURE_PINCH_BEGIN || gesture->type() == ui::ET_GESTURE_PINCH_UPDATE || - gesture->type() == ui::ET_GESTURE_PINCH_END) && - !ShouldSendPinchGesture()) { + gesture->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { return true; } diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 69b342b..eb5d0d7 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -107,6 +107,7 @@ #include "content/browser/worker_host/worker_storage_partition.h" #include "content/common/child_process_host_impl.h" #include "content/common/child_process_messages.h" +#include "content/common/content_switches_internal.h" #include "content/common/gpu/gpu_messages.h" #include "content/common/resource_messages.h" #include "content/common/view_messages.h" @@ -939,6 +940,9 @@ void RenderProcessHostImpl::AppendRendererCommandLine( GetContentClient()->browser()->AppendExtraCommandLineSwitches( command_line, GetID()); + if (content::IsPinchToZoomEnabled()) + command_line->AppendSwitch(switches::kEnablePinch); + AppendGpuCommandLineFlags(command_line); } diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 3e4beaa..599f976 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -80,7 +80,6 @@ #include "ui/wm/public/window_types.h" #if defined(OS_WIN) -#include "base/win/windows_version.h" #include "content/browser/accessibility/browser_accessibility_manager_win.h" #include "content/browser/accessibility/browser_accessibility_win.h" #include "content/common/plugin_constants_win.h" @@ -296,17 +295,6 @@ void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) { results->deviceScaleFactor = display.device_scale_factor(); } -bool ShouldSendPinchGesture() { -#if defined(OS_WIN) - if (base::win::GetVersion() >= base::win::VERSION_WIN8) - return true; -#endif - static bool pinch_allowed = - CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableViewport) || - CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePinch); - return pinch_allowed; -} - bool PointerEventActivates(const ui::Event& event) { if (event.type() == ui::ET_MOUSE_PRESSED) return true; @@ -2992,10 +2980,9 @@ void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); - // Pinch gestures are currently disabled by default. See crbug.com/128477. if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || event->type() == ui::ET_GESTURE_PINCH_UPDATE || - event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { + event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { event->SetHandled(); return; } diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc index 3bf7b8f..d922c93 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc @@ -10,6 +10,7 @@ #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h" +#include "content/common/content_switches_internal.h" #include "content/port/browser/render_widget_host_view_frame_subscriber.h" #include "third_party/WebKit/public/platform/WebScreenInfo.h" #include "ui/gfx/display.h" @@ -390,6 +391,7 @@ RenderWidgetHostViewBase::RenderWidgetHostViewBase() selection_text_offset_(0), selection_range_(gfx::Range::InvalidRange()), current_device_scale_factor_(0), + pinch_zoom_enabled_(content::IsPinchToZoomEnabled()), renderer_frame_number_(0) { } diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index 5c852e5..67b2816 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -156,6 +156,10 @@ protected: // The scale factor of the display the renderer is currently on. float current_device_scale_factor_; + // Whether pinch-to-zoom should be enabled and pinch events forwarded to the + // renderer. + bool pinch_zoom_enabled_; + private: void FlushInput(); diff --git a/content/common/content_switches_internal.cc b/content/common/content_switches_internal.cc index b148772..28542e4 100644 --- a/content/common/content_switches_internal.cc +++ b/content/common/content_switches_internal.cc @@ -7,6 +7,10 @@ #include "base/command_line.h" #include "content/public/common/content_switches.h" +#if defined(OS_WIN) +#include "base/win/windows_version.h" +#endif + namespace content { bool IsOverlayScrollbarEnabled() { @@ -20,4 +24,21 @@ bool IsOverlayScrollbarEnabled() { return false; } +bool IsPinchToZoomEnabled() { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + // --disable-pinch should always disable pinch + if (command_line.HasSwitch(switches::kDisablePinch)) + return false; + +#if defined(OS_WIN) + return base::win::GetVersion() >= base::win::VERSION_WIN8; +#elif defined(OS_CHROMEOS) + return true; +#endif + + return command_line.HasSwitch(switches::kEnableViewport) || + command_line.HasSwitch(switches::kEnablePinch); +} + } // namespace content diff --git a/content/common/content_switches_internal.h b/content/common/content_switches_internal.h index 7bc7d73..8bfa25e 100644 --- a/content/common/content_switches_internal.h +++ b/content/common/content_switches_internal.h @@ -9,6 +9,7 @@ namespace content { // Should we use overlay scrollbars. bool IsOverlayScrollbarEnabled(); +bool IsPinchToZoomEnabled(); } // namespace content |