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 |WebsiteSettingsInternalPageView| is | |
msw
2012/08/08 17:27:08
nit: add a comma: "|WebsiteSettingsPopupView|, the
markusheintz_
2012/08/08 18:00:35
Done.
| |
139 // displayed. | |
140 class WebsiteSettingsInternalPageView : public views::BubbleDelegateView { | |
141 public: | |
142 explicit WebsiteSettingsInternalPageView(views::View* anchor_view); | |
143 virtual ~WebsiteSettingsInternalPageView(); | |
144 | |
145 private: | |
146 // views::BubbleDelegate implementations. | |
147 virtual gfx::Rect GetAnchorRect() OVERRIDE; | |
148 | |
149 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsInternalPageView); | |
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) { |
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; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) { |
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 // WebsiteSettingsInternalPageView | |
msw
2012/08/08 17:27:08
nit: I don't love the name... but lack a great sug
markusheintz_
2012/08/08 18:00:35
How about InternalPageInfoView?
msw
2012/08/08 18:34:10
It's still a 'Popup' bubble, like WebsiteSettings,
markusheintz_
2012/08/08 22:10:02
Well then let's use the descriptive name: Internal
| |
227 //////////////////////////////////////////////////////////////////////////////// | |
228 | |
229 WebsiteSettingsInternalPageView::WebsiteSettingsInternalPageView( | |
230 views::View* anchor_view) | |
231 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT) { | |
232 const int spacing = 4; | |
msw
2012/08/08 17:27:08
nit: this should be kSpacing, i think. (perhaps sa
markusheintz_
2012/08/08 18:00:35
Done. I'm not sure which other CL you mean. I'll s
msw
2012/08/08 18:34:10
found it and sent another nit :p
http://codereview
markusheintz_
2012/08/08 22:10:02
And I changed the code so that I don't need to add
| |
233 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, spacing, | |
234 spacing, spacing)); | |
235 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
236 const gfx::Image& icon = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_26); | |
237 views::ImageView* icon_view = new views::ImageView(); | |
238 icon_view->SetImage(icon.ToImageSkia()); | |
msw
2012/08/08 17:27:08
nit: consider the shorter version (very optional):
markusheintz_
2012/08/08 18:00:35
Done.
| |
239 AddChildView(icon_view); | |
240 | |
241 string16 text = l10n_util::GetStringUTF16( | |
242 IDS_PAGE_INFO_INTERNAL_PAGE); | |
msw
2012/08/08 17:27:08
nit: fits on line above.
markusheintz_
2012/08/08 18:00:35
Done.
| |
243 views::Label* label = new views::Label(text); | |
244 label->SetMultiLine(true); | |
245 label->SetAllowCharacterBreak(true); | |
246 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
247 AddChildView(label); | |
248 | |
249 views::BubbleDelegateView::CreateBubble(this); | |
250 Show(); | |
251 SizeToContents(); | |
252 } | |
253 | |
254 WebsiteSettingsInternalPageView::~WebsiteSettingsInternalPageView() { | |
255 } | |
256 | |
257 gfx::Rect WebsiteSettingsInternalPageView::GetAnchorRect() { | |
258 // Compensate for some built-in padding in the icon. This will make the arrow | |
259 // point to the middle of the icon. | |
260 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | |
261 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); | |
262 return anchor; | |
263 } | |
264 | |
265 //////////////////////////////////////////////////////////////////////////////// | |
211 // WebsiteSettingsPopupView | 266 // WebsiteSettingsPopupView |
212 /////////////////////////////////////////////////////////////////////////////// | 267 //////////////////////////////////////////////////////////////////////////////// |
213 | 268 |
214 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | 269 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { |
215 } | 270 } |
216 | 271 |
217 // static | 272 // static |
218 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | 273 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, |
219 Profile* profile, | 274 Profile* profile, |
220 TabContents* tab_contents, | 275 TabContents* tab_contents, |
221 const GURL& url, | 276 const GURL& url, |
222 const content::SSLStatus& ssl) { | 277 const content::SSLStatus& ssl) { |
223 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); | 278 if (InternalChromePage(url)) |
279 new WebsiteSettingsInternalPageView(anchor_view); | |
280 else | |
281 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); | |
224 } | 282 } |
225 | 283 |
226 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | 284 WebsiteSettingsPopupView::WebsiteSettingsPopupView( |
227 views::View* anchor_view, | 285 views::View* anchor_view, |
228 Profile* profile, | 286 Profile* profile, |
229 TabContents* tab_contents, | 287 TabContents* tab_contents, |
230 const GURL& url, | 288 const GURL& url, |
231 const content::SSLStatus& ssl) | 289 const content::SSLStatus& ssl) |
232 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | 290 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), |
233 tab_contents_(tab_contents), | 291 tab_contents_(tab_contents), |
234 header_(NULL), | 292 header_(NULL), |
235 tabbed_pane_(NULL), | 293 tabbed_pane_(NULL), |
236 site_data_content_(NULL), | 294 site_data_content_(NULL), |
237 cookie_dialog_link_(NULL), | 295 cookie_dialog_link_(NULL), |
238 permissions_content_(NULL), | 296 permissions_content_(NULL), |
239 identity_info_content_(NULL), | 297 identity_info_content_(NULL), |
240 certificate_dialog_link_(NULL), | 298 certificate_dialog_link_(NULL), |
241 cert_id_(0), | 299 cert_id_(0), |
242 connection_info_content_(NULL), | 300 connection_info_content_(NULL), |
243 page_info_content_(NULL) { | 301 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); | 302 views::GridLayout* layout = new views::GridLayout(this); |
286 SetLayoutManager(layout); | 303 SetLayoutManager(layout); |
287 const int content_column = 0; | 304 const int content_column = 0; |
288 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | 305 views::ColumnSet* column_set = layout->AddColumnSet(content_column); |
289 column_set->AddColumn(views::GridLayout::FILL, | 306 column_set->AddColumn(views::GridLayout::FILL, |
290 views::GridLayout::FILL, | 307 views::GridLayout::FILL, |
291 1, | 308 1, |
292 views::GridLayout::USE_PREF, | 309 views::GridLayout::USE_PREF, |
293 0, | 310 0, |
294 0); | 311 0); |
(...skipping 26 matching lines...) Expand all Loading... | |
321 views::BubbleDelegateView::CreateBubble(this); | 338 views::BubbleDelegateView::CreateBubble(this); |
322 this->Show(); | 339 this->Show(); |
323 SizeToContents(); | 340 SizeToContents(); |
324 | 341 |
325 presenter_.reset(new WebsiteSettings(this, profile, | 342 presenter_.reset(new WebsiteSettings(this, profile, |
326 tab_contents->content_settings(), | 343 tab_contents->content_settings(), |
327 tab_contents->infobar_tab_helper(), | 344 tab_contents->infobar_tab_helper(), |
328 url, | 345 url, |
329 ssl, | 346 ssl, |
330 content::CertStore::GetInstance())); | 347 content::CertStore::GetInstance())); |
331 } | |
332 } | 348 } |
333 | 349 |
334 void WebsiteSettingsPopupView::OnPermissionChanged( | 350 void WebsiteSettingsPopupView::OnPermissionChanged( |
335 PermissionSelectorView* permission_selector) { | 351 PermissionSelectorView* permission_selector) { |
336 DCHECK(permission_selector); | 352 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( | 353 presenter_->OnSitePermissionChanged( |
340 permission_selector->GetPermissionType(), | 354 permission_selector->GetPermissionType(), |
341 permission_selector->GetSelectedSetting()); | 355 permission_selector->GetSelectedSetting()); |
342 } | 356 } |
343 | 357 |
344 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { | 358 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { |
345 // Compensate for some built-in padding in the icon. This will make the arrow | 359 // Compensate for some built-in padding in the icon. This will make the arrow |
346 // point to the middle of the icon. | 360 // point to the middle of the icon. |
347 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | 361 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); |
348 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); | 362 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); |
349 return anchor; | 363 return anchor; |
350 } | 364 } |
351 | 365 |
352 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { | 366 void WebsiteSettingsPopupView::OnWidgetClosing(views::Widget* widget) { |
353 if (presenter_.get()) | 367 presenter_->OnUIClosing(); |
354 presenter_->OnUIClosing(); | |
355 } | 368 } |
356 | 369 |
357 void WebsiteSettingsPopupView::ButtonPressed( | 370 void WebsiteSettingsPopupView::ButtonPressed( |
358 views::Button* button, | 371 views::Button* button, |
359 const views::Event& event) { | 372 const views::Event& event) { |
360 GetWidget()->Close(); | 373 GetWidget()->Close(); |
361 } | 374 } |
362 | 375 |
363 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 376 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
364 int event_flags) { | 377 int event_flags) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 | 711 |
699 if (link) { | 712 if (link) { |
700 content_layout->StartRow(1, 0); | 713 content_layout->StartRow(1, 0); |
701 content_layout->AddView(link); | 714 content_layout->AddView(link); |
702 } | 715 } |
703 | 716 |
704 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, | 717 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, |
705 views::GridLayout::LEADING); | 718 views::GridLayout::LEADING); |
706 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); | 719 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); |
707 } | 720 } |
OLD | NEW |