| OLD | NEW |
| 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/certificate_viewer.h" | 10 #include "chrome/browser/certificate_viewer.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 gfx::Size LayoutItems(bool compute_bounds_only, int width); | 55 gfx::Size LayoutItems(bool compute_bounds_only, int width); |
| 56 | 56 |
| 57 // The view that owns this Section object. | 57 // The view that owns this Section object. |
| 58 PageInfoBubbleView* owner_; | 58 PageInfoBubbleView* owner_; |
| 59 | 59 |
| 60 // The information this view represents. | 60 // The information this view represents. |
| 61 PageInfoModel::SectionInfo info_; | 61 PageInfoModel::SectionInfo info_; |
| 62 | 62 |
| 63 static SkBitmap* good_state_icon_; | 63 static SkBitmap* good_state_icon_; |
| 64 static SkBitmap* bad_state_icon_; | 64 static SkBitmap* bad_state_icon_; |
| 65 static SkBitmap* mixed_state_icon_; |
| 65 | 66 |
| 66 views::ImageView* status_image_; | 67 views::ImageView* status_image_; |
| 67 views::Label* headline_label_; | 68 views::Label* headline_label_; |
| 68 views::Label* description_label_; | 69 views::Label* description_label_; |
| 69 views::Link* link_; | 70 views::Link* link_; |
| 70 | 71 |
| 71 DISALLOW_COPY_AND_ASSIGN(Section); | 72 DISALLOW_COPY_AND_ASSIGN(Section); |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 // static | 75 // static |
| 75 SkBitmap* Section::good_state_icon_ = NULL; | 76 SkBitmap* Section::good_state_icon_ = NULL; |
| 76 SkBitmap* Section::bad_state_icon_ = NULL; | 77 SkBitmap* Section::bad_state_icon_ = NULL; |
| 78 SkBitmap* Section::mixed_state_icon_ = NULL; |
| 77 | 79 |
| 78 } // namespace | 80 } // namespace |
| 79 | 81 |
| 80 //////////////////////////////////////////////////////////////////////////////// | 82 //////////////////////////////////////////////////////////////////////////////// |
| 81 // PageInfoBubbleView | 83 // PageInfoBubbleView |
| 82 | 84 |
| 83 PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, | 85 PageInfoBubbleView::PageInfoBubbleView(gfx::NativeWindow parent_window, |
| 84 Profile* profile, | 86 Profile* profile, |
| 85 const GURL& url, | 87 const GURL& url, |
| 86 const NavigationEntry::SSLStatus& ssl, | 88 const NavigationEntry::SSLStatus& ssl, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Section | 164 // Section |
| 163 | 165 |
| 164 Section::Section(PageInfoBubbleView* owner, | 166 Section::Section(PageInfoBubbleView* owner, |
| 165 const PageInfoModel::SectionInfo& section_info) | 167 const PageInfoModel::SectionInfo& section_info) |
| 166 : owner_(owner), | 168 : owner_(owner), |
| 167 info_(section_info) { | 169 info_(section_info) { |
| 168 if (!good_state_icon_) { | 170 if (!good_state_icon_) { |
| 169 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 171 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 170 good_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_GOOD); | 172 good_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_GOOD); |
| 171 bad_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_BAD); | 173 bad_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_BAD); |
| 174 mixed_state_icon_ = rb.GetBitmapNamed(IDR_PAGEINFO_MIXED); |
| 172 } | 175 } |
| 173 | 176 |
| 174 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY || | 177 if (info_.type == PageInfoModel::SECTION_INFO_IDENTITY || |
| 175 info_.type == PageInfoModel::SECTION_INFO_CONNECTION) { | 178 info_.type == PageInfoModel::SECTION_INFO_CONNECTION) { |
| 176 status_image_ = new views::ImageView(); | 179 status_image_ = new views::ImageView(); |
| 177 status_image_->SetImage(info_.state ? good_state_icon_ : bad_state_icon_); | 180 switch (info_.state) { |
| 181 case PageInfoModel::SECTION_STATE_OK: |
| 182 status_image_->SetImage(good_state_icon_); |
| 183 break; |
| 184 case PageInfoModel::SECTION_STATE_WARNING: |
| 185 DCHECK(info_.type == PageInfoModel::SECTION_INFO_CONNECTION); |
| 186 status_image_->SetImage(mixed_state_icon_); |
| 187 break; |
| 188 case PageInfoModel::SECTION_STATE_ERROR: |
| 189 status_image_->SetImage(bad_state_icon_); |
| 190 break; |
| 191 default: |
| 192 NOTREACHED(); // Do you need to add a case here? |
| 193 } |
| 178 AddChildView(status_image_); | 194 AddChildView(status_image_); |
| 179 } | 195 } |
| 180 | 196 |
| 181 headline_label_ = new views::Label(UTF16ToWideHack(info_.headline)); | 197 headline_label_ = new views::Label(UTF16ToWideHack(info_.headline)); |
| 182 headline_label_->SetFont( | 198 headline_label_->SetFont( |
| 183 headline_label_->font().DeriveFont(0, gfx::Font::BOLD)); | 199 headline_label_->font().DeriveFont(0, gfx::Font::BOLD)); |
| 184 headline_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 200 headline_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 185 AddChildView(headline_label_); | 201 AddChildView(headline_label_); |
| 186 | 202 |
| 187 description_label_ = new views::Label(UTF16ToWideHack(info_.description)); | 203 description_label_ = new views::Label(UTF16ToWideHack(info_.description)); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 PageInfoBubbleView* page_info_bubble = | 297 PageInfoBubbleView* page_info_bubble = |
| 282 new PageInfoBubbleView(parent, profile, url, ssl, show_history); | 298 new PageInfoBubbleView(parent, profile, url, ssl, show_history); |
| 283 InfoBubble* info_bubble = | 299 InfoBubble* info_bubble = |
| 284 InfoBubble::Show(browser_view->GetWidget(), bounds, | 300 InfoBubble::Show(browser_view->GetWidget(), bounds, |
| 285 BubbleBorder::TOP_LEFT, | 301 BubbleBorder::TOP_LEFT, |
| 286 page_info_bubble, page_info_bubble); | 302 page_info_bubble, page_info_bubble); |
| 287 page_info_bubble->set_info_bubble(info_bubble); | 303 page_info_bubble->set_info_bubble(info_bubble); |
| 288 } | 304 } |
| 289 | 305 |
| 290 } | 306 } |
| OLD | NEW |