Chromium Code Reviews| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 layout->AddView(header_); | 306 layout->AddView(header_); |
| 307 | 307 |
| 308 layout->AddPaddingRow(1, kHeaderMarginBottom); | 308 layout->AddPaddingRow(1, kHeaderMarginBottom); |
| 309 tabbed_pane_ = new views::TabbedPane(); | 309 tabbed_pane_ = new views::TabbedPane(); |
| 310 layout->StartRow(1, content_column); | 310 layout->StartRow(1, content_column); |
| 311 layout->AddView(tabbed_pane_); | 311 layout->AddView(tabbed_pane_); |
| 312 // Tabs must be added after the tabbed_pane_ was added to the views | 312 // Tabs must be added after the tabbed_pane_ was added to the views |
| 313 // hierachy. Adding the |tabbed_pane_| to the views hierachy triggers the | 313 // hierachy. Adding the |tabbed_pane_| to the views hierachy triggers the |
| 314 // initialization of the native tab UI element. If the native tab UI | 314 // initialization of the native tab UI element. If the native tab UI |
| 315 // element is not initalized adding a tab will result in a NULL pointer | 315 // element is not initalized adding a tab will result in a NULL pointer |
| 316 // excetion. | 316 // exception. |
| 317 tabbed_pane_->AddTab( | 317 tabbed_pane_->AddTab( |
| 318 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), | 318 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), |
| 319 CreatePermissionsTab()); | 319 CreatePermissionsTab()); |
| 320 tabbed_pane_->AddTab( | 320 tabbed_pane_->AddTab( |
| 321 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), | 321 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), |
| 322 CreateConnectionTab()); | 322 CreateConnectionTab()); |
| 323 tabbed_pane_->SelectTabAt(0); | |
| 324 tabbed_pane_->set_listener(this); | 323 tabbed_pane_->set_listener(this); |
| 325 | 324 |
| 326 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, | 325 set_margins(gfx::Insets(kPopupMarginTop, kPopupMarginLeft, |
| 327 kPopupMarginBottom, kPopupMarginRight)); | 326 kPopupMarginBottom, kPopupMarginRight)); |
| 328 | 327 |
| 329 views::BubbleDelegateView::CreateBubble(this); | 328 views::BubbleDelegateView::CreateBubble(this); |
| 330 this->Show(); | 329 this->Show(); |
| 331 SizeToContents(); | 330 SizeToContents(); |
| 332 | 331 |
| 333 presenter_.reset(new WebsiteSettings(this, profile, | 332 presenter_.reset(new WebsiteSettings(this, profile, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 356 GetWidget()->Close(); | 355 GetWidget()->Close(); |
| 357 } | 356 } |
| 358 | 357 |
| 359 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 358 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
| 360 int event_flags) { | 359 int event_flags) { |
| 361 if (source == cookie_dialog_link_) { | 360 if (source == cookie_dialog_link_) { |
| 362 new CollectedCookiesViews(tab_contents_); | 361 new CollectedCookiesViews(tab_contents_); |
| 363 } else if (source == certificate_dialog_link_) { | 362 } else if (source == certificate_dialog_link_) { |
| 364 gfx::NativeWindow parent = | 363 gfx::NativeWindow parent = |
| 365 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; | 364 anchor_view() ? anchor_view()->GetWidget()->GetNativeWindow() : NULL; |
| 366 ShowCertificateViewerByID(tab_contents_->web_contents(), parent, cert_id_); | 365 ShowCertificateViewerByID(tab_contents_->web_contents(), parent, cert_id_); |
| 367 } | 366 } |
| 368 // The popup closes automatically when the collected cookies dialog or the | 367 // The popup closes automatically when the collected cookies dialog or the |
| 369 // certificate viewer opens. | 368 // certificate viewer opens. |
| 370 } | 369 } |
| 371 | 370 |
| 372 void WebsiteSettingsPopupView::TabSelectedAt(int index) { | 371 void WebsiteSettingsPopupView::TabSelectedAt(int index) { |
| 373 tabbed_pane_->GetSelectedTab()->Layout(); | 372 tabbed_pane_->GetSelectedTab()->Layout(); |
| 374 SizeToContents(); | 373 SizeToContents(); |
| 375 } | 374 } |
| 376 | 375 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 UTF8ToUTF16(identity_info.identity_status_description), | 514 UTF8ToUTF16(identity_info.identity_status_description), |
| 516 certificate_dialog_link_); | 515 certificate_dialog_link_); |
| 517 | 516 |
| 518 ResetConnectionSection( | 517 ResetConnectionSection( |
| 519 connection_info_content_, | 518 connection_info_content_, |
| 520 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), | 519 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), |
| 521 string16(), // The connection section has no headline. | 520 string16(), // The connection section has no headline. |
| 522 UTF8ToUTF16(identity_info.connection_status_description), | 521 UTF8ToUTF16(identity_info.connection_status_description), |
| 523 NULL); | 522 NULL); |
| 524 | 523 |
| 525 Layout(); | 524 // TODO(markusheintz): This is a hack to resize the connection tab contents |
| 526 SizeToContents(); | 525 // correctly. If this is not done then the connection tab does not disaply |
|
msw
2012/08/23 01:01:35
spelling nit: display, grammar nit: "not done, the
markusheintz_
2012/08/23 19:46:21
Done.
| |
| 526 // its contents correctly in case it is selected as visible tab when the | |
| 527 // |WebsiteSettingsPopupView| is opened. Fix this. | |
|
markusheintz_
2012/08/23 00:49:14
@msw,sky: I wish I could have come up with somethi
msw
2012/08/23 01:01:35
This hacks seems okay for now, I suppose. Perhaps
markusheintz_
2012/08/23 19:46:21
This is a good guess. And it's also easy to do sin
| |
| 528 int tab_index = tabbed_pane_->GetSelectedTabIndex(); | |
| 529 tabbed_pane_->SelectTabAt(0); | |
| 530 tabbed_pane_->SelectTabAt(1); | |
| 531 tabbed_pane_->SelectTabAt(tab_index); | |
|
sky
2012/08/23 04:01:48
Oy, why the hack? Can't we fix this correctly?
markusheintz_
2012/08/23 19:46:21
That's the plan :) (to fix it correctly).
The pro
msw
2012/08/23 20:11:30
TabLayout::SwitchToPage calls SetBoundsRect on the
markusheintz_
2012/08/23 20:34:33
It does
http://code.google.com/searchframe#OAMlx_
msw
2012/08/23 21:26:39
Sorry, I missed that... hmm, I'm out of ideas with
markusheintz_
2012/08/23 22:21:34
The InvalidayLayout version works perfect.
Thing
msw
2012/08/23 22:59:41
Use InvalidateLayout unless Scott objects :)
sky
2012/08/24 17:41:30
Mike's right, InvalidateLayout is what you want. A
| |
| 527 } | 532 } |
| 528 | 533 |
| 529 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) { | 534 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) { |
| 530 ResetConnectionSection( | 535 ResetConnectionSection( |
| 531 page_info_content_, | 536 page_info_content_, |
| 532 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), | 537 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), |
| 533 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), | 538 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), |
| 534 first_visit, | 539 first_visit, |
| 535 NULL); | 540 NULL); |
| 536 Layout(); | 541 Layout(); |
| 537 SizeToContents(); | 542 SizeToContents(); |
| 538 } | 543 } |
| 539 | 544 |
| 545 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | |
| 546 DCHECK_EQ(TAB_ID_PERMISSIONS, 0); | |
|
msw
2012/08/23 01:01:35
nit: it's silly to DCHECK this on each platform se
markusheintz_
2012/08/23 19:46:21
1) I think the DCHECKS document pretty nice the re
msw
2012/08/23 20:11:30
These (and the GTK and [future] Mac) DCHECKs just
markusheintz_
2012/08/23 20:34:33
I definitely agree that duplicated code sucks :).
msw
2012/08/23 21:26:39
Elliot's okay with my new plan:
1) Remove these an
markusheintz_
2012/08/23 22:21:34
Thanks a lot for checking with Elliot! The new is
msw
2012/08/23 22:59:41
'twas my idea, Elliot liked it too :)
markusheintz_
2012/08/24 12:42:43
+1 done :-)
| |
| 547 DCHECK_EQ(TAB_ID_CONNECTION, 1); | |
| 548 tabbed_pane_->SelectTabAt(tab_id); | |
| 549 } | |
| 550 | |
| 540 views::View* WebsiteSettingsPopupView::CreatePermissionsTab() { | 551 views::View* WebsiteSettingsPopupView::CreatePermissionsTab() { |
| 541 views::View* pane = new views::View(); | 552 views::View* pane = new views::View(); |
| 542 pane->SetLayoutManager( | 553 pane->SetLayoutManager( |
| 543 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | 554 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); |
| 544 // Add cookies and site data section. | 555 // Add cookies and site data section. |
| 545 cookie_dialog_link_ = new views::Link( | 556 cookie_dialog_link_ = new views::Link( |
| 546 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA)); | 557 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA)); |
| 547 cookie_dialog_link_->set_listener(this); | 558 cookie_dialog_link_->set_listener(this); |
| 548 site_data_content_ = new views::View(); | 559 site_data_content_ = new views::View(); |
| 549 views::View* site_data_section = | 560 views::View* site_data_section = |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 | 705 |
| 695 if (link) { | 706 if (link) { |
| 696 content_layout->StartRow(1, 0); | 707 content_layout->StartRow(1, 0); |
| 697 content_layout->AddView(link); | 708 content_layout->AddView(link); |
| 698 } | 709 } |
| 699 | 710 |
| 700 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, | 711 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, |
| 701 views::GridLayout::LEADING); | 712 views::GridLayout::LEADING); |
| 702 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); | 713 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); |
| 703 } | 714 } |
| OLD | NEW |