OLD | NEW |
---|---|
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/website_settings/website_settings_popup_view.h " | 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/certificate_viewer.h" | 9 #include "chrome/browser/certificate_viewer.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 127 |
128 private: | 128 private: |
129 // The label that displays the name of the site's identity. | 129 // The label that displays the name of the site's identity. |
130 views::Label* name_; | 130 views::Label* name_; |
131 // The label that displays the status of the identity check for this site. | 131 // The label that displays the status of the identity check for this site. |
132 views::Label* status_; | 132 views::Label* status_; |
133 | 133 |
134 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); | 134 DISALLOW_COPY_AND_ASSIGN(PopupHeaderView); |
135 }; | 135 }; |
136 | 136 |
137 // Website Settings are not supported for internal Chrome pages. Instead of the | |
138 // |WebsiteSettingsPopupView|, the |InternalPageInfoPopupView| is | |
139 // displayed. | |
140 class InternalPageInfoPopupView : public views::BubbleDelegateView { | |
141 public: | |
142 explicit InternalPageInfoPopupView(views::View* anchor_view); | |
143 virtual ~InternalPageInfoPopupView(); | |
144 | |
145 private: | |
146 // views::BubbleDelegate implementations. | |
147 virtual gfx::Rect GetAnchorRect() OVERRIDE; | |
148 | |
149 DISALLOW_COPY_AND_ASSIGN(InternalPageInfoPopupView); | |
150 }; | |
151 | |
137 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
138 // Popup Header | 153 // Popup Header |
139 //////////////////////////////////////////////////////////////////////////////// | 154 //////////////////////////////////////////////////////////////////////////////// |
140 | 155 |
141 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) | 156 PopupHeaderView::PopupHeaderView(views::ButtonListener* close_button_listener) |
142 : name_(NULL), status_(NULL) { | 157 : name_(NULL), status_(NULL) { |
tfarina
2012/08/09 16:37:40
indent 4 spaces
markusheintz_
2012/08/09 21:14:44
Done.
| |
143 views::GridLayout* layout = new views::GridLayout(this); | 158 views::GridLayout* layout = new views::GridLayout(this); |
144 SetLayoutManager(layout); | 159 SetLayoutManager(layout); |
145 | 160 |
146 const int label_column = 0; | 161 const int label_column = 0; |
147 views::ColumnSet* column_set = layout->AddColumnSet(label_column); | 162 views::ColumnSet* column_set = layout->AddColumnSet(label_column); |
148 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); | 163 column_set->AddPaddingColumn(0, kHeaderPaddingLeft); |
149 column_set->AddColumn(views::GridLayout::FILL, | 164 column_set->AddColumn(views::GridLayout::FILL, |
150 views::GridLayout::FILL, | 165 views::GridLayout::FILL, |
151 1, | 166 1, |
152 views::GridLayout::USE_PREF, | 167 views::GridLayout::USE_PREF, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 } | 210 } |
196 | 211 |
197 PopupHeaderView::~PopupHeaderView() { | 212 PopupHeaderView::~PopupHeaderView() { |
198 } | 213 } |
199 | 214 |
200 void PopupHeaderView::SetIdentityName(const string16& name) { | 215 void PopupHeaderView::SetIdentityName(const string16& name) { |
201 name_->SetText(name); | 216 name_->SetText(name); |
202 } | 217 } |
203 | 218 |
204 void PopupHeaderView::SetIdentityStatus(const string16& status, | 219 void PopupHeaderView::SetIdentityStatus(const string16& status, |
205 SkColor text_color) { | 220 SkColor text_color) { |
tfarina
2012/08/09 16:37:40
wrong indentation here
markusheintz_
2012/08/09 21:14:44
Done.
| |
206 status_->SetText(status); | 221 status_->SetText(status); |
207 status_->SetEnabledColor(text_color); | 222 status_->SetEnabledColor(text_color); |
208 } | 223 } |
209 | 224 |
210 /////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
226 // InternalPageInfoPopupView | |
227 //////////////////////////////////////////////////////////////////////////////// | |
228 | |
229 InternalPageInfoPopupView::InternalPageInfoPopupView(views::View* anchor_view) | |
230 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | |
231 const int kSpacing = 4; | |
232 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, kSpacing, | |
233 kSpacing, kSpacing)); | |
234 views::ImageView* icon_view = new views::ImageView(); | |
235 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
236 icon_view->SetImage(rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_26)); | |
237 AddChildView(icon_view); | |
238 | |
239 string16 text = l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); | |
tfarina
2012/08/09 16:37:40
could you avoid this temporary variable and fold i
markusheintz_
2012/08/09 21:14:44
Done.
| |
240 views::Label* label = new views::Label(text); | |
241 label->SetMultiLine(true); | |
242 label->SetAllowCharacterBreak(true); | |
243 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
244 AddChildView(label); | |
245 | |
246 views::BubbleDelegateView::CreateBubble(this); | |
247 Show(); | |
248 SizeToContents(); | |
249 } | |
250 | |
251 InternalPageInfoPopupView::~InternalPageInfoPopupView() { | |
252 } | |
253 | |
254 gfx::Rect InternalPageInfoPopupView::GetAnchorRect() { | |
255 // Compensate for some built-in padding in the icon. This will make the arrow | |
256 // point to the middle of the icon. | |
257 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | |
258 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); | |
259 return anchor; | |
260 } | |
261 | |
262 //////////////////////////////////////////////////////////////////////////////// | |
211 // WebsiteSettingsPopupView | 263 // WebsiteSettingsPopupView |
212 /////////////////////////////////////////////////////////////////////////////// | 264 //////////////////////////////////////////////////////////////////////////////// |
213 | 265 |
214 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 266 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
215 } | 267 } |
216 | 268 |
217 // static | 269 // static |
218 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | 270 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
219 Profile* profile, | 271 Profile* profile, |
220 TabContents* tab_contents, | 272 TabContents* tab_contents, |
221 const GURL& url, | 273 const GURL& url, |
222 const content::SSLStatus& ssl) { | 274 const content::SSLStatus& ssl) { |
223 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); | 275 if (InternalChromePage(url)) |
276 new InternalPageInfoPopupView(anchor_view); | |
277 else | |
278 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); | |
tfarina
2012/08/09 16:37:40
Looking now, and seeing that this inherits from Bu
markusheintz_
2012/08/09 21:14:44
I see that inheriting from BubbleDelegetView sugge
| |
224 } | 279 } |
225 | 280 |
226 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 281 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
227 views::View* anchor_view, | 282 views::View* anchor_view, |
228 Profile* profile, | 283 Profile* profile, |
229 TabContents* tab_contents, | 284 TabContents* tab_contents, |
230 const GURL& url, | 285 const GURL& url, |
231 const content::SSLStatus& ssl) | 286 const content::SSLStatus& ssl) |
232 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 287 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
233 tab_contents_(tab_contents), | 288 tab_contents_(tab_contents), |
234 header_(NULL), | 289 header_(NULL), |
235 tabbed_pane_(NULL), | 290 tabbed_pane_(NULL), |
236 site_data_content_(NULL), | 291 site_data_content_(NULL), |
237 cookie_dialog_link_(NULL), | 292 cookie_dialog_link_(NULL), |
238 permissions_content_(NULL), | 293 permissions_content_(NULL), |
239 identity_info_content_(NULL), | 294 identity_info_content_(NULL), |
240 certificate_dialog_link_(NULL), | 295 certificate_dialog_link_(NULL), |
241 cert_id_(0), | 296 cert_id_(0), |
242 connection_info_content_(NULL), | 297 connection_info_content_(NULL), |
243 page_info_content_(NULL) { | 298 page_info_content_(NULL) { |
244 if (InternalChromePage(url)) { | |
245 views::GridLayout* layout = new views::GridLayout(this); | |
246 SetLayoutManager(layout); | |
247 views::ColumnSet* column_set = layout->AddColumnSet(0); | |
248 column_set->AddColumn(views::GridLayout::FILL, | |
249 views::GridLayout::FILL, | |
250 0, // Resize weight. | |
251 views::GridLayout::USE_PREF, | |
252 0, | |
253 0); | |
254 column_set->AddPaddingColumn(0, kIconMarginLeft); | |
255 column_set->AddColumn(views::GridLayout::FILL, | |
256 views::GridLayout::FILL, | |
257 1, | |
258 views::GridLayout::USE_PREF, | |
259 0, | |
260 0); | |
261 | |
262 layout->StartRow(1, 0); | |
263 | |
264 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
265 const gfx::Image& icon = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26); | |
266 views::ImageView* icon_view = new views::ImageView(); | |
267 icon_view->SetImage(icon.ToImageSkia()); | |
268 layout->AddView(icon_view, 1, 1, views::GridLayout::LEADING, | |
269 views::GridLayout::LEADING); | |
270 | |
271 string16 text = l10n_util::GetStringUTF16( | |
272 IDS_PAGE_INFO_INTERNAL_PAGE); | |
273 views::Label* label = new views::Label(text); | |
274 label->SetMultiLine(true); | |
275 label->SetAllowCharacterBreak(true); | |
276 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
277 layout->AddView(label, 1, 1, views::GridLayout::LEADING, | |
278 views::GridLayout::CENTER); | |
279 | |
280 views::BubbleDelegateView::CreateBubble(this); | |
281 Show(); | |
282 SizeToContents(); | |
283 } else { | |
284 // Non internal chrome page. | |
285 views::GridLayout* layout = new views::GridLayout(this); | 299 views::GridLayout* layout = new views::GridLayout(this); |
286 SetLayoutManager(layout); | 300 SetLayoutManager(layout); |
287 const int content_column = 0; | 301 const int content_column = 0; |
288 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 302 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
289 column_set->AddColumn(views::GridLayout::FILL, | 303 column_set->AddColumn(views::GridLayout::FILL, |
290 views::GridLayout::FILL, | 304 views::GridLayout::FILL, |
291 1, | 305 1, |
292 views::GridLayout::USE_PREF, | 306 views::GridLayout::USE_PREF, |
293 0, | 307 0, |
294 0); | 308 0); |
(...skipping 26 matching lines...) Expand all Loading... | |
321 views::BubbleDelegateView::CreateBubble(this); | 335 views::BubbleDelegateView::CreateBubble(this); |
322 this->Show(); | 336 this->Show(); |
323 SizeToContents(); | 337 SizeToContents(); |
324 | 338 |
325 presenter_.reset(new WebsiteSettings(this, profile, | 339 presenter_.reset(new WebsiteSettings(this, profile, |
326 tab_contents->content_settings(), | 340 tab_contents->content_settings(), |
327 tab_contents->infobar_tab_helper(), | 341 tab_contents->infobar_tab_helper(), |
328 url, | 342 url, |
329 ssl, | 343 ssl, |
330 content::CertStore::GetInstance())); | 344 content::CertStore::GetInstance())); |
331 } | |
332 } | 345 } |
333 | 346 |
334 void WebsiteSettingsPopupView::OnPermissionChanged( | 347 void WebsiteSettingsPopupView::OnPermissionChanged( |
335 PermissionSelectorView* permission_selector) { | 348 PermissionSelectorView* permission_selector) { |
336 DCHECK(permission_selector); | 349 DCHECK(permission_selector); |
337 // It's not necessary to check that the |presenter_| is not NULL since for | |
338 // internal chrome pages OnPermissionChanged can't be called. | |
339 presenter_->OnSitePermissionChanged( | 350 presenter_->OnSitePermissionChanged( |
340 permission_selector->GetPermissionType(), | 351 permission_selector->GetPermissionType(), |
341 permission_selector->GetSelectedSetting()); | 352 permission_selector->GetSelectedSetting()); |
342 } | 353 } |
343 | 354 |
344 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { | 355 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { |
345 // Compensate for some built-in padding in the icon. This will make the arrow | 356 // Compensate for some built-in padding in the icon. This will make the arrow |
346 // point to the middle of the icon. | 357 // point to the middle of the icon. |
347 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | 358 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); |
348 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); | 359 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); |
349 return anchor; | 360 return anchor; |
350 } | 361 } |
351 | 362 |
352 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { | 363 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { |
353 if (presenter_.get()) | 364 presenter_->OnUIClosing(); |
tfarina
2012/08/09 16:37:40
Is the comment about |presenter_| being NULL still
markusheintz_
2012/08/09 21:14:44
Good catch. Fixed.
| |
354 presenter_->OnUIClosing(); | |
355 } | 365 } |
356 | 366 |
357 void WebsiteSettingsPopupView::ButtonPressed( | 367 void WebsiteSettingsPopupView::ButtonPressed( |
358 views::Button* button, | 368 views::Button* button, |
359 const views::Event& event) { | 369 const views::Event& event) { |
360 GetWidget()->Close(); | 370 GetWidget()->Close(); |
361 } | 371 } |
362 | 372 |
363 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 373 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
364 int event_flags) { | 374 int event_flags) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 | 708 |
699 if (link) { | 709 if (link) { |
700 content_layout->StartRow(1, 0); | 710 content_layout->StartRow(1, 0); |
701 content_layout->AddView(link); | 711 content_layout->AddView(link); |
702 } | 712 } |
703 | 713 |
704 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, | 714 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, |
705 views::GridLayout::LEADING); | 715 views::GridLayout::LEADING); |
706 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); | 716 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); |
707 } | 717 } |
OLD | NEW |