OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/cert_store.h" | 9 #include "chrome/browser/cert_store.h" |
10 #include "chrome/browser/certificate_viewer.h" | 10 #include "chrome/browser/certificate_viewer.h" |
11 #include "chrome/browser/google/google_util.h" | 11 #include "chrome/browser/google/google_util.h" |
12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
13 #include "chrome/browser/ui/views/info_bubble.h" | 13 #include "chrome/browser/ui/views/info_bubble.h" |
14 #include "chrome/browser/ui/views/toolbar_view.h" | 14 #include "chrome/browser/ui/views/toolbar_view.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "grit/locale_settings.h" | 17 #include "grit/locale_settings.h" |
18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/gfx/image.h" |
19 #include "views/controls/image_view.h" | 20 #include "views/controls/image_view.h" |
20 #include "views/controls/label.h" | 21 #include "views/controls/label.h" |
21 #include "views/controls/separator.h" | 22 #include "views/controls/separator.h" |
22 #include "views/layout/grid_layout.h" | 23 #include "views/layout/grid_layout.h" |
23 #include "views/widget/widget.h" | 24 #include "views/widget/widget.h" |
24 #include "views/window/window.h" | 25 #include "views/window/window.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Layout constants. | 29 // Layout constants. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 views::GridLayout::FILL, // Vertical resize. | 136 views::GridLayout::FILL, // Vertical resize. |
136 1, // Resize weight. | 137 1, // Resize weight. |
137 views::GridLayout::USE_PREF, // Size type. | 138 views::GridLayout::USE_PREF, // Size type. |
138 0, // Ignored for USE_PREF. | 139 0, // Ignored for USE_PREF. |
139 0); // Minimum size. | 140 0); // Minimum size. |
140 | 141 |
141 int count = model_.GetSectionCount(); | 142 int count = model_.GetSectionCount(); |
142 for (int i = 0; i < count; ++i) { | 143 for (int i = 0; i < count; ++i) { |
143 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); | 144 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); |
144 layout->StartRow(0, 0); | 145 layout->StartRow(0, 0); |
145 const SkBitmap* icon = model_.GetIconImage(info.icon_id); | 146 const SkBitmap* icon = *model_.GetIconImage(info.icon_id); |
146 layout->AddView(new Section(this, info, icon, cert_id_ > 0)); | 147 layout->AddView(new Section(this, info, icon, cert_id_ > 0)); |
147 | 148 |
148 // Add separator after all sections. | 149 // Add separator after all sections. |
149 layout->AddPaddingRow(0, kPaddingAboveSeparator); | 150 layout->AddPaddingRow(0, kPaddingAboveSeparator); |
150 layout->StartRow(0, 0); | 151 layout->StartRow(0, 0); |
151 layout->AddView(new views::Separator()); | 152 layout->AddView(new views::Separator()); |
152 layout->AddPaddingRow(0, kPaddingBelowSeparator); | 153 layout->AddPaddingRow(0, kPaddingBelowSeparator); |
153 } | 154 } |
154 | 155 |
155 // Then add the help center link at the bottom. | 156 // Then add the help center link at the bottom. |
156 layout->StartRow(0, 1); | 157 layout->StartRow(0, 1); |
157 help_center_link_ = new views::Link( | 158 help_center_link_ = new views::Link( |
158 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PAGE_INFO_HELP_CENTER_LINK))); | 159 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PAGE_INFO_HELP_CENTER_LINK))); |
159 help_center_link_->SetController(this); | 160 help_center_link_->SetController(this); |
160 layout->AddView(help_center_link_); | 161 layout->AddView(help_center_link_); |
161 } | 162 } |
162 | 163 |
163 gfx::Size PageInfoBubbleView::GetPreferredSize() { | 164 gfx::Size PageInfoBubbleView::GetPreferredSize() { |
164 gfx::Size size(views::Window::GetLocalizedContentsSize( | 165 gfx::Size size(views::Window::GetLocalizedContentsSize( |
165 IDS_PAGEINFOBUBBLE_WIDTH_CHARS, IDS_PAGEINFOBUBBLE_HEIGHT_LINES)); | 166 IDS_PAGEINFOBUBBLE_WIDTH_CHARS, IDS_PAGEINFOBUBBLE_HEIGHT_LINES)); |
166 size.set_height(0); | 167 size.set_height(0); |
167 | 168 |
168 int count = model_.GetSectionCount(); | 169 int count = model_.GetSectionCount(); |
169 for (int i = 0; i < count; ++i) { | 170 for (int i = 0; i < count; ++i) { |
170 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); | 171 PageInfoModel::SectionInfo info = model_.GetSectionInfo(i); |
171 const SkBitmap* icon = model_.GetIconImage(info.icon_id); | 172 const SkBitmap* icon = *model_.GetIconImage(info.icon_id); |
172 Section section(this, info, icon, cert_id_ > 0); | 173 Section section(this, info, icon, cert_id_ > 0); |
173 size.Enlarge(0, section.GetHeightForWidth(size.width())); | 174 size.Enlarge(0, section.GetHeightForWidth(size.width())); |
174 } | 175 } |
175 | 176 |
176 // Calculate how much space the separators take up (with padding). | 177 // Calculate how much space the separators take up (with padding). |
177 views::Separator separator; | 178 views::Separator separator; |
178 gfx::Size separator_size = separator.GetPreferredSize(); | 179 gfx::Size separator_size = separator.GetPreferredSize(); |
179 gfx::Size separator_plus_padding(0, separator_size.height() + | 180 gfx::Size separator_plus_padding(0, separator_size.height() + |
180 kPaddingAboveSeparator + | 181 kPaddingAboveSeparator + |
181 kPaddingBelowSeparator); | 182 kPaddingBelowSeparator); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 PageInfoBubbleView* page_info_bubble = | 352 PageInfoBubbleView* page_info_bubble = |
352 new PageInfoBubbleView(parent, profile, url, ssl, show_history); | 353 new PageInfoBubbleView(parent, profile, url, ssl, show_history); |
353 InfoBubble* info_bubble = | 354 InfoBubble* info_bubble = |
354 InfoBubble::Show(browser_view->GetWidget(), bounds, | 355 InfoBubble::Show(browser_view->GetWidget(), bounds, |
355 BubbleBorder::TOP_LEFT, | 356 BubbleBorder::TOP_LEFT, |
356 page_info_bubble, page_info_bubble); | 357 page_info_bubble, page_info_bubble); |
357 page_info_bubble->set_info_bubble(info_bubble); | 358 page_info_bubble->set_info_bubble(info_bubble); |
358 } | 359 } |
359 | 360 |
360 } | 361 } |
OLD | NEW |