OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/views/page_info_bubble_view.h" | 5 #include "chrome/browser/ui/views/page_info_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/certificate_viewer.h" | 10 #include "chrome/browser/certificate_viewer.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 114 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
115 ALLOW_THIS_IN_INITIALIZER_LIST(model_( | 115 ALLOW_THIS_IN_INITIALIZER_LIST(model_( |
116 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url, | 116 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url, |
117 ssl, show_history, this)), | 117 ssl, show_history, this)), |
118 cert_id_(ssl.cert_id), | 118 cert_id_(ssl.cert_id), |
119 help_center_link_(NULL), | 119 help_center_link_(NULL), |
120 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), | 120 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), |
121 animation_start_height_(0), | 121 animation_start_height_(0), |
122 navigator_(navigator), | 122 navigator_(navigator), |
123 web_contents_(web_contents) { | 123 web_contents_(web_contents) { |
| 124 // Compensate for built-in vertical padding in the anchor view's image. |
| 125 set_anchor_insets(gfx::Insets(5, 0, 5, 0)); |
| 126 |
124 if (cert_id_ > 0) { | 127 if (cert_id_ > 0) { |
125 scoped_refptr<net::X509Certificate> cert; | 128 scoped_refptr<net::X509Certificate> cert; |
126 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); | 129 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); |
127 // When running with fake certificate (Chrome Frame), we have no os | 130 // When running with fake certificate (Chrome Frame), we have no os |
128 // certificate, so there is no cert to show. Don't bother showing the cert | 131 // certificate, so there is no cert to show. Don't bother showing the cert |
129 // info link in that case. | 132 // info link in that case. |
130 if (!cert.get() || !cert->os_cert_handle()) | 133 if (!cert.get() || !cert->os_cert_handle()) |
131 cert_id_ = 0; | 134 cert_id_ = 0; |
132 } | 135 } |
133 LayoutSections(); | 136 LayoutSections(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 void PageInfoBubbleView::OnPageInfoModelChanged() { | 279 void PageInfoBubbleView::OnPageInfoModelChanged() { |
277 // The start height must take into account that when we start animating, | 280 // The start height must take into account that when we start animating, |
278 // a separator plus padding is immediately added before the view is animated | 281 // a separator plus padding is immediately added before the view is animated |
279 // into existence. | 282 // into existence. |
280 animation_start_height_ = bounds().height() + GetSeparatorSize().height(); | 283 animation_start_height_ = bounds().height() + GetSeparatorSize().height(); |
281 LayoutSections(); | 284 LayoutSections(); |
282 resize_animation_.SetSlideDuration(kPageInfoSlideDuration); | 285 resize_animation_.SetSlideDuration(kPageInfoSlideDuration); |
283 resize_animation_.Show(); | 286 resize_animation_.Show(); |
284 } | 287 } |
285 | 288 |
286 gfx::Rect PageInfoBubbleView::GetAnchorRect() { | |
287 // Compensate for some built-in padding in the icon. | |
288 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | |
289 anchor.Inset(0, anchor_view() ? 5 : 0); | |
290 return anchor; | |
291 } | |
292 | |
293 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { | 289 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
294 navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), | 290 navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), |
295 Referrer(), | 291 Referrer(), |
296 NEW_FOREGROUND_TAB, | 292 NEW_FOREGROUND_TAB, |
297 content::PAGE_TRANSITION_LINK, | 293 content::PAGE_TRANSITION_LINK, |
298 false)); | 294 false)); |
299 // NOTE: The bubble closes automatically on deactivation as the link opens. | 295 // NOTE: The bubble closes automatically on deactivation as the link opens. |
300 } | 296 } |
301 | 297 |
302 void PageInfoBubbleView::AnimationEnded(const ui::Animation* animation) { | 298 void PageInfoBubbleView::AnimationEnded(const ui::Animation* animation) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 web_contents, | 469 web_contents, |
474 url, | 470 url, |
475 ssl, | 471 ssl, |
476 show_history, | 472 show_history, |
477 navigator); | 473 navigator); |
478 views::BubbleDelegateView::CreateBubble(page_info_bubble); | 474 views::BubbleDelegateView::CreateBubble(page_info_bubble); |
479 page_info_bubble->Show(); | 475 page_info_bubble->Show(); |
480 } | 476 } |
481 | 477 |
482 } // namespace chrome | 478 } // namespace chrome |
OLD | NEW |