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/web_contents/aura/overscroll_navigation_overlay.h" | 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 void OverscrollNavigationOverlay::OnOverscrollCompleted( | 216 void OverscrollNavigationOverlay::OnOverscrollCompleted( |
217 std::unique_ptr<aura::Window> window) { | 217 std::unique_ptr<aura::Window> window) { |
218 DCHECK(direction_ != NONE); | 218 DCHECK(direction_ != NONE); |
219 aura::Window* main_window = GetMainWindow(); | 219 aura::Window* main_window = GetMainWindow(); |
220 if (!main_window) { | 220 if (!main_window) { |
221 UMA_HISTOGRAM_ENUMERATION( | 221 UMA_HISTOGRAM_ENUMERATION( |
222 "Overscroll.Cancelled", direction_, NAVIGATION_COUNT); | 222 "Overscroll.Cancelled", direction_, NAVIGATION_COUNT); |
223 return; | 223 return; |
224 } | 224 } |
225 | 225 |
| 226 main_window->SetTransform(gfx::Transform()); |
| 227 window_ = std::move(window); |
| 228 // Make sure the window is in its default position. |
| 229 window_->SetBounds(gfx::Rect(web_contents_window_->bounds().size())); |
| 230 window_->SetTransform(gfx::Transform()); |
| 231 // Make sure the overlay window is on top. |
| 232 web_contents_window_->StackChildAtTop(window_.get()); |
| 233 |
226 // Make sure we can navigate first, as other factors can trigger a navigation | 234 // Make sure we can navigate first, as other factors can trigger a navigation |
227 // during an overscroll gesture and navigating without history produces a | 235 // during an overscroll gesture and navigating without history produces a |
228 // crash. | 236 // crash. |
229 bool navigated = false; | 237 bool navigated = false; |
230 if (direction_ == FORWARD && web_contents_->GetController().CanGoForward()) { | 238 if (direction_ == FORWARD && web_contents_->GetController().CanGoForward()) { |
231 web_contents_->GetController().GoForward(); | 239 web_contents_->GetController().GoForward(); |
232 navigated = true; | 240 navigated = true; |
233 } else if (direction_ == BACK && web_contents_->GetController().CanGoBack()) { | 241 } else if (direction_ == BACK && web_contents_->GetController().CanGoBack()) { |
234 web_contents_->GetController().GoBack(); | 242 web_contents_->GetController().GoBack(); |
235 navigated = true; | 243 navigated = true; |
236 } else { | 244 } else { |
237 // We need to dismiss the overlay without navigating as soon as the | 245 // We need to dismiss the overlay without navigating as soon as the |
238 // overscroll finishes. | 246 // overscroll finishes. |
239 UMA_HISTOGRAM_ENUMERATION( | 247 UMA_HISTOGRAM_ENUMERATION( |
240 "Overscroll.Cancelled", direction_, NAVIGATION_COUNT); | 248 "Overscroll.Cancelled", direction_, NAVIGATION_COUNT); |
241 loading_complete_ = true; | 249 loading_complete_ = true; |
242 } | 250 } |
243 | 251 |
244 if (navigated) { | 252 if (navigated) { |
245 UMA_HISTOGRAM_ENUMERATION( | 253 UMA_HISTOGRAM_ENUMERATION( |
246 "Overscroll.Navigated2", direction_, NAVIGATION_COUNT); | 254 "Overscroll.Navigated2", direction_, NAVIGATION_COUNT); |
247 StartObserving(); | 255 StartObserving(); |
248 } | 256 } |
249 | 257 |
250 main_window->SetTransform(gfx::Transform()); | |
251 window_ = std::move(window); | |
252 // Make sure the window is in its default position. | |
253 window_->SetBounds(gfx::Rect(web_contents_window_->bounds().size())); | |
254 window_->SetTransform(gfx::Transform()); | |
255 // Make sure the overlay window is on top. | |
256 web_contents_window_->StackChildAtTop(window_.get()); | |
257 direction_ = NONE; | 258 direction_ = NONE; |
258 StopObservingIfDone(); | 259 StopObservingIfDone(); |
259 } | 260 } |
260 | 261 |
261 void OverscrollNavigationOverlay::OnOverscrollCancelled() { | 262 void OverscrollNavigationOverlay::OnOverscrollCancelled() { |
262 UMA_HISTOGRAM_ENUMERATION( | 263 UMA_HISTOGRAM_ENUMERATION( |
263 "Overscroll.Cancelled", direction_, NAVIGATION_COUNT); | 264 "Overscroll.Cancelled", direction_, NAVIGATION_COUNT); |
264 aura::Window* main_window = GetMainWindow(); | 265 aura::Window* main_window = GetMainWindow(); |
265 if (!main_window) | 266 if (!main_window) |
266 return; | 267 return; |
(...skipping 14 matching lines...) Expand all Loading... |
281 | 282 |
282 void OverscrollNavigationOverlay::DidStopLoading() { | 283 void OverscrollNavigationOverlay::DidStopLoading() { |
283 // Don't compare URLs in this case - it's possible they won't match if | 284 // Don't compare URLs in this case - it's possible they won't match if |
284 // a gesture-nav initiated navigation was interrupted by some other in-site | 285 // a gesture-nav initiated navigation was interrupted by some other in-site |
285 // navigation (e.g., from a script, or from a bookmark). | 286 // navigation (e.g., from a script, or from a bookmark). |
286 loading_complete_ = true; | 287 loading_complete_ = true; |
287 StopObservingIfDone(); | 288 StopObservingIfDone(); |
288 } | 289 } |
289 | 290 |
290 } // namespace content | 291 } // namespace content |
OLD | NEW |