| 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/browser/web_contents/web_contents_view_aura.h" |
| 11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "ui/gfx/image/image.h" |
| 13 | 15 |
| 14 struct ViewHostMsg_UpdateRect_Params; | 16 struct ViewHostMsg_UpdateRect_Params; |
| 15 | 17 |
| 16 namespace aura_extra { | 18 namespace aura_extra { |
| 17 class ImageWindowDelegate; | 19 class ImageWindowDelegate; |
| 18 } | 20 } |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 | 23 |
| 22 class ImageLayerDelegate; | 24 class ImageLayerDelegate; |
| 23 class OverscrollNavigationOverlayTest; | 25 class OverscrollNavigationOverlayTest; |
| 24 | 26 |
| 25 // When a history navigation is triggered at the end of an overscroll | 27 // When a history navigation is triggered at the end of an overscroll |
| 26 // navigation, it is necessary to show the history-screenshot until the page is | 28 // navigation, it is necessary to show the history-screenshot until the page is |
| 27 // done navigating and painting. This class accomplishes this by showing the | 29 // done navigating and painting. This class accomplishes this by showing the |
| 28 // screenshot window on top of the page until the page has completed loading and | 30 // screenshot window on top of the page until the page has completed loading and |
| 29 // painting. | 31 // painting. |
| 30 class CONTENT_EXPORT OverscrollNavigationOverlay | 32 class CONTENT_EXPORT OverscrollNavigationOverlay |
| 31 : public WebContentsObserver, | 33 : public WebContentsObserver, |
| 32 public WindowSlider::Delegate { | 34 public WindowSlider::Delegate { |
| 33 public: | 35 public: |
| 34 explicit OverscrollNavigationOverlay(WebContentsImpl* web_contents); | 36 // TODO move this somewhere else. |
| 37 enum Direction { FORWARD, BACKWARD, NONE }; |
| 38 |
| 39 explicit OverscrollNavigationOverlay(WebContentsImpl* web_contents, |
| 40 WebContentsViewAura* wcva); |
| 35 ~OverscrollNavigationOverlay() override; | 41 ~OverscrollNavigationOverlay() override; |
| 36 | 42 |
| 37 bool has_window() const { return !!window_.get(); } | 43 bool has_window() const { return !!window_.get(); } |
| 38 | 44 |
| 39 // Resets state and starts observing |web_contents_| for page load/paint | 45 // Resets state and starts observing |web_contents_| for page load/paint |
| 40 // updates. This function makes sure that the screenshot window is stacked | 46 // updates. This function makes sure that the screenshot window is stacked |
| 41 // on top, so that it hides the content window behind it, and destroys the | 47 // on top, so that it hides the content window behind it, and destroys the |
| 42 // screenshot window when the page is done loading/painting. | 48 // screenshot window when the page is done loading/painting. |
| 43 // This should be called immediately after initiating the navigation, | 49 // This should be called immediately after initiating the navigation, |
| 44 // otherwise the overlay may be dismissed prematurely. | 50 // otherwise the overlay may be dismissed prematurely. |
| 45 void StartObserving(); | 51 void StartObserving(); |
| 46 | 52 |
| 47 // Sets the screenshot window and the delegate. This takes ownership of | 53 // Sets the screenshot window and the delegate. This takes ownership of |
| 48 // |window|. | 54 // |window|. |
| 49 // Note that aura_extra::ImageWindowDelegate manages its own lifetime, so this | 55 // Note that aura_extra::ImageWindowDelegate manages its own lifetime, so this |
| 50 // function does not take ownership of |delegate|. | 56 // function does not take ownership of |delegate|. |
| 51 void SetOverlayWindow(scoped_ptr<aura::Window> window, | 57 void SetOverlayWindow(scoped_ptr<aura::Window> window, |
| 52 aura_extra::ImageWindowDelegate* delegate); | 58 aura_extra::ImageWindowDelegate* delegate); |
| 53 | 59 |
| 60 const gfx::Image GetImageForDirection(Direction direction); |
| 61 |
| 62 // Creates a layer with a screenshot for a given direction. |
| 63 scoped_ptr<ui::Layer> CreateLayerForDirection(Direction direction); |
| 64 |
| 65 Direction GetNavigationDirection(const NavigationController& controller, |
| 66 OverscrollMode mode); |
| 67 |
| 54 private: | 68 private: |
| 55 friend class OverscrollNavigationOverlayTest; | 69 friend class OverscrollNavigationOverlayTest; |
| 56 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 70 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 57 FirstVisuallyNonEmptyPaint_NoImage); | 71 FirstVisuallyNonEmptyPaint_NoImage); |
| 58 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 72 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 59 FirstVisuallyNonEmptyPaint_WithImage); | 73 FirstVisuallyNonEmptyPaint_WithImage); |
| 60 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 74 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 61 LoadUpdateWithoutNonEmptyPaint); | 75 LoadUpdateWithoutNonEmptyPaint); |
| 62 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, | 76 FRIEND_TEST_ALL_PREFIXES(OverscrollNavigationOverlayTest, |
| 63 MultiNavigation_LoadingUpdate); | 77 MultiNavigation_LoadingUpdate); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Layer to be used for the final overlay fadeout animation when the overlay | 130 // Layer to be used for the final overlay fadeout animation when the overlay |
| 117 // is being dismissed. | 131 // is being dismissed. |
| 118 scoped_ptr<ui::Layer> overlay_dismiss_layer_; | 132 scoped_ptr<ui::Layer> overlay_dismiss_layer_; |
| 119 | 133 |
| 120 // The direction of the in-progress slide (if any). | 134 // The direction of the in-progress slide (if any). |
| 121 SlideDirection slide_direction_; | 135 SlideDirection slide_direction_; |
| 122 | 136 |
| 123 // The LayerDelegate used for the back/front layers during a slide. | 137 // The LayerDelegate used for the back/front layers during a slide. |
| 124 scoped_ptr<ImageLayerDelegate> layer_delegate_; | 138 scoped_ptr<ImageLayerDelegate> layer_delegate_; |
| 125 | 139 |
| 140 // TODO use a delegate. |
| 141 WebContentsViewAura* wcva_; |
| 142 |
| 126 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); | 143 DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
| 127 }; | 144 }; |
| 128 | 145 |
| 129 } // namespace content | 146 } // namespace content |
| 130 | 147 |
| 131 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ | 148 #endif // CONTENT_BROWSER_WEB_CONTENTS_AURA_OVERSCROLL_NAVIGATION_OVERLAY_H_ |
| OLD | NEW |