OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_RENDERER_WEBVIEW_ANIMATING_OVERLAY_H_ | |
6 #define CHROME_RENDERER_WEBVIEW_ANIMATING_OVERLAY_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageOverlay.h" | |
10 #include "ui/base/animation/animation_delegate.h" | |
11 #include "ui/base/animation/linear_animation.h" | |
12 | |
13 namespace content { | |
14 class RenderView; | |
15 } | |
16 | |
17 // This class draws a gradient on a PageOverlay of a WebView. The gradient | |
18 // fades in when shown and fades out when hidden. | |
19 class WebViewAnimatingOverlay : public WebKit::WebPageOverlay, | |
20 public ui::AnimationDelegate { | |
21 public: | |
22 enum State { | |
23 ANIMATING_IN, | |
24 VISIBLE, | |
25 ANIMATING_OUT, | |
26 HIDDEN | |
27 }; | |
28 | |
29 explicit WebViewAnimatingOverlay(content::RenderView* render_view); | |
30 virtual ~WebViewAnimatingOverlay(); | |
31 void Show(); | |
32 void Hide(); | |
33 | |
34 State state() { return state_; } | |
35 | |
36 // WebKit::WebPageOverlay implementation: | |
37 virtual void paintPageOverlay(WebKit::WebCanvas* canvas) OVERRIDE; | |
38 | |
39 // ui::AnimationDelegate implementation: | |
40 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | |
41 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
42 | |
43 private: | |
44 int GetCurrentAlpha(); | |
45 | |
46 content::RenderView* render_view_; | |
47 State state_; | |
48 ui::LinearAnimation animation_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(WebViewAnimatingOverlay); | |
51 }; | |
52 | |
53 #endif // CHROME_RENDERER_WEBVIEW_ANIMATING_OVERLAY_H_ | |
OLD | NEW |