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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 width = std::max(width, permissions_content_->GetPreferredSize().width()); | 467 width = std::max(width, permissions_content_->GetPreferredSize().width()); |
| 468 if (header_) | 468 if (header_) |
| 469 width = std::max(width, header_->GetPreferredNameWidth()); | 469 width = std::max(width, header_->GetPreferredNameWidth()); |
| 470 width += kPermissionsSectionPaddingLeft + kPermissionsSectionPaddingRight; | 470 width += kPermissionsSectionPaddingLeft + kPermissionsSectionPaddingRight; |
| 471 width = std::min(width, kMaxPopupWidth); | 471 width = std::min(width, kMaxPopupWidth); |
| 472 return gfx::Size(width, height); | 472 return gfx::Size(width, height); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void WebsiteSettingsPopupView::SetCookieInfo( | 475 void WebsiteSettingsPopupView::SetCookieInfo( |
| 476 const CookieInfoList& cookie_info_list) { | 476 const CookieInfoList& cookie_info_list) { |
| 477 site_data_content_->RemoveAllChildViews(true); | |
| 478 | |
| 479 views::GridLayout* layout = new views::GridLayout(site_data_content_); | |
| 480 site_data_content_->SetLayoutManager(layout); | |
| 481 | |
| 482 const int site_data_content_column = 0; | |
| 483 views::ColumnSet* column_set = | |
| 484 layout->AddColumnSet(site_data_content_column); | |
| 485 column_set->AddColumn(views::GridLayout::FILL, | |
| 486 views::GridLayout::FILL, | |
| 487 1, | |
| 488 views::GridLayout::FIXED, | |
| 489 kSiteDataIconColumnWidth, | |
| 490 0); | |
| 491 column_set->AddPaddingColumn(0, kIconMarginLeft); | |
| 492 column_set->AddColumn(views::GridLayout::FILL, | |
| 493 views::GridLayout::FILL, | |
| 494 1, | |
| 495 views::GridLayout::USE_PREF, | |
| 496 0, | |
| 497 0); | |
| 498 // No padding. This third column is for |third_party_label_text| (see below), | |
| 499 // and the text needs to flow naturally from the |first_party_label_text| | |
| 500 // link. | |
| 501 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 502 views::GridLayout::USE_PREF, 0, 0); | |
| 503 | |
| 504 layout->AddPaddingRow(1, 5); | |
| 505 | |
| 506 // |cookie_info_list| should only ever have 2 items: first- and third-party | 477 // |cookie_info_list| should only ever have 2 items: first- and third-party |
| 507 // cookies. | 478 // cookies. |
| 508 DCHECK_EQ(cookie_info_list.size(), 2u); | 479 DCHECK_EQ(cookie_info_list.size(), 2u); |
| 509 base::string16 first_party_label_text; | 480 base::string16 first_party_label_text; |
| 510 base::string16 third_party_label_text; | 481 base::string16 third_party_label_text; |
| 511 for (const auto& i : cookie_info_list) { | 482 for (const auto& i : cookie_info_list) { |
| 512 if (i.is_first_party) { | 483 if (i.is_first_party) { |
| 513 first_party_label_text = | 484 first_party_label_text = |
| 514 l10n_util::GetStringFUTF16(IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA, | 485 l10n_util::GetStringFUTF16(IDS_WEBSITE_SETTINGS_FIRST_PARTY_SITE_DATA, |
| 515 base::IntToString16(i.allowed)); | 486 base::IntToString16(i.allowed)); |
| 516 } else { | 487 } else { |
| 517 third_party_label_text = | 488 third_party_label_text = |
| 518 l10n_util::GetStringFUTF16(IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA, | 489 l10n_util::GetStringFUTF16(IDS_WEBSITE_SETTINGS_THIRD_PARTY_SITE_DATA, |
| 519 base::IntToString16(i.allowed)); | 490 base::IntToString16(i.allowed)); |
| 520 } | 491 } |
| 521 } | 492 } |
| 522 | 493 |
| 523 cookie_dialog_link_ = new views::Link(first_party_label_text); | 494 if (!cookie_dialog_link_) { |
| 524 cookie_dialog_link_->set_listener(this); | 495 cookie_dialog_link_ = new views::Link(first_party_label_text); |
| 496 cookie_dialog_link_->set_listener(this); | |
| 497 } else { | |
| 498 cookie_dialog_link_->SetText(first_party_label_text); | |
|
felt
2015/09/28 20:47:40
So this has the effect of updating the text, even
palmer
2015/09/28 21:02:51
That's right. Previously, we blew away all the chi
| |
| 499 } | |
| 525 | 500 |
| 526 layout->StartRow(1, site_data_content_column); | 501 views::GridLayout* layout = |
| 527 WebsiteSettingsUI::PermissionInfo info; | 502 static_cast<views::GridLayout*>(site_data_content_->GetLayoutManager()); |
| 528 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | 503 if (!layout) { |
| 529 info.setting = CONTENT_SETTING_ALLOW; | 504 layout = new views::GridLayout(site_data_content_); |
| 530 views::ImageView* icon = new views::ImageView(); | 505 site_data_content_->SetLayoutManager(layout); |
| 531 const gfx::Image& image = WebsiteSettingsUI::GetPermissionIcon(info); | |
| 532 icon->SetImage(image.ToImageSkia()); | |
| 533 layout->AddView(icon, 1, 1, views::GridLayout::CENTER, | |
| 534 views::GridLayout::CENTER); | |
| 535 layout->AddView(cookie_dialog_link_, 1, 1, views::GridLayout::CENTER, | |
| 536 views::GridLayout::CENTER); | |
| 537 base::string16 comma = base::ASCIIToUTF16(", "); | |
| 538 | 506 |
| 539 layout->AddView(new views::Label(comma + third_party_label_text), 1, 1, | 507 const int site_data_content_column = 0; |
| 540 views::GridLayout::LEADING, views::GridLayout::CENTER); | 508 views::ColumnSet* column_set = |
| 509 layout->AddColumnSet(site_data_content_column); | |
| 510 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 511 views::GridLayout::FIXED, kSiteDataIconColumnWidth, | |
| 512 0); | |
| 513 column_set->AddPaddingColumn(0, kIconMarginLeft); | |
| 514 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 515 views::GridLayout::USE_PREF, 0, 0); | |
| 516 // No padding. This third column is for |third_party_label_text| (see | |
| 517 // below), | |
| 518 // and the text needs to flow naturally from the |first_party_label_text| | |
| 519 // link. | |
| 520 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | |
| 521 views::GridLayout::USE_PREF, 0, 0); | |
| 541 | 522 |
| 542 layout->AddPaddingRow(1, 6); | 523 layout->AddPaddingRow(1, 5); |
| 524 | |
| 525 layout->StartRow(1, site_data_content_column); | |
| 526 WebsiteSettingsUI::PermissionInfo info; | |
| 527 info.type = CONTENT_SETTINGS_TYPE_COOKIES; | |
| 528 info.setting = CONTENT_SETTING_ALLOW; | |
| 529 views::ImageView* icon = new views::ImageView(); | |
| 530 const gfx::Image& image = WebsiteSettingsUI::GetPermissionIcon(info); | |
| 531 icon->SetImage(image.ToImageSkia()); | |
| 532 layout->AddView(icon, 1, 1, views::GridLayout::CENTER, | |
| 533 views::GridLayout::CENTER); | |
| 534 layout->AddView(cookie_dialog_link_, 1, 1, views::GridLayout::CENTER, | |
| 535 views::GridLayout::CENTER); | |
| 536 base::string16 comma = base::ASCIIToUTF16(", "); | |
| 537 | |
| 538 layout->AddView(new views::Label(comma + third_party_label_text), 1, 1, | |
| 539 views::GridLayout::LEADING, views::GridLayout::CENTER); | |
| 540 | |
| 541 layout->AddPaddingRow(1, 6); | |
| 542 } | |
| 543 | 543 |
| 544 layout->Layout(site_data_content_); | 544 layout->Layout(site_data_content_); |
| 545 SizeToContents(); | 545 SizeToContents(); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void WebsiteSettingsPopupView::SetPermissionInfo( | 548 void WebsiteSettingsPopupView::SetPermissionInfo( |
| 549 const PermissionInfoList& permission_info_list) { | 549 const PermissionInfoList& permission_info_list) { |
| 550 // When a permission is changed, WebsiteSettings::OnSitePermissionChanged() | 550 // When a permission is changed, WebsiteSettings::OnSitePermissionChanged() |
| 551 // calls this method with updated permissions. However, PermissionSelectorView | 551 // calls this method with updated permissions. However, PermissionSelectorView |
| 552 // will have already updated its state, so it's already reflected in the UI. | 552 // will have already updated its state, so it's already reflected in the UI. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 // desktop we should link to that here, too. | 861 // desktop we should link to that here, too. |
| 862 web_contents_->OpenURL(content::OpenURLParams( | 862 web_contents_->OpenURL(content::OpenURLParams( |
| 863 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), | 863 GURL(chrome::kChromeUIContentSettingsURL), content::Referrer(), |
| 864 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); | 864 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, false)); |
| 865 presenter_->RecordWebsiteSettingsAction( | 865 presenter_->RecordWebsiteSettingsAction( |
| 866 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); | 866 WebsiteSettings::WEBSITE_SETTINGS_SITE_SETTINGS_OPENED); |
| 867 } else { | 867 } else { |
| 868 NOTREACHED(); | 868 NOTREACHED(); |
| 869 } | 869 } |
| 870 } | 870 } |
| OLD | NEW |