| 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 "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/output/compositor_frame_metadata.h" | 10 #include "cc/output/compositor_frame_metadata.h" |
| 11 #include "content/browser/android/edge_effect.h" | 11 #include "content/browser/android/edge_effect.h" |
| 12 #include "content/browser/android/edge_effect_l.h" | 12 #include "content/browser/android/edge_effect_l.h" |
| 13 #include "content/browser/web_contents/web_contents_impl.h" | 13 #include "content/browser/web_contents/web_contents_impl.h" |
| 14 #include "content/common/input/did_overscroll_params.h" | 14 #include "content/common/input/did_overscroll_params.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "third_party/WebKit/public/web/WebInputEvent.h" | 17 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 18 #include "ui/android/resources/resource_manager.h" |
| 18 #include "ui/base/android/window_android_compositor.h" | 19 #include "ui/base/android/window_android_compositor.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Used for conditional creation of EdgeEffect types for the overscroll glow. | 24 // Used for conditional creation of EdgeEffect types for the overscroll glow. |
| 24 const int kAndroidLSDKVersion = 21; | 25 const int kAndroidLSDKVersion = 21; |
| 25 | 26 |
| 26 // Default offset in dips from the top of the view beyond which the refresh | 27 // Default offset in dips from the top of the view beyond which the refresh |
| 27 // action will be activated. | 28 // action will be activated. |
| 28 const int kDefaultRefreshDragTargetDips = 64; | 29 const int kDefaultRefreshDragTargetDips = 64; |
| 29 | 30 |
| 30 scoped_ptr<EdgeEffectBase> CreateGlowEdgeEffect( | 31 scoped_ptr<EdgeEffectBase> CreateGlowEdgeEffect( |
| 31 ui::SystemUIResourceManager* resource_manager, | 32 ui::ResourceManager* resource_manager, |
| 32 float dpi_scale) { | 33 float dpi_scale) { |
| 33 DCHECK(resource_manager); | 34 DCHECK(resource_manager); |
| 34 static bool use_l_flavoured_effect = | 35 static bool use_l_flavoured_effect = |
| 35 base::android::BuildInfo::GetInstance()->sdk_int() >= kAndroidLSDKVersion; | 36 base::android::BuildInfo::GetInstance()->sdk_int() >= kAndroidLSDKVersion; |
| 36 if (use_l_flavoured_effect) | 37 if (use_l_flavoured_effect) |
| 37 return scoped_ptr<EdgeEffectBase>(new EdgeEffectL(resource_manager)); | 38 return scoped_ptr<EdgeEffectBase>(new EdgeEffectL(resource_manager)); |
| 38 | 39 |
| 39 return scoped_ptr<EdgeEffectBase>( | 40 return scoped_ptr<EdgeEffectBase>( |
| 40 new EdgeEffect(resource_manager, dpi_scale)); | 41 new EdgeEffect(resource_manager, dpi_scale)); |
| 41 } | 42 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 scoped_ptr<OverscrollRefresh> CreateRefreshEffect( | 54 scoped_ptr<OverscrollRefresh> CreateRefreshEffect( |
| 54 ui::WindowAndroidCompositor* compositor, | 55 ui::WindowAndroidCompositor* compositor, |
| 55 OverscrollRefreshClient* client, | 56 OverscrollRefreshClient* client, |
| 56 float dpi_scale) { | 57 float dpi_scale) { |
| 57 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 58 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 58 switches::kDisablePullToRefreshEffect)) { | 59 switches::kDisablePullToRefreshEffect)) { |
| 59 return nullptr; | 60 return nullptr; |
| 60 } | 61 } |
| 61 | 62 |
| 62 return make_scoped_ptr( | 63 return make_scoped_ptr( |
| 63 new OverscrollRefresh(&compositor->GetSystemUIResourceManager(), client, | 64 new OverscrollRefresh(&compositor->GetResourceManager(), client, |
| 64 kDefaultRefreshDragTargetDips * dpi_scale)); | 65 kDefaultRefreshDragTargetDips * dpi_scale)); |
| 65 } | 66 } |
| 66 | 67 |
| 67 } // namespace | 68 } // namespace |
| 68 | 69 |
| 69 OverscrollControllerAndroid::OverscrollControllerAndroid( | 70 OverscrollControllerAndroid::OverscrollControllerAndroid( |
| 70 WebContents* web_contents, | 71 WebContents* web_contents, |
| 71 ui::WindowAndroidCompositor* compositor, | 72 ui::WindowAndroidCompositor* compositor, |
| 72 float dpi_scale) | 73 float dpi_scale) |
| 73 : compositor_(compositor), | 74 : compositor_(compositor), |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 278 |
| 278 triggered_refresh_active_ = true; | 279 triggered_refresh_active_ = true; |
| 279 web_contents()->GetController().Reload(true); | 280 web_contents()->GetController().Reload(true); |
| 280 } | 281 } |
| 281 | 282 |
| 282 bool OverscrollControllerAndroid::IsStillRefreshing() const { | 283 bool OverscrollControllerAndroid::IsStillRefreshing() const { |
| 283 return triggered_refresh_active_; | 284 return triggered_refresh_active_; |
| 284 } | 285 } |
| 285 | 286 |
| 286 scoped_ptr<EdgeEffectBase> OverscrollControllerAndroid::CreateEdgeEffect() { | 287 scoped_ptr<EdgeEffectBase> OverscrollControllerAndroid::CreateEdgeEffect() { |
| 287 return CreateGlowEdgeEffect(&compositor_->GetSystemUIResourceManager(), | 288 return CreateGlowEdgeEffect(&compositor_->GetResourceManager(), dpi_scale_); |
| 288 dpi_scale_); | |
| 289 } | 289 } |
| 290 | 290 |
| 291 void OverscrollControllerAndroid::SetNeedsAnimate() { | 291 void OverscrollControllerAndroid::SetNeedsAnimate() { |
| 292 compositor_->SetNeedsAnimate(); | 292 compositor_->SetNeedsAnimate(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace content | 295 } // namespace content |
| OLD | NEW |