Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: content/browser/android/overscroll_glow.cc

Issue 733293002: [Android] Add a flag to disable the pull-to-refresh effect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_glow.h" 5 #include "content/browser/android/overscroll_glow.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "content/browser/android/edge_effect_base.h" 8 #include "content/browser/android/edge_effect_base.h"
9 9
10 using std::max; 10 using std::max;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 case OverscrollGlow::EDGE_RIGHT: 68 case OverscrollGlow::EDGE_RIGHT:
69 return gfx::SizeF(window_size.height(), window_size.width()); 69 return gfx::SizeF(window_size.height(), window_size.width());
70 default: 70 default:
71 NOTREACHED() << "Invalid edge: " << edge; 71 NOTREACHED() << "Invalid edge: " << edge;
72 return gfx::SizeF(); 72 return gfx::SizeF();
73 }; 73 };
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 OverscrollGlow::OverscrollGlow(const EdgeEffectProvider& edge_effect_provider) 78 OverscrollGlow::OverscrollGlow(OverscrollGlowClient* client)
79 : edge_effect_provider_(edge_effect_provider), 79 : client_(client), edge_offsets_(), initialized_(false) {
80 edge_offsets_(), 80 DCHECK(client);
81 initialized_(false) {
82 DCHECK(!edge_effect_provider_.is_null());
83 } 81 }
84 82
85 OverscrollGlow::~OverscrollGlow() { 83 OverscrollGlow::~OverscrollGlow() {
86 Detach(); 84 Detach();
87 } 85 }
88 86
89 void OverscrollGlow::Reset() { 87 void OverscrollGlow::Reset() {
90 if (!initialized_) 88 if (!initialized_)
91 return; 89 return;
92 Detach(); 90 Detach();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 root_layer_->RemoveFromParent(); 197 root_layer_->RemoveFromParent();
200 } 198 }
201 199
202 bool OverscrollGlow::InitializeIfNecessary() { 200 bool OverscrollGlow::InitializeIfNecessary() {
203 if (initialized_) 201 if (initialized_)
204 return true; 202 return true;
205 203
206 DCHECK(!root_layer_.get()); 204 DCHECK(!root_layer_.get());
207 root_layer_ = cc::Layer::Create(); 205 root_layer_ = cc::Layer::Create();
208 for (size_t i = 0; i < EDGE_COUNT; ++i) { 206 for (size_t i = 0; i < EDGE_COUNT; ++i) {
209 edge_effects_[i] = edge_effect_provider_.Run(); 207 edge_effects_[i] = client_->CreateEdgeEffect();
210 DCHECK(edge_effects_[i]); 208 DCHECK(edge_effects_[i]);
211 } 209 }
212 210
213 initialized_ = true; 211 initialized_ = true;
214 return true; 212 return true;
215 } 213 }
216 214
217 void OverscrollGlow::Pull(base::TimeTicks current_time, 215 void OverscrollGlow::Pull(base::TimeTicks current_time,
218 const gfx::Vector2dF& overscroll_delta, 216 const gfx::Vector2dF& overscroll_delta,
219 const gfx::Vector2dF& overscroll_location) { 217 const gfx::Vector2dF& overscroll_location) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 for (size_t i = 0; i < EDGE_COUNT; ++i) 280 for (size_t i = 0; i < EDGE_COUNT; ++i)
283 edge_effects_[i]->Release(current_time); 281 edge_effects_[i]->Release(current_time);
284 } 282 }
285 283
286 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { 284 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) {
287 DCHECK(initialized_); 285 DCHECK(initialized_);
288 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); 286 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get();
289 } 287 }
290 288
291 } // namespace content 289 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/overscroll_glow.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698