Chromium Code Reviews| Index: chrome/browser/ui/views/page_info_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info_bubble_view.cc |
| index 9a6dbedc8c04462ba8c3cb43d552daf2849157c5..0e1bbdd0d53deb39bf57967f133c21dc17daa49c 100644 |
| --- a/chrome/browser/ui/views/page_info_bubble_view.cc |
| +++ b/chrome/browser/ui/views/page_info_bubble_view.cc |
| @@ -30,6 +30,9 @@ |
| namespace { |
| +// TODO(msw): Get color from theme/window color. |
| +const SkColor kColor = SK_ColorWHITE; |
| + |
| // Layout constants. |
| const int kHGapToBorder = 11; |
| const int kVerticalSectionPadding = 8; |
| @@ -98,22 +101,19 @@ class Section : public views::View, |
| //////////////////////////////////////////////////////////////////////////////// |
| // PageInfoBubbleView |
| -Bubble* PageInfoBubbleView::bubble_ = NULL; |
| - |
| -PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, |
| +PageInfoBubbleView::PageInfoBubbleView(const views::View* anchor_view, |
| Profile* profile, |
| const GURL& url, |
| const NavigationEntry::SSLStatus& ssl, |
| bool show_history) |
| - : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, |
| + : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT, kColor), |
| + ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, |
| show_history, this)), |
| - parent_window_(parent_window), |
| cert_id_(ssl.cert_id()), |
| help_center_link_(NULL), |
| ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), |
| animation_start_height_(0) { |
| - if (bubble_) |
| - bubble_->Close(); |
| + |
| if (cert_id_ > 0) { |
| scoped_refptr<net::X509Certificate> cert; |
| CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); |
| @@ -127,10 +127,13 @@ PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, |
| } |
| PageInfoBubbleView::~PageInfoBubbleView() { |
| + resize_animation_.Reset(); |
| } |
| void PageInfoBubbleView::ShowCertDialog() { |
| - ShowCertificateViewerByID(parent_window_, cert_id_); |
| + gfx::NativeWindow parent = |
| + anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; |
| + ShowCertificateViewerByID(parent, cert_id_); |
| } |
| gfx::Size PageInfoBubbleView::GetSeparatorSize() { |
| @@ -288,36 +291,20 @@ void PageInfoBubbleView::OnPageInfoModelChanged() { |
| // animation. |
| // TODO(derat): Remove this once we're not using a toplevel X window for the |
| // bubble. |
|
Finnur
2011/11/15 10:05:01
What's the status on this comment? Is there still
msw
2011/11/15 20:16:57
Just tested; the jank is still there; leaving this
|
| - bubble_->SizeToContents(); |
| + SizeToContents(); |
| #else |
| resize_animation_.SetSlideDuration(kPageInfoSlideDuration); |
| resize_animation_.Show(); |
| #endif |
| } |
| -void PageInfoBubbleView::BubbleClosing(Bubble* bubble, bool closed_by_escape) { |
| - resize_animation_.Reset(); |
| - bubble_ = NULL; |
| -} |
| - |
| -bool PageInfoBubbleView::CloseOnEscape() { |
| - return true; |
| -} |
| - |
| -bool PageInfoBubbleView::FadeInOnShow() { |
| - return false; |
| -} |
| - |
| -string16 PageInfoBubbleView::GetAccessibleName() { |
|
alicet1
2011/11/15 02:02:13
where did this go?
msw
2011/11/15 20:16:57
GetAccessibleName was only ever used on the Window
|
| - return ASCIIToUTF16("PageInfoBubble"); |
| +gfx::Point PageInfoBubbleView::GetAnchorPoint() { |
| + // Compensate for some built-in padding in the icon. |
| + gfx::Point anchor(BubbleDelegateView::GetAnchorPoint()); |
| + return anchor_view() ? anchor.Subtract(gfx::Point(0, 5)) : anchor; |
| } |
| void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
| - // We want to make sure the info bubble closes once the link is activated. So |
| - // we close it explicitly rather than relying on a side-effect of opening a |
| - // new tab (see http://crosbug.com/10186). |
| - bubble_->Close(); |
|
Finnur
2011/11/15 10:05:01
I remember this problem. Do you now guarantee that
msw
2011/11/15 20:16:57
This bubble does indeed close on deactivate on my
|
| - |
| GURL url = google_util::AppendGoogleLocaleParam( |
| GURL(chrome::kPageInfoHelpCenterURL)); |
| Browser* browser = BrowserList::GetLastActive(); |
| @@ -326,13 +313,21 @@ void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
| } |
|
alicet1
2011/11/15 02:02:13
The bubble will be closed on deactivation. add a c
msw
2011/11/15 20:16:57
Done.
|
| void PageInfoBubbleView::AnimationEnded(const ui::Animation* animation) { |
| - LayoutSections(); |
| - bubble_->SizeToContents(); |
| + if (animation == &resize_animation_) { |
| + LayoutSections(); |
| + SizeToContents(); |
| + } else { |
| + BubbleDelegateView::AnimationEnded(animation); |
| + } |
|
Finnur
2011/11/15 10:05:01
Out of curiosity... is there a specific reason for
msw
2011/11/15 20:16:57
BubbleDelegateView was DCHECKing that it only gets
|
| } |
| void PageInfoBubbleView::AnimationProgressed(const ui::Animation* animation) { |
| - LayoutSections(); |
| - bubble_->SizeToContents(); |
| + if (animation == &resize_animation_) { |
| + LayoutSections(); |
| + SizeToContents(); |
| + } else { |
| + BubbleDelegateView::AnimationProgressed(animation); |
| + } |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -477,33 +472,15 @@ gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) { |
| namespace browser { |
| -void ShowPageInfoBubble(BrowserView* browser_view, |
| +void ShowPageInfoBubble(const views::View* anchor_view, |
| Profile* profile, |
| const GURL& url, |
| const NavigationEntry::SSLStatus& ssl, |
| bool show_history) { |
| - // Find where to point the bubble at. |
| - gfx::Point point; |
| - if (base::i18n::IsRTL()) { |
| - int width = browser_view->toolbar()->location_bar()->width(); |
| - point = gfx::Point(width - kIconHorizontalOffset, 0); |
| - } |
| - point.Offset(0, kIconVerticalOffset); |
| - views::View::ConvertPointToScreen(browser_view->toolbar()->location_bar(), |
| - &point); |
| - gfx::Rect bounds = browser_view->toolbar()->location_bar()->bounds(); |
| - bounds.set_origin(point); |
| - bounds.set_width(kIconHorizontalOffset); |
| - |
| - // Show the bubble. If the bubble already exist - it will be closed first. |
| PageInfoBubbleView* page_info_bubble = |
| - new PageInfoBubbleView(browser_view->GetNativeHandle(), |
| - profile, url, ssl, show_history); |
| - Bubble* bubble = |
| - Bubble::Show(browser_view->GetWidget(), bounds, |
| - views::BubbleBorder::TOP_LEFT, |
| - views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, |
| - page_info_bubble, page_info_bubble); |
| - page_info_bubble->set_bubble(bubble); |
| + new PageInfoBubbleView(anchor_view, profile, url, ssl, show_history); |
| + views::BubbleDelegateView::CreateBubble(page_info_bubble); |
| + page_info_bubble->Show(); |
| } |
| + |
| } |