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

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: 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"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 DISALLOW_COPY_AND_ASSIGN(Section); 97 DISALLOW_COPY_AND_ASSIGN(Section);
97 }; 98 };
98 99
99 } // namespace 100 } // namespace
100 101
101 //////////////////////////////////////////////////////////////////////////////// 102 ////////////////////////////////////////////////////////////////////////////////
102 // PageInfoBubbleView 103 // PageInfoBubbleView
103 104
104 PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view, 105 PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view,
105 Profile* profile, 106 TabContents* tab_contents,
106 const GURL& url, 107 const GURL& url,
107 const SSLStatus& ssl, 108 const SSLStatus& ssl,
108 bool show_history, 109 bool show_history,
109 content::PageNavigator* navigator) 110 content::PageNavigator* navigator)
110 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 111 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
111 ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, 112 ALLOW_THIS_IN_INITIALIZER_LIST(model_(tab_contents->profile(), url, ssl,
112 show_history, this)), 113 show_history, this)),
113 cert_id_(ssl.cert_id), 114 cert_id_(ssl.cert_id),
114 help_center_link_(NULL), 115 help_center_link_(NULL),
115 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)), 116 ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)),
116 animation_start_height_(0), 117 animation_start_height_(0),
117 navigator_(navigator) { 118 navigator_(navigator),
118 119 tab_contents_(tab_contents) {
119 if (cert_id_ > 0) { 120 if (cert_id_ > 0) {
120 scoped_refptr<net::X509Certificate> cert; 121 scoped_refptr<net::X509Certificate> cert;
121 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); 122 content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert);
122 // When running with fake certificate (Chrome Frame), we have no os 123 // 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 124 // certificate, so there is no cert to show. Don't bother showing the cert
124 // info link in that case. 125 // info link in that case.
125 if (!cert.get() || !cert->os_cert_handle()) 126 if (!cert.get() || !cert->os_cert_handle())
126 cert_id_ = 0; 127 cert_id_ = 0;
127 } 128 }
128 LayoutSections(); 129 LayoutSections();
129 } 130 }
130 131
131 PageInfoBubbleView::~PageInfoBubbleView() { 132 PageInfoBubbleView::~PageInfoBubbleView() {
132 resize_animation_.Reset(); 133 resize_animation_.Reset();
133 } 134 }
134 135
135 void PageInfoBubbleView::ShowCertDialog() { 136 void PageInfoBubbleView::ShowCertDialog() {
136 gfx::NativeWindow parent = 137 gfx::NativeWindow parent =
137 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; 138 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL;
138 ShowCertificateViewerByID(parent, cert_id_); 139 ShowCertificateViewerByID(tab_contents_, parent, cert_id_);
139 } 140 }
140 141
141 gfx::Size PageInfoBubbleView::GetSeparatorSize() { 142 gfx::Size PageInfoBubbleView::GetSeparatorSize() {
142 // Calculate how much space the separators take up (with padding). 143 // Calculate how much space the separators take up (with padding).
143 views::Separator separator; 144 views::Separator separator;
144 gfx::Size separator_size = separator.GetPreferredSize(); 145 gfx::Size separator_size = separator.GetPreferredSize();
145 gfx::Size separator_plus_padding(0, separator_size.height() + 146 gfx::Size separator_plus_padding(0, separator_size.height() +
146 kPaddingAboveSeparator + 147 kPaddingAboveSeparator +
147 kPaddingBelowSeparator); 148 kPaddingBelowSeparator);
148 return separator_plus_padding; 149 return separator_plus_padding;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 447 }
447 448
448 // Make sure the image is not truncated if the text doesn't contain much. 449 // Make sure the image is not truncated if the text doesn't contain much.
449 y = std::max(y, (2 * kVerticalSectionPadding) + image_height); 450 y = std::max(y, (2 * kVerticalSectionPadding) + image_height);
450 return gfx::Size(width, y); 451 return gfx::Size(width, y);
451 } 452 }
452 453
453 namespace browser { 454 namespace browser {
454 455
455 void ShowPageInfoBubble(views::View* anchor_view, 456 void ShowPageInfoBubble(views::View* anchor_view,
456 Profile* profile, 457 TabContents* tab_contents,
457 const GURL& url, 458 const GURL& url,
458 const SSLStatus& ssl, 459 const SSLStatus& ssl,
459 bool show_history, 460 bool show_history,
460 content::PageNavigator* navigator) { 461 content::PageNavigator* navigator) {
461 PageInfoBubbleView* page_info_bubble = 462 PageInfoBubbleView* page_info_bubble =
462 new PageInfoBubbleView(anchor_view, 463 new PageInfoBubbleView(anchor_view,
463 profile, 464 tab_contents,
464 url, 465 url,
465 ssl, 466 ssl,
466 show_history, 467 show_history,
467 navigator); 468 navigator);
468 views::BubbleDelegateView::CreateBubble(page_info_bubble); 469 views::BubbleDelegateView::CreateBubble(page_info_bubble);
469 page_info_bubble->Show(); 470 page_info_bubble->Show();
470 } 471 }
471 472
472 } 473 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698