Commit 25c3b927 authored by karandeepb's avatar karandeepb Committed by Commit bot

ExtensionInstallDialogView: Make scroll view and icon not overlap.

r411889 introduced scrolling with layers and gave the scroll view in
ExtensionInstallDialog an opaque background color. This caused the scroll view
to obscure the icon for the cases where the extension prompt has no webstore
data. This is because for this case, the scroll view and the icon view in the
ExtensionInstallDialogView overlap.

This CL fixes the regression by making the scroll view and icon view not overlap
for this case. The scroll view is extended to span the full content width and a
separator is added between the title and the scroll view if the prompt shows
permissions.

BUG=638093

Review-Url: https://codereview.chromium.org/2259723003
Cr-Commit-Position: refs/heads/master@{#414259}
parent 6f2ac611
...@@ -200,11 +200,15 @@ void ExtensionInstallDialogView::InitView() { ...@@ -200,11 +200,15 @@ void ExtensionInstallDialogView::InitView() {
// +---------------------+ // +---------------------+
// //
// No webstore data (all other types) // No webstore data (all other types)
// +--------------+------+ // w/ permissions no permissions
// | title | icon | // +--------------+------+ +--------------+------+
// +--------------| | // | title | icon | | title | icon |
// | scroll_view | | // +--------------+------+ +--------------+------+
// +--------------+------+ // | separator | | scroll_view (empty) |
// +---------------------+ +---------------------+
// | scroll_view |
// +---------------------+
// The scroll_view contains permissions (if there are any) and retained // The scroll_view contains permissions (if there are any) and retained
// files/devices (if there are any; post-install-permissions prompt only). // files/devices (if there are any; post-install-permissions prompt only).
int left_column_width = int left_column_width =
...@@ -248,43 +252,34 @@ void ExtensionInstallDialogView::InitView() { ...@@ -248,43 +252,34 @@ void ExtensionInstallDialogView::InitView() {
store_link->SetFontList(small_font_list); store_link->SetFontList(small_font_list);
store_link->set_listener(this); store_link->set_listener(this);
layout->AddView(store_link); layout->AddView(store_link);
}
if (prompt_->ShouldShowPermissions()) { if (prompt_->ShouldShowPermissions()) {
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL), layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 3, 1,
3, views::GridLayout::FILL, views::GridLayout::FILL);
1,
views::GridLayout::FILL,
views::GridLayout::FILL);
}
} }
int content_width = left_column_width + views::kPanelHorizMargin + kIconSize; const int content_width =
left_column_width + views::kPanelHorizMargin + kIconSize;
// Create the scrollable view which will contain the permissions and retained // Create the scrollable view which will contain the permissions and retained
// files/devices. // files/devices. It will span the full content width.
CustomScrollableView* scrollable = new CustomScrollableView(); CustomScrollableView* scrollable = new CustomScrollableView();
views::GridLayout* scroll_layout = new views::GridLayout(scrollable); views::GridLayout* scroll_layout = new views::GridLayout(scrollable);
scrollable->SetLayoutManager(scroll_layout); scrollable->SetLayoutManager(scroll_layout);
views::ColumnSet* scrollable_column_set = views::ColumnSet* scrollable_column_set =
scroll_layout->AddColumnSet(column_set_id); scroll_layout->AddColumnSet(column_set_id);
// If we have webstore data, there's a separator below it, so we can span the
// whole content width. Otherwise just use the width of the left column so scrollable_column_set->AddColumn(
// that we don't overlap the icon. views::GridLayout::LEADING, views::GridLayout::LEADING,
int scrollable_width = prompt_->has_webstore_data() ? content_width 0, // no resizing
: left_column_width; views::GridLayout::USE_PREF, content_width, content_width);
scrollable_column_set->AddColumn(views::GridLayout::LEADING,
views::GridLayout::LEADING,
0, // no resizing
views::GridLayout::USE_PREF,
scrollable_width,
scrollable_width);
// Pad to the very right of the dialog, so the scrollbar will be on the edge. // Pad to the very right of the dialog, so the scrollbar will be on the edge.
int padding_width = scrollable_column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
content_width + views::kButtonHEdgeMarginNew - scrollable_width;
scrollable_column_set->AddPaddingColumn(0, padding_width);
layout->StartRow(0, column_set_id); layout->StartRow(0, column_set_id);
scroll_view_ = new views::ScrollView(); scroll_view_ = new views::ScrollView();
...@@ -298,16 +293,10 @@ void ExtensionInstallDialogView::InitView() { ...@@ -298,16 +293,10 @@ void ExtensionInstallDialogView::InitView() {
ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0; ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0;
if (has_permissions) { if (has_permissions) {
AddPermissions( AddPermissions(
scroll_layout, scroll_layout, rb, column_set_id, content_width,
rb,
column_set_id,
scrollable_width,
ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS); ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS);
AddPermissions( AddPermissions(
scroll_layout, scroll_layout, rb, column_set_id, content_width,
rb,
column_set_id,
scrollable_width,
ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS); ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS);
} else { } else {
scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
...@@ -316,7 +305,7 @@ void ExtensionInstallDialogView::InitView() { ...@@ -316,7 +305,7 @@ void ExtensionInstallDialogView::InitView() {
l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS));
permission_label->SetMultiLine(true); permission_label->SetMultiLine(true);
permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
permission_label->SizeToFit(scrollable_width); permission_label->SizeToFit(content_width);
scroll_layout->AddView(permission_label); scroll_layout->AddView(permission_label);
} }
} }
...@@ -329,7 +318,7 @@ void ExtensionInstallDialogView::InitView() { ...@@ -329,7 +318,7 @@ void ExtensionInstallDialogView::InitView() {
new views::Label(prompt_->GetRetainedFilesHeading()); new views::Label(prompt_->GetRetainedFilesHeading());
retained_files_header->SetMultiLine(true); retained_files_header->SetMultiLine(true);
retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
retained_files_header->SizeToFit(scrollable_width); retained_files_header->SizeToFit(content_width);
scroll_layout->AddView(retained_files_header); scroll_layout->AddView(retained_files_header);
scroll_layout->StartRow(0, column_set_id); scroll_layout->StartRow(0, column_set_id);
...@@ -338,7 +327,7 @@ void ExtensionInstallDialogView::InitView() { ...@@ -338,7 +327,7 @@ void ExtensionInstallDialogView::InitView() {
details.push_back(prompt_->GetRetainedFile(i)); details.push_back(prompt_->GetRetainedFile(i));
} }
ExpandableContainerView* issue_advice_view = ExpandableContainerView* issue_advice_view =
new ExpandableContainerView(details, scrollable_width, false); new ExpandableContainerView(details, content_width, false);
scroll_layout->AddView(issue_advice_view); scroll_layout->AddView(issue_advice_view);
} }
...@@ -350,7 +339,7 @@ void ExtensionInstallDialogView::InitView() { ...@@ -350,7 +339,7 @@ void ExtensionInstallDialogView::InitView() {
new views::Label(prompt_->GetRetainedDevicesHeading()); new views::Label(prompt_->GetRetainedDevicesHeading());
retained_devices_header->SetMultiLine(true); retained_devices_header->SetMultiLine(true);
retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
retained_devices_header->SizeToFit(scrollable_width); retained_devices_header->SizeToFit(content_width);
scroll_layout->AddView(retained_devices_header); scroll_layout->AddView(retained_devices_header);
scroll_layout->StartRow(0, column_set_id); scroll_layout->StartRow(0, column_set_id);
...@@ -359,7 +348,7 @@ void ExtensionInstallDialogView::InitView() { ...@@ -359,7 +348,7 @@ void ExtensionInstallDialogView::InitView() {
details.push_back(prompt_->GetRetainedDeviceMessageString(i)); details.push_back(prompt_->GetRetainedDeviceMessageString(i));
} }
ExpandableContainerView* issue_advice_view = ExpandableContainerView* issue_advice_view =
new ExpandableContainerView(details, scrollable_width, false); new ExpandableContainerView(details, content_width, false);
scroll_layout->AddView(issue_advice_view); scroll_layout->AddView(issue_advice_view);
} }
...@@ -461,7 +450,10 @@ views::GridLayout* ExtensionInstallDialogView::CreateLayout( ...@@ -461,7 +450,10 @@ views::GridLayout* ExtensionInstallDialogView::CreateLayout(
title->SetMultiLine(true); title->SetMultiLine(true);
title->SetHorizontalAlignment(gfx::ALIGN_LEFT); title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
title->SizeToFit(left_column_width); title->SizeToFit(left_column_width);
layout->AddView(title);
// Center align the title along the vertical axis.
layout->AddView(title, 1, 1, views::GridLayout::LEADING,
views::GridLayout::CENTER);
// Scale down to icon size, but allow smaller icons (don't scale up). // Scale down to icon size, but allow smaller icons (don't scale up).
const gfx::ImageSkia* image = prompt_->icon().ToImageSkia(); const gfx::ImageSkia* image = prompt_->icon().ToImageSkia();
...@@ -472,15 +464,9 @@ views::GridLayout* ExtensionInstallDialogView::CreateLayout( ...@@ -472,15 +464,9 @@ views::GridLayout* ExtensionInstallDialogView::CreateLayout(
icon->SetImageSize(size); icon->SetImageSize(size);
icon->SetImage(*image); icon->SetImage(*image);
int icon_row_span = 1; // Always span the title. // Span the title row. In case the webstore data is available, also span the
if (prompt_->has_webstore_data()) { // rating, user_count and store_link rows.
// Also span the rating, user_count and store_link rows. const int icon_row_span = prompt_->has_webstore_data() ? 4 : 1;
icon_row_span += 3;
// Note: Do not span the permissions here, there's a separator in between!
} else {
// Also span the scrollable container with permissions, retained files etc.
icon_row_span += 1;
}
layout->AddView(icon, 1, icon_row_span); layout->AddView(icon, 1, icon_row_span);
return layout; return layout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment