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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 //////////////////////////////////////////////////////////////////////////////// | 101 //////////////////////////////////////////////////////////////////////////////// |
102 // PageInfoBubbleView | 102 // PageInfoBubbleView |
103 | 103 |
104 PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view, | 104 PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view, |
105 Profile* profile, | 105 Profile* profile, |
106 const GURL& url, | 106 const GURL& url, |
107 const SSLStatus& ssl, | 107 const SSLStatus& ssl, |
108 bool show_history) | 108 bool show_history, |
| 109 content::PageNavigator* navigator) |
109 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 110 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
110 ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, | 111 ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, |
111 show_history, this)), | 112 show_history, this)), |
112 cert_id_(ssl.cert_id), | 113 cert_id_(ssl.cert_id), |
113 help_center_link_(NULL), | 114 help_center_link_(NULL), |
114 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), | 115 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), |
115 animation_start_height_(0) { | 116 animation_start_height_(0), |
| 117 navigator_(navigator) { |
116 | 118 |
117 if (cert_id_ > 0) { | 119 if (cert_id_ > 0) { |
118 scoped_refptr<net::X509Certificate> cert; | 120 scoped_refptr<net::X509Certificate> cert; |
119 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); | 121 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); |
120 // When running with fake certificate (Chrome Frame), we have no os | 122 // When running with fake certificate (Chrome Frame), we have no os |
121 // certificate, so there is no cert to show. Don't bother showing the cert | 123 // certificate, so there is no cert to show. Don't bother showing the cert |
122 // info link in that case. | 124 // info link in that case. |
123 if (!cert.get() || !cert->os_cert_handle()) | 125 if (!cert.get() || !cert->os_cert_handle()) |
124 cert_id_ = 0; | 126 cert_id_ = 0; |
125 } | 127 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 277 } |
276 | 278 |
277 gfx::Rect PageInfoBubbleView::GetAnchorRect() { | 279 gfx::Rect PageInfoBubbleView::GetAnchorRect() { |
278 // Compensate for some built-in padding in the icon. | 280 // Compensate for some built-in padding in the icon. |
279 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | 281 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); |
280 anchor.Inset(0, anchor_view() ? 5 : 0); | 282 anchor.Inset(0, anchor_view() ? 5 : 0); |
281 return anchor; | 283 return anchor; |
282 } | 284 } |
283 | 285 |
284 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { | 286 void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) { |
285 Browser* browser = BrowserList::GetLastActive(); | 287 navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), |
286 OpenURLParams params( | 288 Referrer(), |
287 GURL(chrome::kPageInfoHelpCenterURL), Referrer(), NEW_FOREGROUND_TAB, | 289 NEW_FOREGROUND_TAB, |
288 content::PAGE_TRANSITION_LINK, false); | 290 content::PAGE_TRANSITION_LINK, |
289 browser->OpenURL(params); | 291 false)); |
290 // NOTE: The bubble closes automatically on deactivation as the link opens. | 292 // NOTE: The bubble closes automatically on deactivation as the link opens. |
291 } | 293 } |
292 | 294 |
293 void PageInfoBubbleView::AnimationEnded(const ui::Animation* animation) { | 295 void PageInfoBubbleView::AnimationEnded(const ui::Animation* animation) { |
294 if (animation == &resize_animation_) { | 296 if (animation == &resize_animation_) { |
295 LayoutSections(); | 297 LayoutSections(); |
296 SizeToContents(); | 298 SizeToContents(); |
297 } | 299 } |
298 BubbleDelegateView::AnimationEnded(animation); | 300 BubbleDelegateView::AnimationEnded(animation); |
299 } | 301 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 y = std::max(y, (2 * kVerticalSectionPadding) + image_height); | 447 y = std::max(y, (2 * kVerticalSectionPadding) + image_height); |
446 return gfx::Size(width, y); | 448 return gfx::Size(width, y); |
447 } | 449 } |
448 | 450 |
449 namespace browser { | 451 namespace browser { |
450 | 452 |
451 void ShowPageInfoBubble(views::View* anchor_view, | 453 void ShowPageInfoBubble(views::View* anchor_view, |
452 Profile* profile, | 454 Profile* profile, |
453 const GURL& url, | 455 const GURL& url, |
454 const SSLStatus& ssl, | 456 const SSLStatus& ssl, |
455 bool show_history) { | 457 bool show_history, |
| 458 content::PageNavigator* navigator) { |
456 PageInfoBubbleView* page_info_bubble = | 459 PageInfoBubbleView* page_info_bubble = |
457 new PageInfoBubbleView(anchor_view, profile, url, ssl, show_history); | 460 new PageInfoBubbleView(anchor_view, |
| 461 profile, |
| 462 url, |
| 463 ssl, |
| 464 show_history, |
| 465 navigator); |
458 views::BubbleDelegateView::CreateBubble(page_info_bubble); | 466 views::BubbleDelegateView::CreateBubble(page_info_bubble); |
459 page_info_bubble->Show(); | 467 page_info_bubble->Show(); |
460 } | 468 } |
461 | 469 |
462 } | 470 } |
OLD | NEW |