| 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 "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/web_contents/aura/image_window_delegate.h" | 9 #include "content/browser/web_contents/aura/image_window_delegate.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Takes ownership of the layer. | 70 // Takes ownership of the layer. |
| 71 explicit OverlayDismissAnimator(scoped_ptr<ui::Layer> layer) | 71 explicit OverlayDismissAnimator(scoped_ptr<ui::Layer> layer) |
| 72 : layer_(layer.Pass()) { | 72 : layer_(layer.Pass()) { |
| 73 CHECK(layer_.get()); | 73 CHECK(layer_.get()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Starts the fadeout animation on the layer. When the animation finishes, | 76 // Starts the fadeout animation on the layer. When the animation finishes, |
| 77 // the object deletes itself along with the layer. | 77 // the object deletes itself along with the layer. |
| 78 void Animate() { | 78 void Animate() { |
| 79 DCHECK(layer_.get()); | 79 DCHECK(layer_.get()); |
| 80 // Hold on to LayerAnimator to ensure it is not deleted before animation | 80 ui::LayerAnimator* animator = layer_->GetAnimator(); |
| 81 // settings. Without this LayerAnimator would be deleted from SetOpacity if | 81 // This makes SetOpacity() animate with default duration (which could be |
| 82 // the animation duration is 0. | 82 // zero, e.g. when running tests). |
| 83 scoped_refptr<ui::LayerAnimator> animator(layer_->GetAnimator()); | 83 ui::ScopedLayerAnimationSettings settings(animator); |
| 84 { | 84 animator->AddObserver(this); |
| 85 // This makes SetOpacity() animate with default duration (which could be | 85 layer_->SetOpacity(0); |
| 86 // zero, e.g. when running tests). | |
| 87 ui::ScopedLayerAnimationSettings settings(animator); | |
| 88 animator->AddObserver(this); | |
| 89 layer_->SetOpacity(0); | |
| 90 } | |
| 91 } | 86 } |
| 92 | 87 |
| 93 // Overridden from ui::LayerAnimationObserver | 88 // Overridden from ui::LayerAnimationObserver |
| 94 virtual void OnLayerAnimationEnded( | 89 virtual void OnLayerAnimationEnded( |
| 95 ui::LayerAnimationSequence* sequence) OVERRIDE { | 90 ui::LayerAnimationSequence* sequence) OVERRIDE { |
| 96 delete this; | 91 delete this; |
| 97 } | 92 } |
| 98 | 93 |
| 99 virtual void OnLayerAnimationAborted( | 94 virtual void OnLayerAnimationAborted( |
| 100 ui::LayerAnimationSequence* sequence) OVERRIDE { | 95 ui::LayerAnimationSequence* sequence) OVERRIDE { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 bool OverscrollNavigationOverlay::OnMessageReceived( | 293 bool OverscrollNavigationOverlay::OnMessageReceived( |
| 299 const IPC::Message& message) { | 294 const IPC::Message& message) { |
| 300 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 295 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 301 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message) | 296 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message) |
| 302 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 297 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
| 303 IPC_END_MESSAGE_MAP() | 298 IPC_END_MESSAGE_MAP() |
| 304 return false; | 299 return false; |
| 305 } | 300 } |
| 306 | 301 |
| 307 } // namespace content | 302 } // namespace content |
| OLD | NEW |