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 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/browser/web_contents/aura/window_slider.h" | 10 #include "content/browser/web_contents/aura/window_slider.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 // otherwise the overlay may be dismissed prematurely. | 41 // otherwise the overlay may be dismissed prematurely. |
| 42 void StartObserving(); | 42 void StartObserving(); |
| 43 | 43 |
| 44 // Sets the screenshot window and the delegate. This takes ownership of | 44 // Sets the screenshot window and the delegate. This takes ownership of |
| 45 // |window|. | 45 // |window|. |
| 46 // Note that ImageWindowDelegate manages its own lifetime, so this function | 46 // Note that ImageWindowDelegate manages its own lifetime, so this function |
| 47 // does not take ownership of |delegate|. | 47 // does not take ownership of |delegate|. |
| 48 void SetOverlayWindow(scoped_ptr<aura::Window> window, | 48 void SetOverlayWindow(scoped_ptr<aura::Window> window, |
| 49 ImageWindowDelegate* delegate); | 49 ImageWindowDelegate* delegate); |
| 50 | 50 |
| 51 // Sets up the overlay for tests. | |
| 52 void SetupForTesting(); | |
| 53 | |
| 54 private: | 51 private: |
| 55 friend class OverscrollNavigationOverlayTest; | 52 friend class OverscrollNavigationOverlayTest; |
| 56 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 53 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 57 FirstVisuallyNonEmptyPaint_NoImage); | 54 FirstVisuallyNonEmptyPaint_NoImage); |
| 58 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 55 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 59 FirstVisuallyNonEmptyPaint_WithImage); | 56 FirstVisuallyNonEmptyPaint_WithImage); |
| 60 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 57 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 61 PaintUpdateWithoutNonEmptyPaint); | 58 LoadUpdateWithoutNonEmptyPaint); |
| 62 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 59 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 63 MultiNavigation_LoadingUpdate); | 60 MultiNavigation_LoadingUpdate); |
| 64 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 61 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 65 MultiNavigation_PaintUpdate); | 62 MultiNavigation_PaintUpdate); |
| 66 | 63 |
| 67 enum SlideDirection { | 64 enum SlideDirection { |
| 68 SLIDE_UNKNOWN, | 65 SLIDE_UNKNOWN, |
| 69 SLIDE_BACK, | 66 SLIDE_BACK, |
| 70 SLIDE_FRONT | 67 SLIDE_FRONT |
| 71 }; | 68 }; |
| 72 | 69 |
| 73 // Stop observing the page and start the final overlay fade-out animation | 70 // Stop observing the page and start the final overlay fade-out animation |
| 74 // if the page-load has completed and the page has been painted, and a | 71 // if the the page has been painted or the page-load has completed, and a |
|
sadrul
2014/05/27 16:48:29
s/the the/the/
mfomitchev
2014/05/27 21:21:05
Done.
| |
| 75 // window-slide isn't in progress. | 72 // window-slide isn't in progress. |
| 76 void StopObservingIfDone(); | 73 void StopObservingIfDone(); |
| 77 | 74 |
| 78 // Creates a layer to be used for window-slide. |offset| is the offset of the | 75 // Creates a layer to be used for window-slide. |offset| is the offset of the |
| 79 // NavigationEntry for the screenshot image to display. | 76 // NavigationEntry for the screenshot image to display. |
| 80 ui::Layer* CreateSlideLayer(int offset); | 77 ui::Layer* CreateSlideLayer(int offset); |
| 81 | 78 |
| 82 // IPC message callbacks. | |
| 83 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | |
| 84 | |
| 85 // Overridden from WindowSlider::Delegate: | 79 // Overridden from WindowSlider::Delegate: |
| 86 virtual ui::Layer* CreateBackLayer() OVERRIDE; | 80 virtual ui::Layer* CreateBackLayer() OVERRIDE; |
| 87 virtual ui::Layer* CreateFrontLayer() OVERRIDE; | 81 virtual ui::Layer* CreateFrontLayer() OVERRIDE; |
| 88 virtual void OnWindowSlideCompleting() OVERRIDE; | 82 virtual void OnWindowSlideCompleting() OVERRIDE; |
| 89 virtual void OnWindowSlideCompleted() OVERRIDE; | 83 virtual void OnWindowSlideCompleted(scoped_ptr<ui::Layer> layer) OVERRIDE; |
| 90 virtual void OnWindowSlideAborted() OVERRIDE; | 84 virtual void OnWindowSlideAborted() OVERRIDE; |
| 91 virtual void OnWindowSliderDestroyed() OVERRIDE; | 85 virtual void OnWindowSliderDestroyed() OVERRIDE; |
| 92 | 86 |
| 93 // Overridden from WebContentsObserver: | 87 // Overridden from WebContentsObserver: |
| 94 virtual void DocumentOnLoadCompletedInMainFrame() OVERRIDE; | |
| 95 virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE; | 88 virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE; |
| 96 virtual void DidStopLoading(RenderViewHost* host) OVERRIDE; | 89 virtual void DidStopLoading(RenderViewHost* host) OVERRIDE; |
| 97 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 98 | 90 |
| 99 // The WebContents which is being navigated. | 91 // The WebContents which is being navigated. |
| 100 WebContentsImpl* web_contents_; | 92 WebContentsImpl* web_contents_; |
| 101 | 93 |
| 102 // The screenshot overlay window. | 94 // The screenshot overlay window. |
| 103 scoped_ptr<aura::Window> window_; | 95 scoped_ptr<aura::Window> window_; |
| 104 | 96 |
| 105 // This is the WindowDelegate of |window_|. The delegate manages its own | 97 // This is the WindowDelegate of |window_|. The delegate manages its own |
| 106 // lifetime (destroys itself when |window_| is destroyed). | 98 // lifetime (destroys itself when |window_| is destroyed). |
| 107 ImageWindowDelegate* image_delegate_; | 99 ImageWindowDelegate* image_delegate_; |
| 108 | 100 |
| 109 bool loading_complete_; | 101 bool loading_complete_; |
| 110 bool received_paint_update_; | 102 bool received_paint_update_; |
| 111 | 103 |
| 112 // Unique ID of the NavigationEntry we are navigating to. This is needed to | 104 // Unique ID of the NavigationEntry we are navigating to. This is needed to |
| 113 // filter on WebContentsObserver callbacks and is used to dismiss the overlay | 105 // filter on WebContentsObserver callbacks and is used to dismiss the overlay |
| 114 // when the relevant page loads and paints. | 106 // when the relevant page loads and paints. |
| 115 int pending_entry_id_; | 107 int pending_entry_id_; |
| 116 | 108 |
| 117 // The |WindowSlider| that allows sliding history layers while the page is | 109 // The |WindowSlider| that allows sliding history layers while the page is |
| 118 // being reloaded. | 110 // being reloaded. |
| 119 scoped_ptr<WindowSlider> window_slider_; | 111 scoped_ptr<WindowSlider> window_slider_; |
| 120 | 112 |
| 113 // Layer to be used for the final overlay fadeout animation when the overlay | |
| 114 // is being dismissed. | |
| 115 scoped_ptr<ui::Layer> overlay_dismiss_layer_; | |
| 116 | |
| 121 // The direction of the in-progress slide (if any). | 117 // The direction of the in-progress slide (if any). |
| 122 SlideDirection slide_direction_; | 118 SlideDirection slide_direction_; |
| 123 | 119 |
| 124 // The LayerDelegate used for the back/front layers during a slide. | 120 // The LayerDelegate used for the back/front layers during a slide. |
| 125 scoped_ptr<ImageLayerDelegate> layer_delegate_; | 121 scoped_ptr<ImageLayerDelegate> layer_delegate_; |
| 126 | 122 |
| 127 // During tests, the aura windows don't get any paint updates. So the overlay | |
| 128 // container keeps waiting for a paint update it never receives, causing a | |
| 129 // timeout. So during tests, disable the wait for paint updates. | |
| 130 bool need_paint_update_; | |
| 131 | |
| 132 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); | 123 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
| 133 }; | 124 }; |
| 134 | 125 |
| 135 } // namespace content | 126 } // namespace content |
| 136 | 127 |
| 137 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ | 128 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ |
| OLD | NEW |