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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 // | separator | | 430 // | separator | |
431 // +--------------------+------+ | 431 // +--------------------+------+ |
432 // | permissions_header | | | 432 // | permissions_header | | |
433 // +--------------------+------+ | 433 // +--------------------+------+ |
434 // | permission1 | | | 434 // | permission1 | | |
435 // +--------------------+------+ | 435 // +--------------------+------+ |
436 // | permission2 | | | 436 // | permission2 | | |
437 // +--------------------+------+ | 437 // +--------------------+------+ |
438 // | 438 // |
439 // Regular install | 439 // Regular install |
440 // w/ permissions XOR oauth issues no permissions | 440 // w/ permissions no permissions |
441 // +--------------------+------+ +--------------+------+ | 441 // +--------------------+------+ +--------------+------+ |
442 // | heading | icon | | heading | icon | | 442 // | heading | icon | | heading | icon | |
443 // +--------------------| | +--------------+------+ | 443 // +--------------------| | +--------------+------+ |
444 // | permissions_header | | | 444 // | permissions_header | | |
445 // +--------------------| | | 445 // +--------------------| | |
446 // | permission1 | | | 446 // | permission1 | | |
447 // +--------------------| | | 447 // +--------------------| | |
448 // | permission2 | | | 448 // | permission2 | | |
449 // +--------------------+------+ | 449 // +--------------------+------+ |
450 // | 450 // |
451 // w/ permissions AND oauth issues | |
452 // +--------------------+------+ | |
453 // | heading | icon | | |
454 // +--------------------| | | |
455 // | permissions_header | | | |
456 // +--------------------| | | |
457 // | permission1 | | | |
458 // +--------------------| | | |
459 // | permission2 | | | |
460 // +--------------------+------+ | |
461 // | oauth header | | |
462 // +---------------------------+ | |
463 // | oauth issue 1 | | |
464 // +---------------------------+ | |
465 // | oauth issue 2 | | |
466 // +---------------------------+ | |
467 // | |
468 // If the ExtensionPermissionDialog is on, the layout is modified depending | 451 // If the ExtensionPermissionDialog is on, the layout is modified depending |
469 // on the experiment group. For text only experiment, a footer is added at the | 452 // on the experiment group. For text only experiment, a footer is added at the |
470 // bottom of the layouts. For others, inline details are added below some of | 453 // bottom of the layouts. For others, inline details are added below some of |
471 // the permissions. | 454 // the permissions. |
472 // | 455 // |
473 // Regular install w/ permissions and footer (experiment): | 456 // Regular install w/ permissions and footer (experiment): |
474 // +--------------------+------+ | 457 // +--------------------+------+ |
475 // | heading | icon | | 458 // | heading | icon | |
476 // +--------------------| | | 459 // +--------------------| | |
477 // | permissions_header | | | 460 // | permissions_header | | |
(...skipping 28 matching lines...) Expand all Loading... |
506 // +--------------------| | | 489 // +--------------------| | |
507 // |checkbox|permission1| | | 490 // |checkbox|permission1| | |
508 // +--------------------| | | 491 // +--------------------| | |
509 // |checkbox|permission2| | | 492 // |checkbox|permission2| | |
510 // +--------------------+------+ | 493 // +--------------------+------+ |
511 // | 494 // |
512 // Additionally, links or informational text is added to non-client areas of | 495 // Additionally, links or informational text is added to non-client areas of |
513 // the dialog depending on the experiment group. | 496 // the dialog depending on the experiment group. |
514 | 497 |
515 int left_column_width = | 498 int left_column_width = |
516 (prompt.ShouldShowPermissions() + prompt.GetOAuthIssueCount() + | 499 (prompt.ShouldShowPermissions() + |
517 prompt.GetRetainedFileCount()) > 0 ? | 500 prompt.GetRetainedFileCount()) > 0 ? |
518 kPermissionsLeftColumnWidth : kNoPermissionsLeftColumnWidth; | 501 kPermissionsLeftColumnWidth : kNoPermissionsLeftColumnWidth; |
519 if (is_bundle_install()) | 502 if (is_bundle_install()) |
520 left_column_width = kBundleLeftColumnWidth; | 503 left_column_width = kBundleLeftColumnWidth; |
521 if (is_external_install()) | 504 if (is_external_install()) |
522 left_column_width = kExternalInstallLeftColumnWidth; | 505 left_column_width = kExternalInstallLeftColumnWidth; |
523 | 506 |
524 scroll_view_ = new views::ScrollView(); | 507 scroll_view_ = new views::ScrollView(); |
525 scroll_view_->set_hide_horizontal_scrollbar(true); | 508 scroll_view_->set_hide_horizontal_scrollbar(true); |
526 AddChildView(scroll_view_); | 509 AddChildView(scroll_view_); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 layout->StartRow(0, column_set_id); | 682 layout->StartRow(0, column_set_id); |
700 views::Label* permission_label = new views::Label( | 683 views::Label* permission_label = new views::Label( |
701 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); | 684 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); |
702 permission_label->SetMultiLine(true); | 685 permission_label->SetMultiLine(true); |
703 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 686 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
704 permission_label->SizeToFit(left_column_width); | 687 permission_label->SizeToFit(left_column_width); |
705 layout->AddView(permission_label); | 688 layout->AddView(permission_label); |
706 } | 689 } |
707 } | 690 } |
708 | 691 |
709 if (prompt.GetOAuthIssueCount()) { | 692 if (prompt.GetRetainedFileCount()) { |
710 // Slide in under the permissions, if there are any. If there are | 693 // Slide in under the permissions, if there are any. If there are |
711 // permissions, the OAuth prompt stretches all the way to the right of the | 694 // either, the retained files prompt stretches all the way to the |
712 // dialog. If there are no permissions, the OAuth prompt just takes up the | 695 // right of the dialog. If there are no permissions, the retained |
713 // left column. | 696 // files prompt just takes up the left column. |
714 int space_for_oauth = left_column_width; | 697 int space_for_files = left_column_width; |
715 if (prompt.GetPermissionCount()) { | 698 if (prompt.GetPermissionCount()) { |
716 space_for_oauth += kIconSize; | |
717 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); | |
718 column_set->AddColumn(views::GridLayout::FILL, | |
719 views::GridLayout::FILL, | |
720 1, | |
721 views::GridLayout::USE_PREF, | |
722 0, // no fixed width | |
723 space_for_oauth); | |
724 } | |
725 | |
726 layout->StartRowWithPadding(0, column_set_id, | |
727 0, views::kRelatedControlVerticalSpacing); | |
728 views::Label* oauth_header = new views::Label(prompt.GetOAuthHeading()); | |
729 oauth_header->SetMultiLine(true); | |
730 oauth_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
731 oauth_header->SizeToFit(left_column_width); | |
732 layout->AddView(oauth_header); | |
733 | |
734 for (size_t i = 0; i < prompt.GetOAuthIssueCount(); ++i) { | |
735 layout->StartRowWithPadding( | |
736 0, column_set_id, | |
737 0, views::kRelatedControlVerticalSpacing); | |
738 | |
739 PermissionDetails details; | |
740 const IssueAdviceInfoEntry& entry = prompt.GetOAuthIssue(i); | |
741 for (size_t x = 0; x < entry.details.size(); ++x) | |
742 details.push_back(entry.details[x]); | |
743 ExpandableContainerView* issue_advice_view = | |
744 new ExpandableContainerView( | |
745 this, entry.description, details, space_for_oauth, | |
746 true, true, false); | |
747 layout->AddView(issue_advice_view); | |
748 } | |
749 } | |
750 if (prompt.GetRetainedFileCount()) { | |
751 // Slide in under the permissions or OAuth, if there are any. If there are | |
752 // either, the retained files prompt stretches all the way to the right of | |
753 // the dialog. If there are no permissions or OAuth, the retained files | |
754 // prompt just takes up the left column. | |
755 int space_for_files = left_column_width; | |
756 if (prompt.GetPermissionCount() || prompt.GetOAuthIssueCount()) { | |
757 space_for_files += kIconSize; | 699 space_for_files += kIconSize; |
758 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); | 700 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); |
759 column_set->AddColumn(views::GridLayout::FILL, | 701 column_set->AddColumn(views::GridLayout::FILL, |
760 views::GridLayout::FILL, | 702 views::GridLayout::FILL, |
761 1, | 703 1, |
762 views::GridLayout::USE_PREF, | 704 views::GridLayout::USE_PREF, |
763 0, // no fixed width | 705 0, // no fixed width |
764 space_for_files); | 706 space_for_files); |
765 } | 707 } |
766 | 708 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 explanation->SetMultiLine(true); | 751 explanation->SetMultiLine(true); |
810 explanation->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 752 explanation->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
811 explanation->SizeToFit(left_column_width + kIconSize); | 753 explanation->SizeToFit(left_column_width + kIconSize); |
812 layout->AddView(explanation); | 754 layout->AddView(explanation); |
813 } | 755 } |
814 | 756 |
815 if (prompt.experiment()->should_show_expandable_permission_list() || | 757 if (prompt.experiment()->should_show_expandable_permission_list() || |
816 (prompt.experiment()->show_details_link() && | 758 (prompt.experiment()->show_details_link() && |
817 prompt.experiment()->should_show_inline_explanations() && | 759 prompt.experiment()->should_show_inline_explanations() && |
818 !inline_explanations_.empty())) { | 760 !inline_explanations_.empty())) { |
819 // Don't show the "Show details" link if there are OAuth issues or | 761 // Don't show the "Show details" link if there are retained |
820 // retained files. These have their own "Show details" links and having | 762 // files. These have their own "Show details" links and having |
821 // multiple levels of links is confusing. | 763 // multiple levels of links is confusing. |
822 if (prompt.GetOAuthIssueCount() + prompt.GetRetainedFileCount() == 0) { | 764 if (prompt.GetRetainedFileCount() == 0) { |
823 int text_id = | 765 int text_id = |
824 prompt.experiment()->should_show_expandable_permission_list() ? | 766 prompt.experiment()->should_show_expandable_permission_list() ? |
825 IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_PERMISSIONS : | 767 IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_PERMISSIONS : |
826 IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_DETAILS; | 768 IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_DETAILS; |
827 show_details_link_ = new views::Link( | 769 show_details_link_ = new views::Link( |
828 l10n_util::GetStringUTF16(text_id)); | 770 l10n_util::GetStringUTF16(text_id)); |
829 show_details_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 771 show_details_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
830 show_details_link_->set_listener(this); | 772 show_details_link_->set_listener(this); |
831 UpdateLinkActionHistogram(LINK_SHOWN); | 773 UpdateLinkActionHistogram(LINK_SHOWN); |
832 } else { | 774 } else { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 int icon_row_span = 1; | 856 int icon_row_span = 1; |
915 if (is_inline_install()) { | 857 if (is_inline_install()) { |
916 // Also span the rating, user_count and store_link rows. | 858 // Also span the rating, user_count and store_link rows. |
917 icon_row_span = 4; | 859 icon_row_span = 4; |
918 } else if (prompt_.ShouldShowPermissions()) { | 860 } else if (prompt_.ShouldShowPermissions()) { |
919 size_t permission_count = prompt_.GetPermissionCount(); | 861 size_t permission_count = prompt_.GetPermissionCount(); |
920 // Also span the permission header and each of the permission rows (all | 862 // Also span the permission header and each of the permission rows (all |
921 // have a padding row above it). This also works for the 'no special | 863 // have a padding row above it). This also works for the 'no special |
922 // permissions' case. | 864 // permissions' case. |
923 icon_row_span = 3 + permission_count * 2; | 865 icon_row_span = 3 + permission_count * 2; |
924 } else if (prompt_.GetOAuthIssueCount()) { | |
925 // Also span the permission header and each of the permission rows (all | |
926 // have a padding row above it). | |
927 icon_row_span = 3 + prompt_.GetOAuthIssueCount() * 2; | |
928 } else if (prompt_.GetRetainedFileCount()) { | 866 } else if (prompt_.GetRetainedFileCount()) { |
929 // Also span the permission header and the retained files container. | 867 // Also span the permission header and the retained files container. |
930 icon_row_span = 4; | 868 icon_row_span = 4; |
931 } | 869 } |
932 layout->AddView(icon, 1, icon_row_span); | 870 layout->AddView(icon, 1, icon_row_span); |
933 } | 871 } |
934 } | 872 } |
935 return layout; | 873 return layout; |
936 } | 874 } |
937 | 875 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 if (slide_animation_.IsShowing()) | 1276 if (slide_animation_.IsShowing()) |
1339 slide_animation_.Hide(); | 1277 slide_animation_.Hide(); |
1340 else | 1278 else |
1341 slide_animation_.Show(); | 1279 slide_animation_.Show(); |
1342 } | 1280 } |
1343 | 1281 |
1344 void ExpandableContainerView::ExpandWithoutAnimation() { | 1282 void ExpandableContainerView::ExpandWithoutAnimation() { |
1345 expanded_ = true; | 1283 expanded_ = true; |
1346 details_view_->AnimateToState(1.0); | 1284 details_view_->AnimateToState(1.0); |
1347 } | 1285 } |
OLD | NEW |