| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/android/overscroll_controller_android.h" | 5 #include "content/browser/android/overscroll_controller_android.h" |
| 6 | 6 |
| 7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| 11 #include "cc/output/compositor_frame_metadata.h" | 11 #include "cc/output/compositor_frame_metadata.h" |
| 12 #include "content/browser/android/content_view_core_impl.h" | |
| 13 #include "content/public/browser/navigation_controller.h" | 12 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/user_metrics.h" | 13 #include "content/public/browser/user_metrics.h" |
| 15 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 16 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 16 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 17 #include "ui/android/edge_effect.h" | 17 #include "ui/android/edge_effect.h" |
| 18 #include "ui/android/edge_effect_l.h" | 18 #include "ui/android/edge_effect_l.h" |
| 19 #include "ui/android/resources/resource_manager.h" | 19 #include "ui/android/resources/resource_manager.h" |
| 20 #include "ui/android/window_android.h" | 20 #include "ui/android/window_android.h" |
| 21 #include "ui/android/window_android_compositor.h" | 21 #include "ui/android/window_android_compositor.h" |
| 22 #include "ui/base/l10n/l10n_util_android.h" | 22 #include "ui/base/l10n/l10n_util_android.h" |
| 23 #include "ui/events/blink/did_overscroll_params.h" | 23 #include "ui/events/blink/did_overscroll_params.h" |
| 24 | 24 |
| 25 using ui::DidOverscrollParams; | 25 using ui::DidOverscrollParams; |
| 26 using ui::EdgeEffect; | 26 using ui::EdgeEffect; |
| 27 using ui::EdgeEffectBase; | 27 using ui::EdgeEffectBase; |
| 28 using ui::EdgeEffectL; | 28 using ui::EdgeEffectL; |
| 29 using ui::OverscrollGlow; | 29 using ui::OverscrollGlow; |
| 30 using ui::OverscrollGlowClient; | 30 using ui::OverscrollGlowClient; |
| 31 using ui::OverscrollRefresh; | 31 using ui::OverscrollRefresh; |
| 32 using ui::OverscrollRefreshHandler; | |
| 33 | 32 |
| 34 namespace content { | 33 namespace content { |
| 35 namespace { | 34 namespace { |
| 36 | 35 |
| 37 // Used for conditional creation of EdgeEffect types for the overscroll glow. | 36 // Used for conditional creation of EdgeEffect types for the overscroll glow. |
| 38 const int kAndroidLSDKVersion = 21; | 37 const int kAndroidLSDKVersion = 21; |
| 39 | 38 |
| 40 // If the glow effect alpha is greater than this value, the refresh effect will | 39 // If the glow effect alpha is greater than this value, the refresh effect will |
| 41 // be suppressed. This value was experimentally determined to provide a | 40 // be suppressed. This value was experimentally determined to provide a |
| 42 // reasonable balance between avoiding accidental refresh activation and | 41 // reasonable balance between avoiding accidental refresh activation and |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 float dpi_scale) { | 78 float dpi_scale) { |
| 80 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 79 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 81 switches::kDisableOverscrollEdgeEffect)) { | 80 switches::kDisableOverscrollEdgeEffect)) { |
| 82 return nullptr; | 81 return nullptr; |
| 83 } | 82 } |
| 84 | 83 |
| 85 return base::MakeUnique<OverscrollGlow>(client); | 84 return base::MakeUnique<OverscrollGlow>(client); |
| 86 } | 85 } |
| 87 | 86 |
| 88 std::unique_ptr<OverscrollRefresh> CreateRefreshEffect( | 87 std::unique_ptr<OverscrollRefresh> CreateRefreshEffect( |
| 89 OverscrollRefreshHandler* handler) { | 88 ui::OverscrollRefreshHandler* overscroll_refresh_handler) { |
| 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 89 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 91 switches::kDisablePullToRefreshEffect)) { | 90 switches::kDisablePullToRefreshEffect)) { |
| 92 return nullptr; | 91 return nullptr; |
| 93 } | 92 } |
| 94 | 93 |
| 95 return base::MakeUnique<OverscrollRefresh>(handler); | 94 return base::MakeUnique<OverscrollRefresh>(overscroll_refresh_handler); |
| 96 } | 95 } |
| 97 | 96 |
| 98 } // namespace | 97 } // namespace |
| 99 | 98 |
| 100 OverscrollControllerAndroid::OverscrollControllerAndroid( | 99 OverscrollControllerAndroid::OverscrollControllerAndroid( |
| 101 ContentViewCoreImpl* content_view_core, | 100 ui::OverscrollRefreshHandler* overscroll_refresh_handler, |
| 101 ui::WindowAndroidCompositor* compositor, |
| 102 float dpi_scale) | 102 float dpi_scale) |
| 103 : compositor_(content_view_core->GetWindowAndroid()->GetCompositor()), | 103 : compositor_(compositor), |
| 104 dpi_scale_(dpi_scale), | 104 dpi_scale_(dpi_scale), |
| 105 enabled_(true), | 105 enabled_(true), |
| 106 glow_effect_(CreateGlowEffect(this, dpi_scale_)), | 106 glow_effect_(CreateGlowEffect(this, dpi_scale_)), |
| 107 refresh_effect_(CreateRefreshEffect(content_view_core)) { | 107 refresh_effect_(CreateRefreshEffect(overscroll_refresh_handler)) { |
| 108 DCHECK(compositor_); | 108 DCHECK(compositor_); |
| 109 } | 109 } |
| 110 | 110 |
| 111 OverscrollControllerAndroid::~OverscrollControllerAndroid() { | 111 OverscrollControllerAndroid::~OverscrollControllerAndroid() { |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool OverscrollControllerAndroid::WillHandleGestureEvent( | 114 bool OverscrollControllerAndroid::WillHandleGestureEvent( |
| 115 const blink::WebGestureEvent& event) { | 115 const blink::WebGestureEvent& event) { |
| 116 if (!enabled_) | 116 if (!enabled_) |
| 117 return false; | 117 return false; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 std::unique_ptr<EdgeEffectBase> | 274 std::unique_ptr<EdgeEffectBase> |
| 275 OverscrollControllerAndroid::CreateEdgeEffect() { | 275 OverscrollControllerAndroid::CreateEdgeEffect() { |
| 276 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); | 276 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void OverscrollControllerAndroid::SetNeedsAnimate() { | 279 void OverscrollControllerAndroid::SetNeedsAnimate() { |
| 280 compositor_->SetNeedsAnimate(); | 280 compositor_->SetNeedsAnimate(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace content | 283 } // namespace content |
| OLD | NEW |