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

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

Issue 10453101: Convert most of the rest of chrome to ImageSkia (Closed) Base URL: svn://svn.chromium.org/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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // information is provided through the ModelChanged event. 48 // information is provided through the ModelChanged event.
49 const int kPageInfoSlideDuration = 1450; 49 const int kPageInfoSlideDuration = 1450;
50 50
51 // A section contains an image that shows a status (good or bad), a title, an 51 // A section contains an image that shows a status (good or bad), a title, an
52 // optional head-line (in bold) and a description. 52 // optional head-line (in bold) and a description.
53 class Section : public views::View, 53 class Section : public views::View,
54 public views::LinkListener { 54 public views::LinkListener {
55 public: 55 public:
56 Section(PageInfoBubbleView* owner, 56 Section(PageInfoBubbleView* owner,
57 const PageInfoModel::SectionInfo& section_info, 57 const PageInfoModel::SectionInfo& section_info,
58 const SkBitmap* status_icon, 58 const gfx::ImageSkia* status_icon,
59 bool show_cert); 59 bool show_cert);
60 virtual ~Section(); 60 virtual ~Section();
61 61
62 // Notify the section how far along in the animation we are. This is used 62 // Notify the section how far along in the animation we are. This is used
63 // to draw the section opaquely onto the canvas, to animate the section into 63 // to draw the section opaquely onto the canvas, to animate the section into
64 // view. 64 // view.
65 void SetAnimationStage(double animation_stage); 65 void SetAnimationStage(double animation_stage);
66 66
67 // views::View methods: 67 // views::View methods:
68 virtual int GetHeightForWidth(int w); 68 virtual int GetHeightForWidth(int w);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 0, // Ignored for USE_PREF. 184 0, // Ignored for USE_PREF.
185 0); // Minimum size. 185 0); // Minimum size.
186 186
187 int count = model_.GetSectionCount(); 187 int count = model_.GetSectionCount();
188 bool only_internal_section = false; 188 bool only_internal_section = false;
189 for (int i = 0; i < count; ++i) { 189 for (int i = 0; i < count; ++i) {
190 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); 190 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i);
191 if (count == 1 && info.type == PageInfoModel::SECTION_INFO_INTERNAL_PAGE) 191 if (count == 1 && info.type == PageInfoModel::SECTION_INFO_INTERNAL_PAGE)
192 only_internal_section = true; 192 only_internal_section = true;
193 layout->StartRow(0, 0); 193 layout->StartRow(0, 0);
194 const SkBitmap* icon = model_.GetIconImage(info.icon_id)->ToSkBitmap(); 194 const gfx::ImageSkia* icon = model_.GetIconImage(
195 info.icon_id)->ToImageSkia();
195 Section* section = new Section(this, info, icon, cert_id_ > 0); 196 Section* section = new Section(this, info, icon, cert_id_ > 0);
196 if (info.type == PageInfoModel::SECTION_INFO_FIRST_VISIT) { 197 if (info.type == PageInfoModel::SECTION_INFO_FIRST_VISIT) {
197 // This section is animated into view, so we need to set the height of it 198 // This section is animated into view, so we need to set the height of it
198 // according to the animation stage, and let it know how transparent it 199 // according to the animation stage, and let it know how transparent it
199 // should draw itself. 200 // should draw itself.
200 section->SetAnimationStage(GetResizeAnimationCurrentValue()); 201 section->SetAnimationStage(GetResizeAnimationCurrentValue());
201 gfx::Size sz(views::Widget::GetLocalizedContentsSize( 202 gfx::Size sz(views::Widget::GetLocalizedContentsSize(
202 IDS_PAGEINFOBUBBLE_WIDTH_CHARS, IDS_PAGEINFOBUBBLE_HEIGHT_LINES)); 203 IDS_PAGEINFOBUBBLE_WIDTH_CHARS, IDS_PAGEINFOBUBBLE_HEIGHT_LINES));
203 layout->AddView(section, 204 layout->AddView(section,
204 1, 1, // Colspan & Rowspan. 205 1, 1, // Colspan & Rowspan.
(...skipping 27 matching lines...) Expand all
232 } 233 }
233 234
234 gfx::Size PageInfoBubbleView::GetPreferredSize() { 235 gfx::Size PageInfoBubbleView::GetPreferredSize() {
235 gfx::Size size(views::Widget::GetLocalizedContentsSize( 236 gfx::Size size(views::Widget::GetLocalizedContentsSize(
236 IDS_PAGEINFOBUBBLE_WIDTH_CHARS, IDS_PAGEINFOBUBBLE_HEIGHT_LINES)); 237 IDS_PAGEINFOBUBBLE_WIDTH_CHARS, IDS_PAGEINFOBUBBLE_HEIGHT_LINES));
237 size.set_height(0); 238 size.set_height(0);
238 239
239 int count = model_.GetSectionCount(); 240 int count = model_.GetSectionCount();
240 for (int i = 0; i < count; ++i) { 241 for (int i = 0; i < count; ++i) {
241 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); 242 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i);
242 const SkBitmap* icon = model_.GetIconImage(info.icon_id)->ToSkBitmap(); 243 const gfx::ImageSkia* icon = model_.GetIconImage(
244 info.icon_id)->ToImageSkia();
243 Section section(this, info, icon, cert_id_ > 0); 245 Section section(this, info, icon, cert_id_ > 0);
244 size.Enlarge(0, section.GetHeightForWidth(size.width())); 246 size.Enlarge(0, section.GetHeightForWidth(size.width()));
245 } 247 }
246 248
247 static int separator_plus_padding = GetSeparatorSize().height(); 249 static int separator_plus_padding = GetSeparatorSize().height();
248 250
249 // Account for the separators and padding within sections. 251 // Account for the separators and padding within sections.
250 size.Enlarge(0, (count - 1) * separator_plus_padding); 252 size.Enlarge(0, (count - 1) * separator_plus_padding);
251 253
252 // Account for the Help Center link and the separator above it. 254 // Account for the Help Center link and the separator above it.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 SizeToContents(); 308 SizeToContents();
307 } 309 }
308 BubbleDelegateView::AnimationProgressed(animation); 310 BubbleDelegateView::AnimationProgressed(animation);
309 } 311 }
310 312
311 //////////////////////////////////////////////////////////////////////////////// 313 ////////////////////////////////////////////////////////////////////////////////
312 // Section 314 // Section
313 315
314 Section::Section(PageInfoBubbleView* owner, 316 Section::Section(PageInfoBubbleView* owner,
315 const PageInfoModel::SectionInfo& section_info, 317 const PageInfoModel::SectionInfo& section_info,
316 const SkBitmap* state_icon, 318 const gfx::ImageSkia* state_icon,
317 bool show_cert) 319 bool show_cert)
318 : owner_(owner), 320 : owner_(owner),
319 info_(section_info), 321 info_(section_info),
320 status_image_(NULL), 322 status_image_(NULL),
321 link_(NULL) { 323 link_(NULL) {
322 if (state_icon) { 324 if (state_icon) {
323 status_image_ = new views::ImageView(); 325 status_image_ = new views::ImageView();
324 status_image_->SetImage(*state_icon); 326 status_image_->SetImage(*state_icon);
325 AddChildView(status_image_); 327 AddChildView(status_image_);
326 } 328 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 profile, 463 profile,
462 url, 464 url,
463 ssl, 465 ssl,
464 show_history, 466 show_history,
465 navigator); 467 navigator);
466 views::BubbleDelegateView::CreateBubble(page_info_bubble); 468 views::BubbleDelegateView::CreateBubble(page_info_bubble);
467 page_info_bubble->Show(); 469 page_info_bubble->Show();
468 } 470 }
469 471
470 } 472 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/notifications/balloon_view.cc ('k') | chrome/browser/ui/views/speech_recognition_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698