Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/website_settings_popup_view.h" | |
| 6 | |
| 7 #include "base/string_number_conversions.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "chrome/browser/profiles/profile.h" | |
| 10 #include "chrome/browser/ui/website_settings/website_settings.h" | |
| 11 #include "chrome/browser/ui/views/collected_cookies_views.h" | |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 13 #include "chrome/common/content_settings_types.h" | |
| 14 #include "content/public/browser/cert_store.h" | |
| 15 #include "googleurl/src/gurl.h" | |
| 16 #include "grit/generated_resources.h" | |
| 17 #include "ui/base/l10n/l10n_util.h" | |
| 18 #include "ui/base/models/combobox_model.h" | |
| 19 #include "ui/gfx/font.h" | |
| 20 #include "ui/views/controls/combobox/combobox.h" | |
| 21 #include "ui/views/controls/label.h" | |
| 22 #include "ui/views/controls/link.h" | |
| 23 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | |
| 24 #include "ui/views/layout/box_layout.h" | |
| 25 #include "ui/views/layout/grid_layout.h" | |
| 26 #include "ui/views/layout/layout_manager.h" | |
| 27 #include "ui/views/view.h" | |
| 28 | |
| 29 namespace { | |
| 30 | |
| 31 // In order to make the arrow of the bubble point directly at the location icon | |
| 32 // in the Omnibox rather then the bottom border of the Omnibox, the position of | |
| 33 // the bubble must be adjusted. This is the number of pixel the bubble must be | |
| 34 // moved towards the top of the screen (starting from the bottom border of the | |
| 35 // Omnibox). | |
| 36 const int kLocationIconBottomMargin = 5; | |
| 37 | |
| 38 const int kPopupWidth = 300; | |
| 39 | |
| 40 string16 PermissionTypeToString(ContentSettingsType type) { | |
| 41 return l10n_util::GetStringUTF16( | |
| 42 WebsiteSettingsUI::PermissionTypeToUIStringID(type)); | |
| 43 } | |
| 44 | |
| 45 string16 PermissionValueToString(ContentSetting value) { | |
| 46 return l10n_util::GetStringUTF16( | |
| 47 WebsiteSettingsUI::PermissionValueToUIStringID(value)); | |
| 48 } | |
| 49 | |
| 50 } // namespace | |
| 51 | |
| 52 namespace website_settings { | |
| 53 | |
| 54 // A |ComboboxModel| implementation that is used for |Combobox|es that allow | |
| 55 // selecting a setting for a given site permission. | |
| 56 class PermissionComboboxModel : public ui::ComboboxModel { | |
| 57 public: | |
| 58 // Creates a combobox model that provides all possible settings for the given | |
| 59 // |site_permission|. | |
| 60 PermissionComboboxModel(ContentSettingsType site_permission, | |
| 61 ContentSetting default_setting); | |
| 62 virtual ~PermissionComboboxModel(); | |
| 63 | |
| 64 // Returns the setting for the given |index|. | |
| 65 ContentSetting GetSettingAt(int index) const; | |
| 66 | |
| 67 // Returns the site permission for which the combobox model provides | |
| 68 // settings. | |
| 69 ContentSettingsType site_permission() const { | |
| 70 return site_permission_; | |
| 71 } | |
| 72 | |
| 73 // ui::ComboboxModel implementations. | |
| 74 virtual int GetItemCount() const OVERRIDE; | |
| 75 virtual string16 GetItemAt(int index) OVERRIDE; | |
| 76 | |
| 77 private: | |
| 78 // The site permission (the |ContentSettingsType|) for which the combobox | |
| 79 // model provides settings. | |
| 80 ContentSettingsType site_permission_; | |
| 81 | |
| 82 // The global default setting for the |site_permission_|. | |
| 83 ContentSetting default_setting_; | |
| 84 | |
| 85 // All possible valid setting for the |site_permission_|. | |
| 86 std::vector<ContentSetting> settings_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(PermissionComboboxModel); | |
| 89 }; | |
| 90 | |
| 91 PermissionComboboxModel::PermissionComboboxModel( | |
| 92 ContentSettingsType site_permission, | |
| 93 ContentSetting default_setting) | |
| 94 : site_permission_(site_permission), | |
| 95 default_setting_(default_setting){ | |
| 96 settings_.push_back(CONTENT_SETTING_DEFAULT); | |
| 97 settings_.push_back(CONTENT_SETTING_ALLOW); | |
| 98 settings_.push_back(CONTENT_SETTING_BLOCK); | |
| 99 if (site_permission == CONTENT_SETTINGS_TYPE_GEOLOCATION || | |
| 100 site_permission == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | |
| 101 settings_.push_back(CONTENT_SETTING_ASK); | |
| 102 } | |
| 103 | |
| 104 PermissionComboboxModel::~PermissionComboboxModel() { | |
| 105 } | |
| 106 | |
| 107 ContentSetting PermissionComboboxModel::GetSettingAt(int index) const { | |
| 108 if (index < static_cast<int>(settings_.size())) | |
| 109 return settings_[index]; | |
| 110 NOTREACHED(); | |
| 111 return CONTENT_SETTING_DEFAULT; | |
| 112 } | |
| 113 | |
| 114 int PermissionComboboxModel::GetItemCount() const { | |
| 115 return settings_.size(); | |
| 116 } | |
| 117 | |
| 118 string16 PermissionComboboxModel::GetItemAt(int index) { | |
| 119 if (index == 0) { | |
| 120 return l10n_util::GetStringFUTF16( | |
| 121 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL, | |
| 122 PermissionValueToString(default_setting_)); | |
| 123 } | |
| 124 if (index < static_cast<int>(settings_.size())) { | |
| 125 return l10n_util::GetStringFUTF16( | |
| 126 IDS_WEBSITE_SETTINGS_PERMISSION_LABEL, | |
| 127 PermissionValueToString(settings_[index])); | |
| 128 } | |
| 129 NOTREACHED(); | |
| 130 return string16(); | |
| 131 } | |
| 132 | |
| 133 } // namespace website_settings | |
| 134 | |
| 135 // |PopupHeader| is the UI element (view) that represents the header of the | |
| 136 // |WebsiteSettingsPopupView|. The header shows the status of the site's | |
| 137 // identity check and the name of the site's identity. | |
| 138 class PopupHeader : public views::View { | |
| 139 public: | |
| 140 PopupHeader(); | |
| 141 virtual ~PopupHeader(); | |
| 142 | |
| 143 // Sets the name of the site's identity. | |
| 144 void SetIdentityName(const string16& name); | |
| 145 | |
| 146 // Sets the status text for the identity check of this site. | |
| 147 void SetIdentityStatus(const string16& status_text); | |
| 148 | |
| 149 private: | |
| 150 // The label that displays the name of the site's identity. | |
| 151 views::Label* name_; | |
| 152 // The label that displays the status of the identity check for this site. | |
| 153 views::Label* status_; | |
| 154 | |
| 155 DISALLOW_COPY_AND_ASSIGN(PopupHeader); | |
| 156 }; | |
| 157 | |
| 158 //////////////////////////////////////////////////////////////////////////////// | |
| 159 // Popup Header | |
| 160 //////////////////////////////////////////////////////////////////////////////// | |
| 161 | |
| 162 PopupHeader::PopupHeader() : name_(NULL), status_(NULL) { | |
| 163 views::GridLayout* layout = new views::GridLayout(this); | |
| 164 SetLayoutManager(layout); | |
| 165 const int label_column = 0; | |
| 166 views::ColumnSet* column_set = layout->AddColumnSet(label_column); | |
| 167 column_set->AddColumn(views::GridLayout::FILL, | |
| 168 views::GridLayout::FILL, | |
| 169 1, | |
| 170 views::GridLayout::USE_PREF, | |
| 171 0, | |
| 172 0); | |
| 173 | |
| 174 layout->AddPaddingRow(0, 8); | |
| 175 | |
| 176 layout->StartRow(0, label_column); | |
| 177 name_ = new views::Label(string16()); | |
| 178 name_->SetFont(name_->font().DeriveFont(0, gfx::Font::BOLD)); | |
| 179 layout->AddView(name_, 1, 1, views::GridLayout::LEADING, | |
| 180 views::GridLayout::CENTER); | |
| 181 | |
| 182 layout->AddPaddingRow(0, 4); | |
| 183 | |
| 184 status_ = new views::Label(string16()); | |
| 185 layout->StartRow(0, label_column); | |
| 186 layout->AddView(status_, | |
| 187 1, | |
| 188 1, | |
| 189 views::GridLayout::LEADING, | |
| 190 views::GridLayout::CENTER); | |
| 191 } | |
| 192 | |
| 193 PopupHeader::~PopupHeader() { | |
| 194 } | |
| 195 | |
| 196 void PopupHeader::SetIdentityName(const string16& name) { | |
| 197 name_->SetText(name); | |
| 198 } | |
| 199 | |
| 200 void PopupHeader::SetIdentityStatus(const string16& status) { | |
| 201 status_->SetText(status); | |
| 202 } | |
| 203 | |
| 204 /////////////////////////////////////////////////////////////////////////////// | |
| 205 // WebsiteSettingsPopupView | |
| 206 /////////////////////////////////////////////////////////////////////////////// | |
| 207 | |
| 208 WebsiteSettingsPopupView::~WebsiteSettingsPopupView() { | |
| 209 } | |
| 210 | |
| 211 // static | |
| 212 void WebsiteSettingsPopupView::ShowPopup(views::View* anchor_view, | |
| 213 Profile* profile, | |
| 214 TabContentsWrapper* tab_contents, | |
| 215 const GURL& url, | |
| 216 const content::SSLStatus& ssl) { | |
| 217 new WebsiteSettingsPopupView(anchor_view, profile, tab_contents, url, ssl); | |
| 218 } | |
| 219 | |
| 220 WebsiteSettingsPopupView::WebsiteSettingsPopupView( | |
| 221 views::View* anchor_view, | |
| 222 Profile* profile, | |
| 223 TabContentsWrapper* tab_contents, | |
| 224 const GURL& url, | |
| 225 const content::SSLStatus& ssl) | |
| 226 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), | |
| 227 tab_contents_(tab_contents), | |
| 228 header_(NULL), | |
| 229 tabbed_pane_(NULL), | |
| 230 site_data_content_(NULL), | |
| 231 cookie_dialog_link_(NULL), | |
| 232 permissions_content_(NULL), | |
| 233 identity_info_text_(NULL), | |
| 234 connection_info_text_(NULL), | |
| 235 page_info_text_(NULL) { | |
| 236 views::GridLayout* layout = new views::GridLayout(this); | |
| 237 SetLayoutManager(layout); | |
| 238 const int content_column = 0; | |
| 239 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | |
| 240 column_set->AddColumn(views::GridLayout::FILL, | |
| 241 views::GridLayout::FILL, | |
| 242 1, | |
| 243 views::GridLayout::USE_PREF, | |
| 244 0, | |
| 245 0); | |
| 246 | |
| 247 header_ = new PopupHeader(); | |
| 248 layout->StartRow(1, content_column); | |
| 249 layout->AddView(header_); | |
| 250 | |
| 251 layout->AddPaddingRow(1, 10); | |
| 252 | |
| 253 tabbed_pane_ = new views::TabbedPane(); | |
| 254 layout->StartRow(1, content_column); | |
| 255 layout->AddView(tabbed_pane_); | |
| 256 // Tabs must be added after the tabbed_pane_ was added to the views hierachy. | |
| 257 // Adding the |tabbed_pane_| to the views hierachy triggers the | |
| 258 // initialization of the native tab UI element. If the native tab UI element | |
| 259 // is not initalized adding a tab will result in a NULL pointer excetion. | |
| 260 tabbed_pane_->AddTab( | |
| 261 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS), | |
| 262 CreatePermissionsTab()); | |
| 263 tabbed_pane_->AddTab( | |
| 264 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_TAB_LABEL_IDENTITY), | |
| 265 CreateIdentityTab()); | |
| 266 tabbed_pane_->SelectTabAt(0); | |
| 267 tabbed_pane_->set_listener(this); | |
| 268 | |
| 269 views::BubbleDelegateView::CreateBubble(this); | |
| 270 this->Show(); | |
| 271 SizeToContents(); | |
| 272 | |
| 273 presenter_.reset(new WebsiteSettings(this, profile, | |
| 274 tab_contents->content_settings(), url, | |
| 275 ssl, content::CertStore::GetInstance())); | |
| 276 } | |
| 277 | |
| 278 void WebsiteSettingsPopupView::SetCookieInfo( | |
| 279 const CookieInfoList& cookie_info_list) { | |
| 280 site_data_content_->RemoveAllChildViews(true); | |
| 281 | |
| 282 views::GridLayout* layout = new views::GridLayout(site_data_content_); | |
| 283 site_data_content_->SetLayoutManager(layout); | |
| 284 | |
| 285 const int site_data_content_column = 0; | |
| 286 views::ColumnSet* column_set = | |
| 287 layout->AddColumnSet(site_data_content_column); | |
| 288 column_set->AddColumn(views::GridLayout::FILL, | |
| 289 views::GridLayout::FILL, | |
| 290 1, | |
| 291 views::GridLayout::USE_PREF, | |
| 292 0, | |
| 293 0); | |
| 294 | |
| 295 for (CookieInfoList::const_iterator it = cookie_info_list.begin(); | |
| 296 it != cookie_info_list.end(); | |
| 297 ++it) { | |
| 298 string16 label_text = l10n_util::GetStringFUTF16( | |
| 299 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE, | |
| 300 UTF8ToUTF16(it->cookie_source), | |
| 301 base::IntToString16(it->allowed), | |
| 302 base::IntToString16(it->allowed)); | |
| 303 layout->StartRow(1, site_data_content_column); | |
| 304 layout->AddView(new views::Label(label_text), | |
| 305 1, | |
| 306 1, | |
| 307 views::GridLayout::LEADING, | |
| 308 views::GridLayout::CENTER); | |
| 309 | |
| 310 layout->AddPaddingRow(1, 4); | |
| 311 } | |
| 312 | |
| 313 layout->Layout(site_data_content_); | |
| 314 SizeToContents(); | |
| 315 } | |
| 316 | |
| 317 void WebsiteSettingsPopupView::SetPermissionInfo( | |
| 318 const PermissionInfoList& permission_info_list) { | |
| 319 permissions_content_->RemoveAllChildViews(true); | |
| 320 | |
| 321 views::GridLayout* layout = | |
| 322 new views::GridLayout(permissions_content_); | |
| 323 permissions_content_->SetLayoutManager(layout); | |
| 324 const int content_column = 0; | |
| 325 views::ColumnSet* column_set = | |
| 326 layout->AddColumnSet(content_column); | |
| 327 column_set->AddColumn(views::GridLayout::FILL, | |
| 328 views::GridLayout::FILL, | |
| 329 1, | |
| 330 views::GridLayout::USE_PREF, | |
| 331 0, | |
| 332 0); | |
| 333 for (PermissionInfoList::const_iterator permission = | |
| 334 permission_info_list.begin(); | |
| 335 permission != permission_info_list.end(); | |
| 336 ++permission) { | |
| 337 views::Label* label = | |
| 338 new views::Label(PermissionTypeToString(permission->type)); | |
| 339 | |
| 340 // The |ComboboxModel| is not owned by the |Combobox|. Therefore all models | |
| 341 // are stored in a scoped vector so that they are be deleted when the popup | |
| 342 // is destroyed. | |
| 343 combobox_models_->push_back(new website_settings::PermissionComboboxModel( | |
| 344 permission->type, permission->default_setting)); | |
| 345 views::Combobox* combobox = new views::Combobox( | |
| 346 combobox_models_->back()); | |
| 347 switch (permission->setting) { | |
| 348 case CONTENT_SETTING_DEFAULT: | |
| 349 combobox->SetSelectedIndex(0); | |
| 350 break; | |
| 351 case CONTENT_SETTING_ALLOW: | |
| 352 combobox->SetSelectedIndex(1); | |
| 353 break; | |
| 354 case CONTENT_SETTING_BLOCK: | |
| 355 combobox->SetSelectedIndex(2); | |
| 356 break; | |
| 357 default: | |
| 358 combobox->SetSelectedIndex(4); | |
| 359 break; | |
| 360 } | |
| 361 combobox->set_listener(this); | |
| 362 | |
| 363 layout->StartRow(1, content_column); | |
| 364 layout->AddView(CreatePermissionRow(label, combobox), | |
| 365 1, | |
| 366 1, | |
| 367 views::GridLayout::LEADING, | |
| 368 views::GridLayout::CENTER); | |
| 369 | |
| 370 } | |
| 371 | |
| 372 SizeToContents(); | |
| 373 } | |
| 374 | |
| 375 void WebsiteSettingsPopupView::SetIdentityInfo( | |
| 376 const IdentityInfo& identity_info) { | |
| 377 string16 identity_status_text; | |
| 378 switch (identity_info.identity_status) { | |
| 379 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: | |
| 380 case WebsiteSettings::SITE_IDENTITY_STATUS_DNSSEC_CERT: | |
| 381 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: | |
| 382 identity_status_text = | |
| 383 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_IDENTITY_VERIFIED); | |
| 384 break; | |
| 385 default: | |
| 386 identity_status_text = | |
| 387 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); | |
| 388 break; | |
| 389 } | |
| 390 header_->SetIdentityName(UTF8ToUTF16(identity_info.site_identity)); | |
| 391 header_->SetIdentityStatus(identity_status_text); | |
| 392 | |
| 393 identity_info_text_->SetText( | |
| 394 UTF8ToUTF16(identity_info.identity_status_description)); | |
| 395 | |
| 396 connection_info_text_->SetText( | |
| 397 UTF8ToUTF16(identity_info.connection_status_description)); | |
| 398 | |
| 399 GetLayoutManager()->Layout(this); | |
| 400 SizeToContents(); | |
| 401 } | |
| 402 | |
| 403 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() { | |
| 404 int height = 0; | |
| 405 int width = kPopupWidth; | |
|
tfarina
2012/06/07 22:09:41
nit: no need of this temp (non-const) variable.
j
markusheintz_
2012/06/08 08:43:22
Done.
| |
| 406 if (header_) | |
| 407 height += header_->GetPreferredSize().height(); | |
| 408 if (tabbed_pane_) | |
| 409 height += tabbed_pane_->GetPreferredSize().height(); | |
| 410 | |
| 411 return gfx::Size(width, height); | |
| 412 } | |
| 413 | |
| 414 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) { | |
| 415 page_info_text_->SetText(first_visit); | |
| 416 } | |
| 417 | |
| 418 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { | |
| 419 // Compensate for some built-in padding in the icon. This will make the arrow | |
| 420 // point to the middle of the icon. | |
| 421 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); | |
| 422 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); | |
| 423 return anchor; | |
| 424 } | |
| 425 | |
| 426 void WebsiteSettingsPopupView::OnSelectedIndexChanged( | |
| 427 views::Combobox* combobox) { | |
| 428 website_settings::PermissionComboboxModel* model = | |
| 429 static_cast<website_settings::PermissionComboboxModel*>(combobox->model()); | |
| 430 DCHECK(model); | |
| 431 presenter_->OnSitePermissionChanged( | |
| 432 model->site_permission(), | |
| 433 model->GetSettingAt(combobox->selected_index())); | |
| 434 } | |
| 435 | |
| 436 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | |
| 437 int event_flags) { | |
| 438 DCHECK_EQ(cookie_dialog_link_, source); | |
| 439 new CollectedCookiesViews(tab_contents_); | |
| 440 GetWidget()->CloseNow(); | |
| 441 } | |
| 442 | |
| 443 void WebsiteSettingsPopupView::TabSelectedAt(int index) { | |
| 444 tabbed_pane_->GetSelectedTab()->Layout(); | |
| 445 SizeToContents(); | |
| 446 } | |
| 447 | |
| 448 views::View* WebsiteSettingsPopupView::CreatePermissionsTab() { | |
| 449 views::View* pane = new views::View(); | |
| 450 pane->SetLayoutManager( | |
| 451 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | |
| 452 | |
| 453 cookie_dialog_link_ = new views::Link( | |
| 454 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA)); | |
| 455 cookie_dialog_link_->set_listener(this); | |
| 456 site_data_content_ = new views::View(); | |
| 457 views::View* site_data_section = | |
| 458 CreateSection(l10n_util::GetStringUTF16( | |
| 459 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA), | |
| 460 site_data_content_, | |
| 461 cookie_dialog_link_); | |
| 462 pane->AddChildView(site_data_section); | |
| 463 | |
| 464 permissions_content_ = new views::View(); | |
| 465 views::View* permissions_section = | |
| 466 CreateSection(l10n_util::GetStringUTF16( | |
| 467 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS), | |
| 468 permissions_content_, | |
| 469 NULL); | |
| 470 pane->AddChildView(permissions_section); | |
| 471 return pane; | |
| 472 } | |
| 473 | |
| 474 views::View* WebsiteSettingsPopupView::CreateIdentityTab() { | |
| 475 views::View* pane = new views::View(); | |
| 476 pane->SetLayoutManager( | |
| 477 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | |
| 478 | |
| 479 // Add Identity section. | |
| 480 views::View* section_content = new views::View(); | |
| 481 views::GridLayout* layout = | |
| 482 new views::GridLayout(section_content); | |
| 483 section_content->SetLayoutManager(layout); | |
| 484 const int content_column = 0; | |
| 485 views::ColumnSet* column_set = | |
| 486 layout->AddColumnSet(content_column); | |
| 487 column_set->AddColumn(views::GridLayout::FILL, | |
| 488 views::GridLayout::FILL, | |
| 489 1, | |
| 490 views::GridLayout::USE_PREF, | |
| 491 0, | |
| 492 0); | |
| 493 identity_info_text_ = CreateTextLabel(string16()); | |
| 494 layout->StartRow(1, content_column); | |
| 495 layout->AddView(identity_info_text_, 1, 1, views::GridLayout::LEADING, | |
| 496 views::GridLayout::CENTER); | |
| 497 views::View* section = | |
| 498 CreateSection(l10n_util::GetStringUTF16( | |
| 499 IDS_WEBSITE_SETTINGS_TITEL_IDENTITY), | |
| 500 section_content, | |
| 501 NULL); | |
| 502 pane->AddChildView(section); | |
| 503 | |
| 504 // Add connection section. | |
| 505 section_content = new views::View(); | |
| 506 layout = new views::GridLayout(section_content); | |
| 507 section_content->SetLayoutManager(layout); | |
| 508 column_set = layout->AddColumnSet(content_column); | |
| 509 column_set->AddColumn(views::GridLayout::FILL, | |
| 510 views::GridLayout::FILL, | |
| 511 1, | |
| 512 views::GridLayout::USE_PREF, | |
| 513 0, | |
| 514 0); | |
| 515 connection_info_text_ = CreateTextLabel(string16()); | |
| 516 layout->StartRow(1, content_column); | |
| 517 layout->AddView(connection_info_text_, 1, 1, views::GridLayout::LEADING, | |
| 518 views::GridLayout::CENTER); | |
| 519 section = CreateSection(l10n_util::GetStringUTF16( | |
| 520 IDS_WEBSITE_SETTINGS_TITEL_CONNECTION), | |
| 521 section_content, | |
| 522 NULL); | |
| 523 pane->AddChildView(section); | |
| 524 | |
| 525 // Add page info section. | |
| 526 section_content = new views::View(); | |
| 527 layout = new views::GridLayout(section_content); | |
| 528 section_content->SetLayoutManager(layout); | |
| 529 column_set = layout->AddColumnSet(content_column); | |
| 530 column_set->AddColumn(views::GridLayout::FILL, | |
| 531 views::GridLayout::FILL, | |
| 532 1, | |
| 533 views::GridLayout::USE_PREF, | |
| 534 0, | |
| 535 0); | |
| 536 page_info_text_ = CreateTextLabel(string16()); | |
| 537 layout->StartRow(1, content_column); | |
| 538 layout->AddView(page_info_text_, 1, 1, views::GridLayout::LEADING, | |
| 539 views::GridLayout::CENTER); | |
| 540 section = CreateSection(l10n_util::GetStringUTF16( | |
| 541 IDS_PAGE_INFO_SITE_INFO_TITLE), | |
| 542 section_content, | |
| 543 NULL); | |
| 544 pane->AddChildView(section); | |
| 545 | |
| 546 return pane; | |
| 547 } | |
| 548 | |
| 549 views::View* WebsiteSettingsPopupView::CreateSection( | |
| 550 const string16& headline_text, | |
| 551 views::View* content, | |
| 552 views::Link* link) { | |
| 553 views::View* container = new views::View(); | |
| 554 views::GridLayout* layout = new views::GridLayout(container); | |
| 555 container->SetLayoutManager(layout); | |
| 556 const int content_column = 0; | |
| 557 views::ColumnSet* column_set = layout->AddColumnSet(content_column); | |
| 558 column_set->AddColumn(views::GridLayout::FILL, | |
| 559 views::GridLayout::FILL, | |
| 560 1, | |
| 561 views::GridLayout::USE_PREF, | |
| 562 0, | |
| 563 0); | |
| 564 | |
| 565 layout->AddPaddingRow(1, 4); | |
| 566 layout->StartRow(1, content_column); | |
| 567 views::Label* headline = new views::Label(headline_text); | |
| 568 headline->SetFont(headline->font().DeriveFont(0, gfx::Font::BOLD)); | |
| 569 layout->AddView(headline, 1, 1, views::GridLayout::LEADING, | |
| 570 views::GridLayout::CENTER); | |
| 571 | |
| 572 layout->AddPaddingRow(1, 4); | |
| 573 layout->StartRow(1, content_column); | |
| 574 layout->AddView(content, 1, 1, views::GridLayout::LEADING, | |
| 575 views::GridLayout::CENTER); | |
| 576 | |
| 577 if (link) { | |
| 578 layout->AddPaddingRow(1, 4); | |
| 579 layout->StartRow(1, content_column); | |
| 580 layout->AddView(link, 1, 1, views::GridLayout::LEADING, | |
| 581 views::GridLayout::CENTER); | |
| 582 } | |
| 583 | |
| 584 return container; | |
| 585 } | |
| 586 | |
| 587 views::View* WebsiteSettingsPopupView::CreatePermissionRow( | |
| 588 views::Label* label, | |
| 589 views::Combobox* combobox) { | |
| 590 views::View* container = new views::View(); | |
| 591 views::GridLayout* layout = new views::GridLayout(container); | |
| 592 container->SetLayoutManager(layout); | |
| 593 const int two_column_layout = 0; | |
| 594 views::ColumnSet* column_set = layout->AddColumnSet(two_column_layout); | |
| 595 column_set->AddColumn(views::GridLayout::FILL, | |
| 596 views::GridLayout::FILL, | |
| 597 1, | |
| 598 views::GridLayout::USE_PREF, | |
| 599 0, | |
| 600 0); | |
| 601 column_set->AddPaddingColumn(0, 8); | |
| 602 column_set->AddColumn(views::GridLayout::FILL, | |
| 603 views::GridLayout::FILL, | |
| 604 1, | |
| 605 views::GridLayout::USE_PREF, | |
| 606 0, | |
| 607 0); | |
| 608 | |
| 609 layout->StartRow(1, two_column_layout); | |
| 610 layout->AddView(label); | |
| 611 layout->AddView(combobox); | |
| 612 return container; | |
| 613 } | |
| 614 | |
| 615 views::Label* WebsiteSettingsPopupView::CreateTextLabel(const string16& text) { | |
| 616 views::Label* label = new views::Label(text); | |
| 617 label->SetMultiLine(true); | |
| 618 label->SetAllowCharacterBreak(true); | |
| 619 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
| 620 return label; | |
| 621 } | |
| OLD | NEW |