Chromium Code Reviews| 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" | 12 #include "content/browser/android/content_view_core_impl.h" |
|
boliu
2016/12/03 01:05:28
don't need this include
rlanday
2016/12/05 19:53:56
It's needed for member access into blink::WebGestu
boliu
2016/12/06 00:46:34
then forward declare that as well, or include the
rlanday
2016/12/06 03:25:26
Ok, I will include the WebGestureEvent header (a f
| |
| 13 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/user_metrics.h" | 14 #include "content/public/browser/user_metrics.h" |
| 15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.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/overscroll_refresh_handler.h" | |
| 19 #include "ui/android/resources/resource_manager.h" | 20 #include "ui/android/resources/resource_manager.h" |
| 20 #include "ui/android/window_android.h" | 21 #include "ui/android/window_android.h" |
| 21 #include "ui/android/window_android_compositor.h" | 22 #include "ui/android/window_android_compositor.h" |
| 22 #include "ui/base/l10n/l10n_util_android.h" | 23 #include "ui/base/l10n/l10n_util_android.h" |
| 23 #include "ui/events/blink/did_overscroll_params.h" | 24 #include "ui/events/blink/did_overscroll_params.h" |
| 24 | 25 |
| 25 using ui::DidOverscrollParams; | 26 using ui::DidOverscrollParams; |
| 26 using ui::EdgeEffect; | 27 using ui::EdgeEffect; |
| 27 using ui::EdgeEffectBase; | 28 using ui::EdgeEffectBase; |
| 28 using ui::EdgeEffectL; | 29 using ui::EdgeEffectL; |
| 29 using ui::OverscrollGlow; | 30 using ui::OverscrollGlow; |
| 30 using ui::OverscrollGlowClient; | 31 using ui::OverscrollGlowClient; |
| 31 using ui::OverscrollRefresh; | 32 using ui::OverscrollRefresh; |
| 32 using ui::OverscrollRefreshHandler; | |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Used for conditional creation of EdgeEffect types for the overscroll glow. | 37 // Used for conditional creation of EdgeEffect types for the overscroll glow. |
| 38 const int kAndroidLSDKVersion = 21; | 38 const int kAndroidLSDKVersion = 21; |
| 39 | 39 |
| 40 // If the glow effect alpha is greater than this value, the refresh effect will | 40 // 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 | 41 // be suppressed. This value was experimentally determined to provide a |
| 42 // reasonable balance between avoiding accidental refresh activation and | 42 // 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) { | 79 float dpi_scale) { |
| 80 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 80 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 81 switches::kDisableOverscrollEdgeEffect)) { | 81 switches::kDisableOverscrollEdgeEffect)) { |
| 82 return nullptr; | 82 return nullptr; |
| 83 } | 83 } |
| 84 | 84 |
| 85 return base::MakeUnique<OverscrollGlow>(client); | 85 return base::MakeUnique<OverscrollGlow>(client); |
| 86 } | 86 } |
| 87 | 87 |
| 88 std::unique_ptr<OverscrollRefresh> CreateRefreshEffect( | 88 std::unique_ptr<OverscrollRefresh> CreateRefreshEffect( |
| 89 OverscrollRefreshHandler* handler) { | 89 ui::OverscrollRefreshHandler* overscroll_refresh_handler) { |
| 90 if (overscroll_refresh_handler == nullptr) | |
|
boliu
2016/12/03 01:05:28
should write RWHVA/WCVA such that this is never nu
rlanday
2016/12/05 19:53:56
I'm not quite sure what you mean by "explicit sign
rlanday
2016/12/05 23:01:33
Ok, so I took the call to CreateOverscrollControll
boliu
2016/12/06 00:46:33
Overall pretty reasonable to me.
Probably fine e
| |
| 91 return nullptr; | |
| 92 | |
| 90 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 93 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 91 switches::kDisablePullToRefreshEffect)) { | 94 switches::kDisablePullToRefreshEffect)) { |
| 92 return nullptr; | 95 return nullptr; |
| 93 } | 96 } |
| 94 | 97 |
| 95 return base::MakeUnique<OverscrollRefresh>(handler); | 98 return base::MakeUnique<OverscrollRefresh>(overscroll_refresh_handler); |
| 96 } | 99 } |
| 97 | 100 |
| 98 } // namespace | 101 } // namespace |
| 99 | 102 |
| 100 OverscrollControllerAndroid::OverscrollControllerAndroid( | 103 OverscrollControllerAndroid::OverscrollControllerAndroid( |
| 101 ContentViewCoreImpl* content_view_core, | 104 ui::OverscrollRefreshHandler* overscroll_refresh_handler, |
| 105 ui::WindowAndroidCompositor* compositor, | |
| 102 float dpi_scale) | 106 float dpi_scale) |
| 103 : compositor_(content_view_core->GetWindowAndroid()->GetCompositor()), | 107 : compositor_(compositor), |
| 104 dpi_scale_(dpi_scale), | 108 dpi_scale_(dpi_scale), |
| 105 enabled_(true), | 109 enabled_(true), |
| 106 glow_effect_(CreateGlowEffect(this, dpi_scale_)), | 110 glow_effect_(CreateGlowEffect(this, dpi_scale_)), |
| 107 refresh_effect_(CreateRefreshEffect(content_view_core)) { | 111 refresh_effect_(CreateRefreshEffect(overscroll_refresh_handler)) { |
| 108 DCHECK(compositor_); | 112 DCHECK(compositor_); |
| 109 } | 113 } |
| 110 | 114 |
| 111 OverscrollControllerAndroid::~OverscrollControllerAndroid() { | 115 OverscrollControllerAndroid::~OverscrollControllerAndroid() { |
| 112 } | 116 } |
| 113 | 117 |
| 114 bool OverscrollControllerAndroid::WillHandleGestureEvent( | 118 bool OverscrollControllerAndroid::WillHandleGestureEvent( |
| 115 const blink::WebGestureEvent& event) { | 119 const blink::WebGestureEvent& event) { |
| 116 if (!enabled_) | 120 if (!enabled_) |
| 117 return false; | 121 return false; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 std::unique_ptr<EdgeEffectBase> | 278 std::unique_ptr<EdgeEffectBase> |
| 275 OverscrollControllerAndroid::CreateEdgeEffect() { | 279 OverscrollControllerAndroid::CreateEdgeEffect() { |
| 276 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); | 280 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); |
| 277 } | 281 } |
| 278 | 282 |
| 279 void OverscrollControllerAndroid::SetNeedsAnimate() { | 283 void OverscrollControllerAndroid::SetNeedsAnimate() { |
| 280 compositor_->SetNeedsAnimate(); | 284 compositor_->SetNeedsAnimate(); |
| 281 } | 285 } |
| 282 | 286 |
| 283 } // namespace content | 287 } // namespace content |
| OLD | NEW |