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" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
13 | 13 |
14 struct ViewHostMsg_UpdateRect_Params; | 14 struct ViewHostMsg_UpdateRect_Params; |
15 | 15 |
| 16 namespace aura_extra { |
| 17 class ImageWindowDelegate; |
| 18 } |
| 19 |
16 namespace content { | 20 namespace content { |
17 | 21 |
18 class ImageLayerDelegate; | 22 class ImageLayerDelegate; |
19 class ImageWindowDelegate; | |
20 class OverscrollNavigationOverlayTest; | 23 class OverscrollNavigationOverlayTest; |
21 | 24 |
22 // When a history navigation is triggered at the end of an overscroll | 25 // When a history navigation is triggered at the end of an overscroll |
23 // navigation, it is necessary to show the history-screenshot until the page is | 26 // navigation, it is necessary to show the history-screenshot until the page is |
24 // done navigating and painting. This class accomplishes this by showing the | 27 // done navigating and painting. This class accomplishes this by showing the |
25 // screenshot window on top of the page until the page has completed loading and | 28 // screenshot window on top of the page until the page has completed loading and |
26 // painting. | 29 // painting. |
27 class CONTENT_EXPORT OverscrollNavigationOverlay | 30 class CONTENT_EXPORT OverscrollNavigationOverlay |
28 : public WebContentsObserver, | 31 : public WebContentsObserver, |
29 public WindowSlider::Delegate { | 32 public WindowSlider::Delegate { |
30 public: | 33 public: |
31 explicit OverscrollNavigationOverlay(WebContentsImpl* web_contents); | 34 explicit OverscrollNavigationOverlay(WebContentsImpl* web_contents); |
32 ~OverscrollNavigationOverlay() override; | 35 ~OverscrollNavigationOverlay() override; |
33 | 36 |
34 bool has_window() const { return !!window_.get(); } | 37 bool has_window() const { return !!window_.get(); } |
35 | 38 |
36 // Resets state and starts observing |web_contents_| for page load/paint | 39 // Resets state and starts observing |web_contents_| for page load/paint |
37 // updates. This function makes sure that the screenshot window is stacked | 40 // updates. This function makes sure that the screenshot window is stacked |
38 // on top, so that it hides the content window behind it, and destroys the | 41 // on top, so that it hides the content window behind it, and destroys the |
39 // screenshot window when the page is done loading/painting. | 42 // screenshot window when the page is done loading/painting. |
40 // This should be called immediately after initiating the navigation, | 43 // This should be called immediately after initiating the navigation, |
41 // otherwise the overlay may be dismissed prematurely. | 44 // otherwise the overlay may be dismissed prematurely. |
42 void StartObserving(); | 45 void StartObserving(); |
43 | 46 |
44 // Sets the screenshot window and the delegate. This takes ownership of | 47 // Sets the screenshot window and the delegate. This takes ownership of |
45 // |window|. | 48 // |window|. |
46 // Note that ImageWindowDelegate manages its own lifetime, so this function | 49 // Note that aura_extra::ImageWindowDelegate manages its own lifetime, so this |
47 // does not take ownership of |delegate|. | 50 // function does not take ownership of |delegate|. |
48 void SetOverlayWindow(scoped_ptr<aura::Window> window, | 51 void SetOverlayWindow(scoped_ptr<aura::Window> window, |
49 ImageWindowDelegate* delegate); | 52 aura_extra::ImageWindowDelegate* delegate); |
50 | 53 |
51 private: | 54 private: |
52 friend class OverscrollNavigationOverlayTest; | 55 friend class OverscrollNavigationOverlayTest; |
53 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 56 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
54 FirstVisuallyNonEmptyPaint_NoImage); | 57 FirstVisuallyNonEmptyPaint_NoImage); |
55 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 58 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
56 FirstVisuallyNonEmptyPaint_WithImage); | 59 FirstVisuallyNonEmptyPaint_WithImage); |
57 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 60 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
58 LoadUpdateWithoutNonEmptyPaint); | 61 LoadUpdateWithoutNonEmptyPaint); |
59 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 62 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
(...skipping 29 matching lines...) Expand all Loading... |
89 void DidStopLoading(RenderViewHost* host) override; | 92 void DidStopLoading(RenderViewHost* host) override; |
90 | 93 |
91 // The WebContents which is being navigated. | 94 // The WebContents which is being navigated. |
92 WebContentsImpl* web_contents_; | 95 WebContentsImpl* web_contents_; |
93 | 96 |
94 // The screenshot overlay window. | 97 // The screenshot overlay window. |
95 scoped_ptr<aura::Window> window_; | 98 scoped_ptr<aura::Window> window_; |
96 | 99 |
97 // This is the WindowDelegate of |window_|. The delegate manages its own | 100 // This is the WindowDelegate of |window_|. The delegate manages its own |
98 // lifetime (destroys itself when |window_| is destroyed). | 101 // lifetime (destroys itself when |window_| is destroyed). |
99 ImageWindowDelegate* image_delegate_; | 102 aura_extra::ImageWindowDelegate* image_delegate_; |
100 | 103 |
101 bool loading_complete_; | 104 bool loading_complete_; |
102 bool received_paint_update_; | 105 bool received_paint_update_; |
103 | 106 |
104 // URL of the NavigationEntry we are navigating to. This is needed to | 107 // URL of the NavigationEntry we are navigating to. This is needed to |
105 // filter on WebContentsObserver callbacks and is used to dismiss the overlay | 108 // filter on WebContentsObserver callbacks and is used to dismiss the overlay |
106 // when the relevant page loads and paints. | 109 // when the relevant page loads and paints. |
107 GURL pending_entry_url_; | 110 GURL pending_entry_url_; |
108 | 111 |
109 // The |WindowSlider| that allows sliding history layers while the page is | 112 // The |WindowSlider| that allows sliding history layers while the page is |
110 // being reloaded. | 113 // being reloaded. |
111 scoped_ptr<WindowSlider> window_slider_; | 114 scoped_ptr<WindowSlider> window_slider_; |
112 | 115 |
113 // Layer to be used for the final overlay fadeout animation when the overlay | 116 // Layer to be used for the final overlay fadeout animation when the overlay |
114 // is being dismissed. | 117 // is being dismissed. |
115 scoped_ptr<ui::Layer> overlay_dismiss_layer_; | 118 scoped_ptr<ui::Layer> overlay_dismiss_layer_; |
116 | 119 |
117 // The direction of the in-progress slide (if any). | 120 // The direction of the in-progress slide (if any). |
118 SlideDirection slide_direction_; | 121 SlideDirection slide_direction_; |
119 | 122 |
120 // The LayerDelegate used for the back/front layers during a slide. | 123 // The LayerDelegate used for the back/front layers during a slide. |
121 scoped_ptr<ImageLayerDelegate> layer_delegate_; | 124 scoped_ptr<ImageLayerDelegate> layer_delegate_; |
122 | 125 |
123 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); | 126 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
124 }; | 127 }; |
125 | 128 |
126 } // namespace content | 129 } // namespace content |
127 | 130 |
128 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ | 131 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ |
OLD | NEW |