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