diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 10:29:55 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 10:29:55 +0000 |
commit | d91220a5c9667e59787c8b835f7687f1e0e8890d (patch) | |
tree | b1272836dc654bf7cf4cb76868a7d9227878e1c2 /chrome/browser/views | |
parent | fa6dbb2dc3daadc84f5ca66404386b80887f737d (diff) | |
download | chromium_src-d91220a5c9667e59787c8b835f7687f1e0e8890d.zip chromium_src-d91220a5c9667e59787c8b835f7687f1e0e8890d.tar.gz chromium_src-d91220a5c9667e59787c8b835f7687f1e0e8890d.tar.bz2 |
Fix a crash when showing the certificate in the SSL info bubble while Gears is in Offline mode.
Also tackled the resize flicker by adding animation.
BUG=59331, 59307
TEST=Contact mpcomplete for details on how to test the crash. For the resize, just make sure the bubble animates after the Site Information is available (most of the time that is almost instantly).
Review URL: http://codereview.chromium.org/3747005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/page_info_bubble_view.cc | 38 | ||||
-rw-r--r-- | chrome/browser/views/page_info_bubble_view.h | 13 |
2 files changed, 48 insertions, 3 deletions
diff --git a/chrome/browser/views/page_info_bubble_view.cc b/chrome/browser/views/page_info_bubble_view.cc index 7584947..0aa1d71 100644 --- a/chrome/browser/views/page_info_bubble_view.cc +++ b/chrome/browser/views/page_info_bubble_view.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/cert_store.h" #include "chrome/browser/certificate_viewer.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/info_bubble.h" @@ -33,6 +34,10 @@ const int kPaddingAboveSeparator = 13; const int kIconHorizontalOffset = 27; const int kIconVerticalOffset = -7; +// The duration of the animation that resizes the bubble once the async +// information is provided through the ModelChanged event. +const int kPageInfoSlideDuration = 300; + // A section contains an image that shows a status (good or bad), a title, an // optional head-line (in bold) and a description. class Section : public views::View, @@ -84,7 +89,18 @@ PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, parent_window_(parent_window), cert_id_(ssl.cert_id()), info_bubble_(NULL), - help_center_link_(NULL) { + help_center_link_(NULL), + ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), + animation_start_height_(0) { + if (cert_id_ > 0) { + scoped_refptr<net::X509Certificate> cert; + CertStore::GetSharedInstance()->RetrieveCert(cert_id_, &cert); + // When running with fake certificate (Chrome Frame) or Gears in offline + // mode, we have no os certificate, so there is no cert to show. Don't + // bother showing the cert info link in that case. + if (!cert.get() || !cert->os_cert_handle()) + cert_id_ = 0; + } LayoutSections(); } @@ -172,12 +188,22 @@ gfx::Size PageInfoBubbleView::GetPreferredSize() { size.Enlarge(0, separator_plus_padding.height() + link_size.height()); + if (!resize_animation_.is_animating()) + return size; + + // We are animating from animation_start_height_ to size. + int target_height = animation_start_height_ + static_cast<int>( + (size.height() - animation_start_height_) * + resize_animation_.GetCurrentValue()); + size.set_height(target_height); return size; } void PageInfoBubbleView::ModelChanged() { + animation_start_height_ = bounds().height(); LayoutSections(); - info_bubble_->SizeToContents(); + resize_animation_.SetSlideDuration(kPageInfoSlideDuration); + resize_animation_.Show(); } void PageInfoBubbleView::LinkActivated(views::Link* source, int event_flags) { @@ -186,6 +212,14 @@ void PageInfoBubbleView::LinkActivated(views::Link* source, int event_flags) { browser->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); } +void PageInfoBubbleView::AnimationEnded(const Animation* animation) { + info_bubble_->SizeToContents(); +} + +void PageInfoBubbleView::AnimationProgressed(const Animation* animation) { + info_bubble_->SizeToContents(); +} + //////////////////////////////////////////////////////////////////////////////// // Section diff --git a/chrome/browser/views/page_info_bubble_view.h b/chrome/browser/views/page_info_bubble_view.h index 8585862..cc8d1f0 100644 --- a/chrome/browser/views/page_info_bubble_view.h +++ b/chrome/browser/views/page_info_bubble_view.h @@ -18,7 +18,8 @@ class Label; class PageInfoBubbleView : public views::View, public PageInfoModel::PageInfoModelObserver, public InfoBubbleDelegate, - public views::LinkController { + public views::LinkController, + public AnimationDelegate { public: PageInfoBubbleView(gfx::NativeWindow parent_window, Profile* profile, @@ -48,6 +49,10 @@ class PageInfoBubbleView : public views::View, // LinkController methods: virtual void LinkActivated(views::Link* source, int event_flags); + // Overridden from AnimationDelegate. + virtual void AnimationEnded(const Animation* animation); + virtual void AnimationProgressed(const Animation* animation); + private: // Layout the sections within the bubble. void LayoutSections(); @@ -66,6 +71,12 @@ class PageInfoBubbleView : public views::View, // The Help Center link at the bottom of the bubble. views::Link* help_center_link_; + // Animation that helps us change size smoothly as more data comes in. + SlideAnimation resize_animation_; + + // The height of the info bubble at the start of the resize animation. + int animation_start_height_; + DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleView); }; |