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

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

Issue 3367007: Page info model now shows red skull and crossbones on SECURITY_STYLE_AUTHENTI... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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
« no previous file with comments | « chrome/browser/page_info_model.cc ('k') | chrome/browser/views/page_info_window_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/page_info_bubble_view.h" 5 #include "chrome/browser/views/page_info_bubble_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 private: 54 private:
55 // Calculate the layout if |compute_bounds_only|, otherwise does Layout also. 55 // Calculate the layout if |compute_bounds_only|, otherwise does Layout also.
56 gfx::Size LayoutItems(bool compute_bounds_only, int width); 56 gfx::Size LayoutItems(bool compute_bounds_only, int width);
57 57
58 // The view that owns this Section object. 58 // The view that owns this Section object.
59 PageInfoBubbleView* owner_; 59 PageInfoBubbleView* owner_;
60 60
61 // The information this view represents. 61 // The information this view represents.
62 PageInfoModel::SectionInfo info_; 62 PageInfoModel::SectionInfo info_;
63 63
64 static SkBitmap* good_state_icon_;
65 static SkBitmap* bad_state_icon_;
66 static SkBitmap* mixed_state_icon_;
67
68 views::ImageView* status_image_; 64 views::ImageView* status_image_;
69 views::Label* headline_label_; 65 views::Label* headline_label_;
70 views::Label* description_label_; 66 views::Label* description_label_;
71 views::Link* link_; 67 views::Link* link_;
72 68
73 DISALLOW_COPY_AND_ASSIGN(Section); 69 DISALLOW_COPY_AND_ASSIGN(Section);
74 }; 70 };
75 71
76 // static
77 SkBitmap* Section::good_state_icon_ = NULL;
78 SkBitmap* Section::bad_state_icon_ = NULL;
79 SkBitmap* Section::mixed_state_icon_ = NULL;
80
81 } // namespace 72 } // namespace
82 73
83 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
84 // PageInfoBubbleView 75 // PageInfoBubbleView
85 76
86 PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, 77 PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window,
87 Profile* profile, 78 Profile* profile,
88 const GURL& url, 79 const GURL& url,
89 const NavigationEntry::SSLStatus& ssl, 80 const NavigationEntry::SSLStatus& ssl,
90 bool show_history) 81 bool show_history)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 174 }
184 175
185 //////////////////////////////////////////////////////////////////////////////// 176 ////////////////////////////////////////////////////////////////////////////////
186 // Section 177 // Section
187 178
188 Section::Section(PageInfoBubbleView* owner, 179 Section::Section(PageInfoBubbleView* owner,
189 const PageInfoModel::SectionInfo& section_info, 180 const PageInfoModel::SectionInfo& section_info,
190 bool show_cert) 181 bool show_cert)
191 : owner_(owner), 182 : owner_(owner),
192 info_(section_info), 183 info_(section_info),
184 status_image_(NULL),
193 link_(NULL) { 185 link_(NULL) {
194 if (!good_state_icon_) { 186 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
195 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
196 good_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_GOOD);
197 bad_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_BAD);
198 mixed_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_MIXED);
199 }
200 187
201 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY || 188 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY ||
202 info_.type == PageInfoModel::SECTION_INFO_CONNECTION) { 189 info_.type == PageInfoModel::SECTION_INFO_CONNECTION) {
203 status_image_ = new views::ImageView(); 190 status_image_ = new views::ImageView();
204 switch (info_.state) { 191 switch (info_.state) {
205 case PageInfoModel::SECTION_STATE_OK: 192 case PageInfoModel::SECTION_STATE_OK:
206 status_image_->SetImage(good_state_icon_); 193 status_image_->SetImage(rb.GetBitmapNamed(IDR_PAGEINFO_GOOD));
207 break; 194 break;
208 case PageInfoModel::SECTION_STATE_WARNING: 195 case PageInfoModel::SECTION_STATE_WARNING_MAJOR:
209 DCHECK(info_.type == PageInfoModel::SECTION_INFO_CONNECTION); 196 status_image_->SetImage(rb.GetBitmapNamed(IDR_PAGEINFO_WARNING_MAJOR));
210 status_image_->SetImage(mixed_state_icon_); 197 break;
198 case PageInfoModel::SECTION_STATE_WARNING_MINOR:
199 status_image_->SetImage(rb.GetBitmapNamed(IDR_PAGEINFO_WARNING_MINOR));
211 break; 200 break;
212 case PageInfoModel::SECTION_STATE_ERROR: 201 case PageInfoModel::SECTION_STATE_ERROR:
213 status_image_->SetImage(bad_state_icon_); 202 status_image_->SetImage(rb.GetBitmapNamed(IDR_PAGEINFO_BAD));
214 break; 203 break;
215 default: 204 default:
216 NOTREACHED(); // Do you need to add a case here? 205 NOTREACHED(); // Do you need to add a case here?
217 } 206 }
218 AddChildView(status_image_); 207 AddChildView(status_image_);
208 } else if (info_.type == PageInfoModel::SECTION_INFO_FIRST_VISIT) {
209 status_image_ = new views::ImageView();
210 status_image_->SetImage(info_.state == PageInfoModel::SECTION_STATE_OK ?
211 rb.GetBitmapNamed(IDR_PAGEINFO_INFO) :
212 rb.GetBitmapNamed(IDR_PAGEINFO_WARNING_MAJOR));
213 AddChildView(status_image_);
219 } 214 }
220 215
221 headline_label_ = new views::Label(UTF16ToWideHack(info_.headline)); 216 headline_label_ = new views::Label(UTF16ToWideHack(info_.headline));
222 headline_label_->SetFont( 217 headline_label_->SetFont(
223 headline_label_->font().DeriveFont(0, gfx::Font::BOLD)); 218 headline_label_->font().DeriveFont(0, gfx::Font::BOLD));
224 headline_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 219 headline_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
225 AddChildView(headline_label_); 220 AddChildView(headline_label_);
226 221
227 description_label_ = new views::Label(UTF16ToWideHack(info_.description)); 222 description_label_ = new views::Label(UTF16ToWideHack(info_.description));
228 description_label_->SetMultiLine(true); 223 description_label_->SetMultiLine(true);
(...skipping 25 matching lines...) Expand all
254 void Section::LinkActivated(views::Link* source, int event_flags) { 249 void Section::LinkActivated(views::Link* source, int event_flags) {
255 owner_->ShowCertDialog(); 250 owner_->ShowCertDialog();
256 } 251 }
257 252
258 gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) { 253 gfx::Size Section::LayoutItems(bool compute_bounds_only, int width) {
259 int x = kHGapToBorder; 254 int x = kHGapToBorder;
260 int y = kVGapToImage; 255 int y = kVGapToImage;
261 256
262 // Layout the image, head-line and description. 257 // Layout the image, head-line and description.
263 gfx::Size size; 258 gfx::Size size;
264 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY || 259 if (status_image_) {
265 info_.type == PageInfoModel::SECTION_INFO_CONNECTION) {
266 size = status_image_->GetPreferredSize(); 260 size = status_image_->GetPreferredSize();
267 if (!compute_bounds_only) 261 if (!compute_bounds_only)
268 status_image_->SetBounds(x, y, size.width(), size.height()); 262 status_image_->SetBounds(x, y, size.width(), size.height());
269 } 263 }
270 int image_height = y + size.height(); 264 int image_height = y + size.height();
271 x += size.width() + kHGapImageToDescription; 265 x += size.width() + kHGapImageToDescription;
272 int w = width - x - kTextPaddingRight; 266 int w = width - x - kTextPaddingRight;
273 y = kVGapToHeadline; 267 y = kVGapToHeadline;
274 if (!headline_label_->GetText().empty()) { 268 if (!headline_label_->GetText().empty()) {
275 size = headline_label_->GetPreferredSize(); 269 size = headline_label_->GetPreferredSize();
276 if (!compute_bounds_only) 270 if (!compute_bounds_only)
277 headline_label_->SetBounds(x, y, w > 0 ? w : 0, size.height()); 271 headline_label_->SetBounds(x, y, w > 0 ? w : 0, size.height());
278 y += size.height(); 272 y += size.height();
279 } else { 273 } else {
280 if (!compute_bounds_only) 274 if (!compute_bounds_only)
281 headline_label_->SetBounds(x, y, 0, 0); 275 headline_label_->SetBounds(x, y, 0, 0);
282 } 276 }
283 if (w > 0) { 277 if (w > 0) {
284 int height = description_label_->GetHeightForWidth(w); 278 int height = description_label_->GetHeightForWidth(w);
285 if (!compute_bounds_only) 279 if (!compute_bounds_only)
286 description_label_->SetBounds(x, y, w, height); 280 description_label_->SetBounds(x, y, w, height);
287 y += height; 281 y += height;
288 } else { 282 } else {
289 if (!compute_bounds_only) 283 if (!compute_bounds_only)
290 description_label_->SetBounds(x, y, 0, 0); 284 description_label_->SetBounds(x, y, 0, 0);
291 } 285 }
292 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY && link_) { 286 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY && link_) {
293 size = link_->GetPreferredSize(); 287 size = link_->GetPreferredSize();
294 link_->SetBounds(x, y, size.width(), size.height()); 288 if (!compute_bounds_only)
289 link_->SetBounds(x, y, size.width(), size.height());
295 y += size.height(); 290 y += size.height();
296 } 291 }
297 292
298 // Make sure the image is not truncated if the text doesn't contain much. 293 // Make sure the image is not truncated if the text doesn't contain much.
299 y = std::max(y, image_height); 294 y = std::max(y, image_height);
300 return gfx::Size(width, y); 295 return gfx::Size(width, y);
301 } 296 }
302 297
303 namespace browser { 298 namespace browser {
304 299
(...skipping 20 matching lines...) Expand all
325 PageInfoBubbleView* page_info_bubble = 320 PageInfoBubbleView* page_info_bubble =
326 new PageInfoBubbleView(parent, profile, url, ssl, show_history); 321 new PageInfoBubbleView(parent, profile, url, ssl, show_history);
327 InfoBubble* info_bubble = 322 InfoBubble* info_bubble =
328 InfoBubble::Show(browser_view->GetWidget(), bounds, 323 InfoBubble::Show(browser_view->GetWidget(), bounds,
329 BubbleBorder::TOP_LEFT, 324 BubbleBorder::TOP_LEFT,
330 page_info_bubble, page_info_bubble); 325 page_info_bubble, page_info_bubble);
331 page_info_bubble->set_info_bubble(info_bubble); 326 page_info_bubble->set_info_bubble(info_bubble);
332 } 327 }
333 328
334 } 329 }
OLDNEW
« no previous file with comments | « chrome/browser/page_info_model.cc ('k') | chrome/browser/views/page_info_window_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698