Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: chrome/browser/ui/views/page_info_bubble_view.cc

Issue 10554010: Remove BrowserList::GetLastActive usage from WebUI pages. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: mac build Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/ui/browser_list.h" 11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "chrome/browser/ui/views/toolbar_view.h" 14 #include "chrome/browser/ui/views/toolbar_view.h"
14 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/cert_store.h" 16 #include "content/public/browser/cert_store.h"
16 #include "content/public/common/ssl_status.h" 17 #include "content/public/common/ssl_status.h"
17 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
18 #include "grit/locale_settings.h" 19 #include "grit/locale_settings.h"
19 #include "net/base/x509_certificate.h" 20 #include "net/base/x509_certificate.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 #include "ui/views/controls/image_view.h" 24 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/label.h" 25 #include "ui/views/controls/label.h"
25 #include "ui/views/controls/link.h" 26 #include "ui/views/controls/link.h"
26 #include "ui/views/controls/separator.h" 27 #include "ui/views/controls/separator.h"
27 #include "ui/views/layout/grid_layout.h" 28 #include "ui/views/layout/grid_layout.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 30
30 using content::OpenURLParams; 31 using content::OpenURLParams;
31 using content::Referrer; 32 using content::Referrer;
32 using content::SSLStatus; 33 using content::SSLStatus;
34 using content::WebContents;
33 35
34 namespace { 36 namespace {
35 37
36 // Layout constants. 38 // Layout constants.
37 const int kHGapToBorder = 11; 39 const int kHGapToBorder = 11;
38 const int kVerticalSectionPadding = 8; 40 const int kVerticalSectionPadding = 8;
39 const int kVGapToHeadline = 5; 41 const int kVGapToHeadline = 5;
40 const int kHGapImageToDescription = 6; 42 const int kHGapImageToDescription = 6;
41 const int kTextPaddingRight = 10; 43 const int kTextPaddingRight = 10;
42 const int kPaddingBelowSeparator = 6; 44 const int kPaddingBelowSeparator = 6;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 97
96 DISALLOW_COPY_AND_ASSIGN(Section); 98 DISALLOW_COPY_AND_ASSIGN(Section);
97 }; 99 };
98 100
99 } // namespace 101 } // namespace
100 102
101 //////////////////////////////////////////////////////////////////////////////// 103 ////////////////////////////////////////////////////////////////////////////////
102 // PageInfoBubbleView 104 // PageInfoBubbleView
103 105
104 PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view, 106 PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view,
105 Profile* profile, 107 WebContents* web_contents,
106 const GURL& url, 108 const GURL& url,
107 const SSLStatus& ssl, 109 const SSLStatus& ssl,
108 bool show_history, 110 bool show_history,
109 content::PageNavigator* navigator) 111 content::PageNavigator* navigator)
110 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 112 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
111 ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, 113 ALLOW_THIS_IN_INITIALIZER_LIST(model_(
112 show_history, this)), 114 TabContents::FromWebContents(web_contents)->profile(), url, ssl,
Ben Goodger (Google) 2012/06/19 14:55:07 Profile::FromBrowserContext(web_contents->GetBrows
jam 2012/06/19 15:13:28 Done.
115 show_history, this)),
113 cert_id_(ssl.cert_id), 116 cert_id_(ssl.cert_id),
114 help_center_link_(NULL), 117 help_center_link_(NULL),
115 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), 118 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)),
116 animation_start_height_(0), 119 animation_start_height_(0),
117 navigator_(navigator) { 120 navigator_(navigator),
118 121 web_contents_(web_contents) {
119 if (cert_id_ > 0) { 122 if (cert_id_ > 0) {
120 scoped_refptr<net::X509Certificate> cert; 123 scoped_refptr<net::X509Certificate> cert;
121 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); 124 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert);
122 // When running with fake certificate (Chrome Frame), we have no os 125 // When running with fake certificate (Chrome Frame), we have no os
123 // certificate, so there is no cert to show. Don't bother showing the cert 126 // certificate, so there is no cert to show. Don't bother showing the cert
124 // info link in that case. 127 // info link in that case.
125 if (!cert.get() || !cert->os_cert_handle()) 128 if (!cert.get() || !cert->os_cert_handle())
126 cert_id_ = 0; 129 cert_id_ = 0;
127 } 130 }
128 LayoutSections(); 131 LayoutSections();
129 } 132 }
130 133
131 PageInfoBubbleView::~PageInfoBubbleView() { 134 PageInfoBubbleView::~PageInfoBubbleView() {
132 resize_animation_.Reset(); 135 resize_animation_.Reset();
133 } 136 }
134 137
135 void PageInfoBubbleView::ShowCertDialog() { 138 void PageInfoBubbleView::ShowCertDialog() {
136 gfx::NativeWindow parent = 139 gfx::NativeWindow parent =
137 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; 140 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL;
138 ShowCertificateViewerByID(parent, cert_id_); 141 ShowCertificateViewerByID(web_contents_, parent, cert_id_);
139 } 142 }
140 143
141 gfx::Size PageInfoBubbleView::GetSeparatorSize() { 144 gfx::Size PageInfoBubbleView::GetSeparatorSize() {
142 // Calculate how much space the separators take up (with padding). 145 // Calculate how much space the separators take up (with padding).
143 views::Separator separator; 146 views::Separator separator;
144 gfx::Size separator_size = separator.GetPreferredSize(); 147 gfx::Size separator_size = separator.GetPreferredSize();
145 gfx::Size separator_plus_padding(0, separator_size.height() + 148 gfx::Size separator_plus_padding(0, separator_size.height() +
146 kPaddingAboveSeparator + 149 kPaddingAboveSeparator +
147 kPaddingBelowSeparator); 150 kPaddingBelowSeparator);
148 return separator_plus_padding; 151 return separator_plus_padding;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 449 }
447 450
448 // Make sure the image is not truncated if the text doesn't contain much. 451 // Make sure the image is not truncated if the text doesn't contain much.
449 y = std::max(y, (2 * kVerticalSectionPadding) + image_height); 452 y = std::max(y, (2 * kVerticalSectionPadding) + image_height);
450 return gfx::Size(width, y); 453 return gfx::Size(width, y);
451 } 454 }
452 455
453 namespace browser { 456 namespace browser {
454 457
455 void ShowPageInfoBubble(views::View* anchor_view, 458 void ShowPageInfoBubble(views::View* anchor_view,
456 Profile* profile, 459 WebContents* web_contents,
457 const GURL& url, 460 const GURL& url,
458 const SSLStatus& ssl, 461 const SSLStatus& ssl,
459 bool show_history, 462 bool show_history,
460 content::PageNavigator* navigator) { 463 content::PageNavigator* navigator) {
461 PageInfoBubbleView* page_info_bubble = 464 PageInfoBubbleView* page_info_bubble =
462 new PageInfoBubbleView(anchor_view, 465 new PageInfoBubbleView(anchor_view,
463 profile, 466 web_contents,
464 url, 467 url,
465 ssl, 468 ssl,
466 show_history, 469 show_history,
467 navigator); 470 navigator);
468 views::BubbleDelegateView::CreateBubble(page_info_bubble); 471 views::BubbleDelegateView::CreateBubble(page_info_bubble);
469 page_info_bubble->Show(); 472 page_info_bubble->Show();
470 } 473 }
471 474
472 } 475 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698