Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Side by Side Diff: chrome/browser/ui/views/website_settings_popup_view.cc

Issue 10534138: Add icons to the views Website Settings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments (finnur). Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_popup_view.h" 5 #include "chrome/browser/ui/views/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/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/website_settings/website_settings.h" 10 #include "chrome/browser/ui/website_settings/website_settings.h"
11 #include "chrome/browser/ui/views/collected_cookies_views.h" 11 #include "chrome/browser/ui/views/collected_cookies_views.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents.h"
13 #include "chrome/common/content_settings_types.h" 13 #include "chrome/common/content_settings_types.h"
14 #include "content/public/browser/cert_store.h" 14 #include "content/public/browser/cert_store.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "grit/ui_resources_standard.h" 17 #include "grit/ui_resources_standard.h"
18 #include "grit/theme_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/models/combobox_model.h" 20 #include "ui/base/models/combobox_model.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/font.h" 23 #include "ui/gfx/font.h"
22 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
23 #include "ui/views/controls/button/image_button.h" 25 #include "ui/views/controls/button/image_button.h"
24 #include "ui/views/controls/combobox/combobox.h" 26 #include "ui/views/controls/combobox/combobox.h"
27 #include "ui/views/controls/image_view.h"
25 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
26 #include "ui/views/controls/link.h" 29 #include "ui/views/controls/link.h"
27 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" 30 #include "ui/views/controls/tabbed_pane/tabbed_pane.h"
28 #include "ui/views/layout/box_layout.h" 31 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/layout/grid_layout.h" 32 #include "ui/views/layout/grid_layout.h"
30 #include "ui/views/layout/layout_manager.h" 33 #include "ui/views/layout/layout_manager.h"
31 #include "ui/views/view.h" 34 #include "ui/views/view.h"
32 35
33 namespace { 36 namespace {
34 37
35 // In order to make the arrow of the bubble point directly at the location icon 38 // In order to make the arrow of the bubble point directly at the location icon
36 // in the Omnibox rather then the bottom border of the Omnibox, the position of 39 // in the Omnibox rather then the bottom border of the Omnibox, the position of
37 // the bubble must be adjusted. This is the number of pixel the bubble must be 40 // the bubble must be adjusted. This is the number of pixel the bubble must be
38 // moved towards the top of the screen (starting from the bottom border of the 41 // moved towards the top of the screen (starting from the bottom border of the
39 // Omnibox). 42 // Omnibox).
40 const int kLocationIconBottomMargin = 5; 43 const int kLocationIconBottomMargin = 5;
41 44
42 // Font size of the label for the site identity. 45 // Font size of the label for the site identity.
43 const int kIdentityNameFontSize = 14; 46 const int kIdentityNameFontSize = 14;
44 // The text color that is used for the site identity status text, if the site's 47 // The text color that is used for the site identity status text, if the site's
45 // identity was sucessfully verified. 48 // identity was sucessfully verified.
46 const int kIdentityVerifiedTextColor = 0xFF298a27; 49 const int kIdentityVerifiedTextColor = 0xFF298a27;
47 50
51 // Left icon margin.
52 const int kIconMarginLeft = 6;
53
48 // Margin and padding values for the |PopupHeader|. 54 // Margin and padding values for the |PopupHeader|.
49 const int kHeaderMarginBottom = 10; 55 const int kHeaderMarginBottom = 10;
50 const int kHeaderPaddingBottom = 12; 56 const int kHeaderPaddingBottom = 12;
51 const int kHeaderPaddingLeft = 10; 57 const int kHeaderPaddingLeft = 10;
52 const int kHeaderPaddingRight = 8; 58 const int kHeaderPaddingRight = 8;
53 const int kHeaderPaddingTop = 8; 59 const int kHeaderPaddingTop = 8;
54 60
55 // Spacing between the site identity label and the site identity status text in 61 // Spacing between the site identity label and the site identity status text in
56 // the popup header. 62 // the popup header.
57 const int kHeaderRowSpacing = 4; 63 const int kHeaderRowSpacing = 4;
58 64
59 // Padding values for sections. 65 // Padding values for sections.
60 const int kSectionPaddingBottom = 6; 66 const int kSectionPaddingBottom = 6;
61 const int kSectionPaddingLeft = 10; 67 const int kSectionPaddingLeft = 10;
62 const int kSectionPaddingTop = 14; 68 const int kSectionPaddingTop = 14;
63 69
64 // Space between a section headline and the section content. 70 // Space between a section headline and the section content.
65 const int kSectionHeadlineMarginBottom = 10; 71 const int kSectionHeadlineMarginBottom = 10;
66 // The content of the "Permissions" section and of the "Cookies and Site Data" 72 // The content of the "Permissions" section and of the "Cookies and Site Data"
67 // section, is structured in individual rows. |kSectionRowSpaceing| is the 73 // section, is structured in individual rows. |kSectionRowSpaceing| is the
68 // space between these rows. 74 // space between these rows.
69 const int kSectionRowSpacing = 6; 75 const int kSectionRowSpacing = 6;
70 76
77 // The width of the column that contains the permissions icons.
78 const int kPermissionIconColumnWidth = 20;
79 // Left margin of the label that displays the permission types.
80 const int kPermissionsRowLabelMarginLeft = 8;
81
71 // The max width of the popup. 82 // The max width of the popup.
72 const int kPopupWidth = 300; 83 const int kPopupWidth = 300;
73 84
74 // The bottom margin of the tabbed pane view. 85 // The bottom margin of the tabbed pane view.
75 const int kTabbedPaneMarginBottom = 8; 86 const int kTabbedPaneMarginBottom = 8;
76 87
77 string16 PermissionTypeToString(ContentSettingsType type) { 88 string16 PermissionTypeToString(ContentSettingsType type) {
78 return l10n_util::GetStringUTF16( 89 return l10n_util::GetStringUTF16(
79 WebsiteSettingsUI::PermissionTypeToUIStringID(type)); 90 WebsiteSettingsUI::PermissionTypeToUIStringID(type));
80 } 91 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 153 }
143 154
144 ContentSetting PermissionComboboxModel::GetSettingAt(int index) const { 155 ContentSetting PermissionComboboxModel::GetSettingAt(int index) const {
145 if (index < static_cast<int>(settings_.size())) 156 if (index < static_cast<int>(settings_.size()))
146 return settings_[index]; 157 return settings_[index];
147 NOTREACHED(); 158 NOTREACHED();
148 return CONTENT_SETTING_DEFAULT; 159 return CONTENT_SETTING_DEFAULT;
149 } 160 }
150 161
151 int PermissionComboboxModel::GetItemCount() const { 162 int PermissionComboboxModel::GetItemCount() const {
152 return settings_.size(); 163 return settings_.size();
153 } 164 }
154 165
155 string16 PermissionComboboxModel::GetItemAt(int index) { 166 string16 PermissionComboboxModel::GetItemAt(int index) {
156 if (index == 0) { 167 if (index == 0) {
157 return l10n_util::GetStringFUTF16( 168 return l10n_util::GetStringFUTF16(
158 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL, 169 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL,
159 PermissionValueToString(default_setting_)); 170 PermissionValueToString(default_setting_));
160 } 171 }
161 if (index < static_cast<int>(settings_.size())) { 172 if (index < static_cast<int>(settings_.size())) {
162 return l10n_util::GetStringFUTF16( 173 return l10n_util::GetStringFUTF16(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 TabContents* tab_contents, 299 TabContents* tab_contents,
289 const GURL& url, 300 const GURL& url,
290 const content::SSLStatus& ssl) 301 const content::SSLStatus& ssl)
291 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT), 302 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
292 tab_contents_(tab_contents), 303 tab_contents_(tab_contents),
293 header_(NULL), 304 header_(NULL),
294 tabbed_pane_(NULL), 305 tabbed_pane_(NULL),
295 site_data_content_(NULL), 306 site_data_content_(NULL),
296 cookie_dialog_link_(NULL), 307 cookie_dialog_link_(NULL),
297 permissions_content_(NULL), 308 permissions_content_(NULL),
298 identity_info_text_(NULL), 309 identity_info_content_(NULL),
299 connection_info_text_(NULL), 310 connection_info_content_(NULL),
300 page_info_text_(NULL) { 311 page_info_content_(NULL) {
301 views::GridLayout* layout = new views::GridLayout(this); 312 views::GridLayout* layout = new views::GridLayout(this);
302 SetLayoutManager(layout); 313 SetLayoutManager(layout);
303 const int content_column = 0; 314 const int content_column = 0;
304 views::ColumnSet* column_set = layout->AddColumnSet(content_column); 315 views::ColumnSet* column_set = layout->AddColumnSet(content_column);
305 column_set->AddColumn(views::GridLayout::FILL, 316 column_set->AddColumn(views::GridLayout::FILL,
306 views::GridLayout::FILL, 317 views::GridLayout::FILL,
307 1, 318 1,
308 views::GridLayout::USE_PREF, 319 views::GridLayout::USE_PREF,
309 0, 320 0,
310 0); 321 0);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 362
352 const int site_data_content_column = 0; 363 const int site_data_content_column = 0;
353 views::ColumnSet* column_set = 364 views::ColumnSet* column_set =
354 layout->AddColumnSet(site_data_content_column); 365 layout->AddColumnSet(site_data_content_column);
355 column_set->AddColumn(views::GridLayout::FILL, 366 column_set->AddColumn(views::GridLayout::FILL,
356 views::GridLayout::FILL, 367 views::GridLayout::FILL,
357 1, 368 1,
358 views::GridLayout::USE_PREF, 369 views::GridLayout::USE_PREF,
359 0, 370 0,
360 0); 371 0);
372 column_set->AddPaddingColumn(0, kIconMarginLeft);
373 column_set->AddColumn(views::GridLayout::FILL,
374 views::GridLayout::FILL,
375 1,
376 views::GridLayout::USE_PREF,
377 0,
378 0);
361 379
362 for (CookieInfoList::const_iterator it = cookie_info_list.begin(); 380 for (CookieInfoList::const_iterator it = cookie_info_list.begin();
363 it != cookie_info_list.end(); 381 it != cookie_info_list.end();
364 ++it) { 382 ++it) {
365 string16 label_text = l10n_util::GetStringFUTF16( 383 string16 label_text = l10n_util::GetStringFUTF16(
366 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE, 384 IDS_WEBSITE_SETTINGS_SITE_DATA_STATS_LINE,
367 UTF8ToUTF16(it->cookie_source), 385 UTF8ToUTF16(it->cookie_source),
368 base::IntToString16(it->allowed), 386 base::IntToString16(it->allowed),
369 base::IntToString16(it->allowed)); 387 base::IntToString16(it->allowed));
370 layout->StartRow(1, site_data_content_column); 388 layout->StartRow(1, site_data_content_column);
389 views::ImageView* icon = new views::ImageView();
390 gfx::Image* image = WebsiteSettingsUI::GetPermissionIcon(
391 CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_ALLOW);
392 icon->SetImage(image->ToImageSkia());
393 layout->AddView(icon);
371 layout->AddView(new views::Label(label_text), 394 layout->AddView(new views::Label(label_text),
372 1, 395 1,
373 1, 396 1,
374 views::GridLayout::LEADING, 397 views::GridLayout::LEADING,
375 views::GridLayout::CENTER); 398 views::GridLayout::CENTER);
376 399
377 layout->AddPaddingRow(1, kSectionRowSpacing); 400 layout->AddPaddingRow(1, kSectionRowSpacing);
378 } 401 }
379 402
380 layout->Layout(site_data_content_); 403 layout->Layout(site_data_content_);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 break; 443 break;
421 case CONTENT_SETTING_BLOCK: 444 case CONTENT_SETTING_BLOCK:
422 combobox->SetSelectedIndex(2); 445 combobox->SetSelectedIndex(2);
423 break; 446 break;
424 default: 447 default:
425 combobox->SetSelectedIndex(4); 448 combobox->SetSelectedIndex(4);
426 break; 449 break;
427 } 450 }
428 combobox->set_listener(this); 451 combobox->set_listener(this);
429 452
453 views::ImageView* icon = new views::ImageView();
454 ContentSetting setting = permission->setting;
455 if (setting == CONTENT_SETTING_DEFAULT)
456 setting = permission->default_setting;
457 gfx::Image* image = WebsiteSettingsUI::GetPermissionIcon(
458 permission->type, setting);
459 icon->SetImage(image->ToImageSkia());
460
430 layout->StartRow(1, content_column); 461 layout->StartRow(1, content_column);
431 layout->AddView(CreatePermissionRow(label, combobox), 462 layout->AddView(CreatePermissionRow(icon, label, combobox),
432 1, 463 1,
433 1, 464 1,
434 views::GridLayout::LEADING, 465 views::GridLayout::LEADING,
435 views::GridLayout::CENTER); 466 views::GridLayout::CENTER);
436 467
437 layout->AddPaddingRow(1, kSectionRowSpacing); 468 layout->AddPaddingRow(1, kSectionRowSpacing);
438 } 469 }
439 470
440 SizeToContents(); 471 SizeToContents();
441 } 472 }
(...skipping 11 matching lines...) Expand all
453 text_color = kIdentityVerifiedTextColor; 484 text_color = kIdentityVerifiedTextColor;
454 break; 485 break;
455 default: 486 default:
456 identity_status_text = 487 identity_status_text =
457 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED); 488 l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_IDENTITY_NOT_VERIFIED);
458 break; 489 break;
459 } 490 }
460 header_->SetIdentityName(UTF8ToUTF16(identity_info.site_identity)); 491 header_->SetIdentityName(UTF8ToUTF16(identity_info.site_identity));
461 header_->SetIdentityStatus(identity_status_text, text_color); 492 header_->SetIdentityStatus(identity_status_text, text_color);
462 493
463 identity_info_text_->SetText( 494 ResetContentContainer(
495 identity_info_content_,
496 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status),
464 UTF8ToUTF16(identity_info.identity_status_description)); 497 UTF8ToUTF16(identity_info.identity_status_description));
465 498 ResetContentContainer(
466 connection_info_text_->SetText( 499 connection_info_content_,
500 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status),
467 UTF8ToUTF16(identity_info.connection_status_description)); 501 UTF8ToUTF16(identity_info.connection_status_description));
468 502
503 // Layout.
469 GetLayoutManager()->Layout(this); 504 GetLayoutManager()->Layout(this);
470 SizeToContents(); 505 SizeToContents();
471 } 506 }
507
508 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) {
509 // TODO(markusheintz): Display a minor warning icon if the page is visited
510 // the first time.
511 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
512 ResetContentContainer(
513 page_info_content_,
514 &rb.GetImageNamed(IDR_PAGEINFO_INFO),
515 first_visit);
516
517 // Layout.
518 GetLayoutManager()->Layout(this);
519 SizeToContents();
520 }
472 521
473 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() { 522 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() {
474 int height = 0; 523 int height = 0;
475 if (header_) 524 if (header_)
476 height += header_->GetPreferredSize().height(); 525 height += header_->GetPreferredSize().height();
477 if (tabbed_pane_) 526 if (tabbed_pane_)
478 height += tabbed_pane_->GetPreferredSize().height(); 527 height += tabbed_pane_->GetPreferredSize().height();
479 528
480 return gfx::Size(kPopupWidth, height); 529 return gfx::Size(kPopupWidth, height);
481 } 530 }
482 531
483 void WebsiteSettingsPopupView::SetFirstVisit(const string16& first_visit) {
484 page_info_text_->SetText(first_visit);
485 }
486
487 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() { 532 gfx::Rect WebsiteSettingsPopupView::GetAnchorRect() {
488 // Compensate for some built-in padding in the icon. This will make the arrow 533 // Compensate for some built-in padding in the icon. This will make the arrow
489 // point to the middle of the icon. 534 // point to the middle of the icon.
490 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect()); 535 gfx::Rect anchor(BubbleDelegateView::GetAnchorRect());
491 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0); 536 anchor.Inset(0, anchor_view() ? kLocationIconBottomMargin : 0);
492 return anchor; 537 return anchor;
493 } 538 }
494 539
495 void WebsiteSettingsPopupView::OnSelectedIndexChanged( 540 void WebsiteSettingsPopupView::OnSelectedIndexChanged(
496 views::Combobox* combobox) { 541 views::Combobox* combobox) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 section_content->SetLayoutManager(layout); 603 section_content->SetLayoutManager(layout);
559 const int content_column = 0; 604 const int content_column = 0;
560 views::ColumnSet* column_set = 605 views::ColumnSet* column_set =
561 layout->AddColumnSet(content_column); 606 layout->AddColumnSet(content_column);
562 column_set->AddColumn(views::GridLayout::FILL, 607 column_set->AddColumn(views::GridLayout::FILL,
563 views::GridLayout::FILL, 608 views::GridLayout::FILL,
564 1, 609 1,
565 views::GridLayout::USE_PREF, 610 views::GridLayout::USE_PREF,
566 0, 611 0,
567 0); 612 0);
568 identity_info_text_ = CreateTextLabel(string16()); 613 identity_info_content_ = new views::View();
569 layout->StartRow(1, content_column); 614 layout->StartRow(1, content_column);
570 layout->AddView(identity_info_text_, 1, 1, views::GridLayout::LEADING, 615 layout->AddView(identity_info_content_, 1, 1, views::GridLayout::LEADING,
571 views::GridLayout::CENTER); 616 views::GridLayout::CENTER);
572 views::View* section = 617 views::View* section =
573 CreateSection(l10n_util::GetStringUTF16( 618 CreateSection(l10n_util::GetStringUTF16(
574 IDS_WEBSITE_SETTINGS_TITEL_IDENTITY), 619 IDS_WEBSITE_SETTINGS_TITEL_IDENTITY),
575 section_content, 620 section_content,
576 NULL); 621 NULL);
577 pane->AddChildView(section); 622 pane->AddChildView(section);
578 623
579 // Add connection section. 624 // Add connection section.
580 section_content = new views::View(); 625 connection_info_content_ = new views::View();
581 layout = new views::GridLayout(section_content);
582 section_content->SetLayoutManager(layout);
583 column_set = layout->AddColumnSet(content_column);
584 column_set->AddColumn(views::GridLayout::FILL,
585 views::GridLayout::FILL,
586 1,
587 views::GridLayout::USE_PREF,
588 0,
589 0);
590 connection_info_text_ = CreateTextLabel(string16());
591 layout->StartRow(1, content_column);
592 layout->AddView(connection_info_text_, 1, 1, views::GridLayout::LEADING,
593 views::GridLayout::CENTER);
594 section = CreateSection(l10n_util::GetStringUTF16( 626 section = CreateSection(l10n_util::GetStringUTF16(
595 IDS_WEBSITE_SETTINGS_TITEL_CONNECTION), 627 IDS_WEBSITE_SETTINGS_TITEL_CONNECTION),
596 section_content, 628 connection_info_content_,
597 NULL); 629 NULL);
598 pane->AddChildView(section); 630 pane->AddChildView(section);
599 631
600 // Add page info section. 632 // Add page info section.
601 section_content = new views::View(); 633 section_content = new views::View();
602 layout = new views::GridLayout(section_content); 634 layout = new views::GridLayout(section_content);
603 section_content->SetLayoutManager(layout); 635 section_content->SetLayoutManager(layout);
604 column_set = layout->AddColumnSet(content_column); 636 column_set = layout->AddColumnSet(content_column);
605 column_set->AddColumn(views::GridLayout::FILL, 637 column_set->AddColumn(views::GridLayout::FILL,
606 views::GridLayout::FILL, 638 views::GridLayout::FILL,
607 1, 639 1,
608 views::GridLayout::USE_PREF, 640 views::GridLayout::USE_PREF,
609 0, 641 0,
610 0); 642 0);
611 page_info_text_ = CreateTextLabel(string16()); 643 page_info_content_ = new views::View();
612 layout->StartRow(1, content_column); 644 layout->StartRow(1, content_column);
613 layout->AddView(page_info_text_, 1, 1, views::GridLayout::LEADING, 645 layout->AddView(page_info_content_, 1, 1, views::GridLayout::LEADING,
614 views::GridLayout::CENTER); 646 views::GridLayout::CENTER);
615 section = CreateSection(l10n_util::GetStringUTF16( 647 section = CreateSection(l10n_util::GetStringUTF16(
616 IDS_PAGE_INFO_SITE_INFO_TITLE), 648 IDS_PAGE_INFO_SITE_INFO_TITLE),
617 section_content, 649 section_content,
618 NULL); 650 NULL);
619 pane->AddChildView(section); 651 pane->AddChildView(section);
620 652
621 return pane; 653 return pane;
622 } 654 }
623 655
(...skipping 30 matching lines...) Expand all
654 layout->AddPaddingRow(1, 4); 686 layout->AddPaddingRow(1, 4);
655 layout->StartRow(1, content_column); 687 layout->StartRow(1, content_column);
656 layout->AddView(link, 1, 1, views::GridLayout::LEADING, 688 layout->AddView(link, 1, 1, views::GridLayout::LEADING,
657 views::GridLayout::CENTER); 689 views::GridLayout::CENTER);
658 } 690 }
659 691
660 layout->AddPaddingRow(1, kSectionPaddingBottom); 692 layout->AddPaddingRow(1, kSectionPaddingBottom);
661 return container; 693 return container;
662 } 694 }
663 695
696 void WebsiteSettingsPopupView::ResetContentContainer(
697 views::View* content_container,
698 gfx::Image* icon,
699 const string16& text) {
700 views::ImageView* icon_view = new views::ImageView();
701 icon_view->SetImage(icon->ToImageSkia());
702 views::Label* label = new views::Label(text);
703 label->SetMultiLine(true);
704 label->SetAllowCharacterBreak(true);
705 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
706
707 content_container->RemoveAllChildViews(true);
708 views::GridLayout* layout = new views::GridLayout(content_container);
709 content_container->SetLayoutManager(layout);
710 views::ColumnSet* column_set = layout->AddColumnSet(0);
711 column_set->AddColumn(views::GridLayout::FILL,
712 views::GridLayout::FILL,
713 0,
714 views::GridLayout::USE_PREF,
715 0,
716 0);
717 column_set->AddPaddingColumn(0, kIconMarginLeft);
718 column_set->AddColumn(views::GridLayout::FILL,
719 views::GridLayout::FILL,
720 1,
721 views::GridLayout::USE_PREF,
722 0,
723 0);
724
725 layout->StartRow(1, 0);
726 layout->AddView(icon_view, 1, 1, views::GridLayout::LEADING,
727 views::GridLayout::LEADING);
728 layout->AddView(label, 1, 1, views::GridLayout::LEADING,
729 views::GridLayout::LEADING);
730 }
731
664 views::View* WebsiteSettingsPopupView::CreatePermissionRow( 732 views::View* WebsiteSettingsPopupView::CreatePermissionRow(
733 views::ImageView* icon,
665 views::Label* label, 734 views::Label* label,
666 views::Combobox* combobox) { 735 views::Combobox* combobox) {
667 views::View* container = new views::View(); 736 views::View* container = new views::View();
668 views::GridLayout* layout = new views::GridLayout(container); 737 views::GridLayout* layout = new views::GridLayout(container);
669 container->SetLayoutManager(layout); 738 container->SetLayoutManager(layout);
670 const int two_column_layout = 0; 739 const int two_column_layout = 0;
671 views::ColumnSet* column_set = layout->AddColumnSet(two_column_layout); 740 views::ColumnSet* column_set = layout->AddColumnSet(two_column_layout);
672 column_set->AddColumn(views::GridLayout::FILL, 741 column_set->AddColumn(views::GridLayout::FILL,
673 views::GridLayout::FILL, 742 views::GridLayout::FILL,
674 1, 743 1,
744 views::GridLayout::FIXED,
745 kPermissionIconColumnWidth,
746 0);
747 column_set->AddPaddingColumn(0, kIconMarginLeft);
748 column_set->AddColumn(views::GridLayout::FILL,
749 views::GridLayout::FILL,
750 1,
675 views::GridLayout::USE_PREF, 751 views::GridLayout::USE_PREF,
676 0, 752 0,
677 0); 753 0);
678 column_set->AddPaddingColumn(0, 8); 754 column_set->AddPaddingColumn(0, kPermissionsRowLabelMarginLeft);
679 column_set->AddColumn(views::GridLayout::FILL, 755 column_set->AddColumn(views::GridLayout::FILL,
680 views::GridLayout::FILL, 756 views::GridLayout::FILL,
681 1, 757 1,
682 views::GridLayout::USE_PREF, 758 views::GridLayout::USE_PREF,
683 0, 759 0,
684 0); 760 0);
685 761
686 layout->StartRow(1, two_column_layout); 762 layout->StartRow(1, two_column_layout);
687 layout->AddView(label); 763
764 layout->AddView(icon, 1, 1, views::GridLayout::CENTER,
765 views::GridLayout::CENTER);
766 layout->AddView(label, 1,1, views::GridLayout::LEADING,
767 views::GridLayout::CENTER);
688 layout->AddView(combobox); 768 layout->AddView(combobox);
689 return container; 769 return container;
690 } 770 }
691
692 views::Label* WebsiteSettingsPopupView::CreateTextLabel(const string16& text) {
693 views::Label* label = new views::Label(text);
694 label->SetMultiLine(true);
695 label->SetAllowCharacterBreak(true);
696 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
697 return label;
698 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698