OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_VIEWS_PAGE_INFO_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAGE_INFO_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAGE_INFO_BUBBLE_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | |
10 #include "chrome/browser/page_info_model.h" | 9 #include "chrome/browser/page_info_model.h" |
11 #include "chrome/browser/page_info_model_observer.h" | 10 #include "chrome/browser/page_info_model_observer.h" |
12 #include "chrome/browser/ui/views/bubble/bubble.h" | |
13 #include "ui/base/animation/animation_delegate.h" | |
14 #include "ui/base/animation/slide_animation.h" | 11 #include "ui/base/animation/slide_animation.h" |
| 12 #include "views/bubble/bubble_delegate.h" |
15 #include "views/controls/link_listener.h" | 13 #include "views/controls/link_listener.h" |
16 #include "views/view.h" | |
17 | 14 |
18 class PageInfoBubbleView : public views::View, | 15 class PageInfoBubbleView : public views::BubbleDelegateView, |
19 public PageInfoModelObserver, | 16 public PageInfoModelObserver, |
20 public BubbleDelegate, | 17 public views::LinkListener { |
21 public views::LinkListener, | |
22 public ui::AnimationDelegate { | |
23 public: | 18 public: |
24 PageInfoBubbleView(gfx::NativeWindow parent_window, | 19 PageInfoBubbleView(views::View* anchor_view, |
25 Profile* profile, | 20 Profile* profile, |
26 const GURL& url, | 21 const GURL& url, |
27 const NavigationEntry::SSLStatus& ssl, | 22 const NavigationEntry::SSLStatus& ssl, |
28 bool show_history); | 23 bool show_history); |
29 virtual ~PageInfoBubbleView(); | 24 virtual ~PageInfoBubbleView(); |
30 | 25 |
31 // Show the certificate dialog. | 26 // Show the certificate dialog. |
32 void ShowCertDialog(); | 27 void ShowCertDialog(); |
33 | 28 |
34 void set_bubble(Bubble* bubble) { bubble_ = bubble; } | |
35 | |
36 // views::View methods: | 29 // views::View methods: |
37 virtual gfx::Size GetPreferredSize(); | 30 virtual gfx::Size GetPreferredSize(); |
38 | 31 |
39 // PageInfoModelObserver methods: | 32 // PageInfoModelObserver methods: |
40 virtual void OnPageInfoModelChanged() OVERRIDE; | 33 virtual void OnPageInfoModelChanged() OVERRIDE; |
41 | 34 |
42 // BubbleDelegate methods: | 35 // views::BubbleDelegate methods: |
43 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE; | 36 virtual gfx::Point GetAnchorPoint() OVERRIDE; |
44 virtual bool CloseOnEscape() OVERRIDE; | |
45 virtual bool FadeInOnShow() OVERRIDE; | |
46 virtual string16 GetAccessibleName() OVERRIDE; | |
47 | 37 |
48 // views::LinkListener methods: | 38 // views::LinkListener methods: |
49 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 39 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
50 | 40 |
51 // ui::AnimationDelegate methods: | 41 // ui::AnimationDelegate methods: |
52 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 42 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
53 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 43 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
54 | 44 |
55 private: | 45 private: |
56 // Gets the size of the separator, including padding. | 46 // Gets the size of the separator, including padding. |
57 gfx::Size GetSeparatorSize(); | 47 gfx::Size GetSeparatorSize(); |
58 | 48 |
59 // Get the current value of |resize_animation_| (in [0.0, 1.0]). | 49 // Get the current value of |resize_animation_| (in [0.0, 1.0]). |
60 double GetResizeAnimationCurrentValue(); | 50 double GetResizeAnimationCurrentValue(); |
61 | 51 |
62 // Gets the animation value to use for setting the height. | 52 // Gets the animation value to use for setting the height. |
63 double HeightAnimationValue(); | 53 double HeightAnimationValue(); |
64 | 54 |
65 // Layout the sections within the bubble. | 55 // Layout the sections within the bubble. |
66 void LayoutSections(); | 56 void LayoutSections(); |
67 | 57 |
68 // Global pointer to the bubble that is hosting our view. | |
69 static Bubble* bubble_; | |
70 | |
71 // The model providing the various section info. | 58 // The model providing the various section info. |
72 PageInfoModel model_; | 59 PageInfoModel model_; |
73 | 60 |
74 // The parent window of the Bubble showing this view. | |
75 gfx::NativeWindow parent_window_; | |
76 | |
77 // The id of the certificate for this page. | 61 // The id of the certificate for this page. |
78 int cert_id_; | 62 int cert_id_; |
79 | 63 |
80 // The Help Center link at the bottom of the bubble. | 64 // The Help Center link at the bottom of the bubble. |
81 views::Link* help_center_link_; | 65 views::Link* help_center_link_; |
82 | 66 |
83 // Animation that helps us change size smoothly as more data comes in. | 67 // Animation that helps us change size smoothly as more data comes in. |
84 ui::SlideAnimation resize_animation_; | 68 ui::SlideAnimation resize_animation_; |
85 | 69 |
86 // The height of the info bubble at the start of the resize animation. | 70 // The height of the info bubble at the start of the resize animation. |
87 int animation_start_height_; | 71 int animation_start_height_; |
88 | 72 |
89 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleView); | 73 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleView); |
90 }; | 74 }; |
91 | 75 |
92 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_BUBBLE_VIEW_H_ | 76 #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_BUBBLE_VIEW_H_ |
OLD | NEW |