Chromium Code Reviews| Index: content/browser/renderer_host/input/gestures/zoom_manager.h |
| diff --git a/content/browser/renderer_host/input/gestures/zoom_manager.h b/content/browser/renderer_host/input/gestures/zoom_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4d038574a093469c17ace6e4e2642e824960e995 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/gestures/zoom_manager.h |
| @@ -0,0 +1,64 @@ |
| +// 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. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_ZOOM_MANAGER_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_ZOOM_MANAGER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/browser/renderer_host/input/gestures/scale_gesture_detector.h" |
| + |
| +namespace content { |
| + |
| +// Port of ZoomManager.java from Chromium |
| +// * Changes to this class should be cosmetic only, easing fork maintenance. |
|
tdresser
2014/01/08 19:18:21
Will we still need the java version of ZoomManager
|
| +// Responsible for maintaining zoom state and processing scale-related gestures. |
| +class ZoomManager : public ScaleGestureDetector::OnScaleGestureListener { |
| + public: |
| + ZoomManager(ScaleGestureDetector::Config config, |
| + ScaleGestureDetector::OnScaleGestureListener* listener); |
| + virtual ~ZoomManager(); |
| + |
| + // Passes the touch event to ScaleGestureDetector so that its internal |
| + // state won't go wrong, but instructs the listener to ignore the result |
| + // of processing, if any. |
| + void PassTouchEventThrough(const MotionEvent& event); |
| + |
| + // Passes the touch event to ScaleGestureDetector so that its internal state |
| + // won't go wrong. ScaleGestureDetector needs two pointers in a MotionEvent |
| + // to recognize a zoom gesture. |
| + bool ProcessTouchEvent(const MotionEvent& event); |
| + |
| + void UpdateMultiTouchSupport(bool supports_multi_touch_zoom); |
| + |
| + bool IsScaleGestureDetectionInProgress() const; |
| + |
| + private: |
| + // OnScaleGestureListener |
| + virtual bool OnScaleBegin(const ScaleGestureDetector& detector) OVERRIDE; |
| + virtual void OnScaleEnd(const ScaleGestureDetector& detector) OVERRIDE; |
| + virtual bool OnScale(const ScaleGestureDetector& detector) OVERRIDE; |
| + |
| + bool IgnoreDetectorEvents() const; |
| + |
| + scoped_ptr<ScaleGestureDetector> multi_touch_detector_; |
| + |
| + ScaleGestureDetector::OnScaleGestureListener* const listener_; |
| + |
| + // Completely silence scaling events. Used in WebView when zoom support |
| + // is turned off. |
| + bool permanently_ignore_detector_events_; |
| + |
| + // Bypass events through the detector to maintain its state. Used when |
| + // renderes already handles the touch event. |
| + bool temporarily_ignore_detector_events_; |
| + |
| + // Whether any pinch zoom event has been sent to native. |
| + bool pinch_event_sent_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ZoomManager); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURES_ZOOM_MANAGER_H_ |