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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_install_dialog_view.cc

Issue 2259723003: ExtensionInstallDialogView: Make scroll view and icon not overlap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions/extension_install_dialog_view.h" 5 #include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // | user_count | | | user_count | | 193 // | user_count | | | user_count | |
194 // +--------------| | +--------------| | 194 // +--------------| | +--------------| |
195 // | store_link | | | store_link | | 195 // | store_link | | | store_link | |
196 // +--------------+------+ +--------------+------+ 196 // +--------------+------+ +--------------+------+
197 // | separator | | scroll_view (empty) | 197 // | separator | | scroll_view (empty) |
198 // +---------------------+ +---------------------+ 198 // +---------------------+ +---------------------+
199 // | scroll_view | 199 // | scroll_view |
200 // +---------------------+ 200 // +---------------------+
201 // 201 //
202 // No webstore data (all other types) 202 // No webstore data (all other types)
203 // +--------------+------+ 203 // w/ permissions no permissions
204 // | title | icon | 204 // +--------------+------+ +--------------+------+
205 // +--------------| | 205 // | title | icon | | title | icon |
206 // | scroll_view | | 206 // +--------------+------+ +--------------+------+
207 // +--------------+------+ 207 // | separator | | scroll_view (empty) |
208 // +---------------------+ +---------------------+
209 // | scroll_view |
210 // +---------------------+
211
208 // The scroll_view contains permissions (if there are any) and retained 212 // The scroll_view contains permissions (if there are any) and retained
209 // files/devices (if there are any; post-install-permissions prompt only). 213 // files/devices (if there are any; post-install-permissions prompt only).
210 int left_column_width = 214 int left_column_width =
211 (prompt_->ShouldShowPermissions() || prompt_->GetRetainedFileCount() > 0) 215 (prompt_->ShouldShowPermissions() || prompt_->GetRetainedFileCount() > 0)
212 ? kPermissionsLeftColumnWidth 216 ? kPermissionsLeftColumnWidth
213 : kNoPermissionsLeftColumnWidth; 217 : kNoPermissionsLeftColumnWidth;
214 if (is_external_install()) 218 if (is_external_install())
215 left_column_width = kExternalInstallLeftColumnWidth; 219 left_column_width = kExternalInstallLeftColumnWidth;
216 220
217 int column_set_id = 0; 221 int column_set_id = 0;
(...skipping 23 matching lines...) Expand all
241 user_count->SetAutoColorReadabilityEnabled(false); 245 user_count->SetAutoColorReadabilityEnabled(false);
242 user_count->SetEnabledColor(SK_ColorGRAY); 246 user_count->SetEnabledColor(SK_ColorGRAY);
243 layout->AddView(user_count); 247 layout->AddView(user_count);
244 248
245 layout->StartRow(0, column_set_id); 249 layout->StartRow(0, column_set_id);
246 views::Link* store_link = new views::Link( 250 views::Link* store_link = new views::Link(
247 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); 251 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK));
248 store_link->SetFontList(small_font_list); 252 store_link->SetFontList(small_font_list);
249 store_link->set_listener(this); 253 store_link->set_listener(this);
250 layout->AddView(store_link); 254 layout->AddView(store_link);
251
252 if (prompt_->ShouldShowPermissions()) {
253 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
254 layout->StartRow(0, column_set_id);
255 layout->AddView(new views::Separator(views::Separator::HORIZONTAL),
256 3,
257 1,
258 views::GridLayout::FILL,
259 views::GridLayout::FILL);
260 }
261 } 255 }
262 256
263 int content_width = left_column_width + views::kPanelHorizMargin + kIconSize; 257 if (prompt_->ShouldShowPermissions()) {
258 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
259 layout->StartRow(0, column_set_id);
260 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 3, 1,
261 views::GridLayout::FILL, views::GridLayout::FILL);
262 }
263
264 const int content_width =
265 left_column_width + views::kPanelHorizMargin + kIconSize;
264 266
265 // Create the scrollable view which will contain the permissions and retained 267 // Create the scrollable view which will contain the permissions and retained
266 // files/devices. 268 // files/devices. It will span the full content width.
267 CustomScrollableView* scrollable = new CustomScrollableView(); 269 CustomScrollableView* scrollable = new CustomScrollableView();
268 views::GridLayout* scroll_layout = new views::GridLayout(scrollable); 270 views::GridLayout* scroll_layout = new views::GridLayout(scrollable);
269 scrollable->SetLayoutManager(scroll_layout); 271 scrollable->SetLayoutManager(scroll_layout);
270 272
271 views::ColumnSet* scrollable_column_set = 273 views::ColumnSet* scrollable_column_set =
272 scroll_layout->AddColumnSet(column_set_id); 274 scroll_layout->AddColumnSet(column_set_id);
273 // If we have webstore data, there's a separator below it, so we can span the 275
274 // whole content width. Otherwise just use the width of the left column so 276 scrollable_column_set->AddColumn(
275 // that we don't overlap the icon. 277 views::GridLayout::LEADING, views::GridLayout::LEADING,
276 int scrollable_width = prompt_->has_webstore_data() ? content_width 278 0, // no resizing
277 : left_column_width; 279 views::GridLayout::USE_PREF, content_width, content_width);
278 scrollable_column_set->AddColumn(views::GridLayout::LEADING, 280
279 views::GridLayout::LEADING,
280 0, // no resizing
281 views::GridLayout::USE_PREF,
282 scrollable_width,
283 scrollable_width);
284 // Pad to the very right of the dialog, so the scrollbar will be on the edge. 281 // Pad to the very right of the dialog, so the scrollbar will be on the edge.
285 int padding_width = 282 scrollable_column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
286 content_width + views::kButtonHEdgeMarginNew - scrollable_width;
287 scrollable_column_set->AddPaddingColumn(0, padding_width);
288 283
289 layout->StartRow(0, column_set_id); 284 layout->StartRow(0, column_set_id);
290 scroll_view_ = new views::ScrollView(); 285 scroll_view_ = new views::ScrollView();
291 scroll_view_->set_hide_horizontal_scrollbar(true); 286 scroll_view_->set_hide_horizontal_scrollbar(true);
292 scroll_view_->SetContents(scrollable); 287 scroll_view_->SetContents(scrollable);
293 layout->AddView(scroll_view_, 4, 1); 288 layout->AddView(scroll_view_, 4, 1);
294 289
295 if (prompt_->ShouldShowPermissions()) { 290 if (prompt_->ShouldShowPermissions()) {
296 bool has_permissions = 291 bool has_permissions =
297 prompt_->GetPermissionCount( 292 prompt_->GetPermissionCount(
298 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0; 293 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0;
299 if (has_permissions) { 294 if (has_permissions) {
300 AddPermissions( 295 AddPermissions(
301 scroll_layout, 296 scroll_layout, rb, column_set_id, content_width,
302 rb,
303 column_set_id,
304 scrollable_width,
305 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS); 297 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS);
306 AddPermissions( 298 AddPermissions(
307 scroll_layout, 299 scroll_layout, rb, column_set_id, content_width,
308 rb,
309 column_set_id,
310 scrollable_width,
311 ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS); 300 ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS);
312 } else { 301 } else {
313 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 302 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
314 scroll_layout->StartRow(0, column_set_id); 303 scroll_layout->StartRow(0, column_set_id);
315 views::Label* permission_label = new views::Label( 304 views::Label* permission_label = new views::Label(
316 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); 305 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS));
317 permission_label->SetMultiLine(true); 306 permission_label->SetMultiLine(true);
318 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 307 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
319 permission_label->SizeToFit(scrollable_width); 308 permission_label->SizeToFit(content_width);
320 scroll_layout->AddView(permission_label); 309 scroll_layout->AddView(permission_label);
321 } 310 }
322 } 311 }
323 312
324 if (prompt_->GetRetainedFileCount()) { 313 if (prompt_->GetRetainedFileCount()) {
325 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 314 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
326 315
327 scroll_layout->StartRow(0, column_set_id); 316 scroll_layout->StartRow(0, column_set_id);
328 views::Label* retained_files_header = 317 views::Label* retained_files_header =
329 new views::Label(prompt_->GetRetainedFilesHeading()); 318 new views::Label(prompt_->GetRetainedFilesHeading());
330 retained_files_header->SetMultiLine(true); 319 retained_files_header->SetMultiLine(true);
331 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); 320 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
332 retained_files_header->SizeToFit(scrollable_width); 321 retained_files_header->SizeToFit(content_width);
333 scroll_layout->AddView(retained_files_header); 322 scroll_layout->AddView(retained_files_header);
334 323
335 scroll_layout->StartRow(0, column_set_id); 324 scroll_layout->StartRow(0, column_set_id);
336 PermissionDetails details; 325 PermissionDetails details;
337 for (size_t i = 0; i < prompt_->GetRetainedFileCount(); ++i) { 326 for (size_t i = 0; i < prompt_->GetRetainedFileCount(); ++i) {
338 details.push_back(prompt_->GetRetainedFile(i)); 327 details.push_back(prompt_->GetRetainedFile(i));
339 } 328 }
340 ExpandableContainerView* issue_advice_view = 329 ExpandableContainerView* issue_advice_view =
341 new ExpandableContainerView(details, scrollable_width, false); 330 new ExpandableContainerView(details, content_width, false);
342 scroll_layout->AddView(issue_advice_view); 331 scroll_layout->AddView(issue_advice_view);
343 } 332 }
344 333
345 if (prompt_->GetRetainedDeviceCount()) { 334 if (prompt_->GetRetainedDeviceCount()) {
346 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 335 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
347 336
348 scroll_layout->StartRow(0, column_set_id); 337 scroll_layout->StartRow(0, column_set_id);
349 views::Label* retained_devices_header = 338 views::Label* retained_devices_header =
350 new views::Label(prompt_->GetRetainedDevicesHeading()); 339 new views::Label(prompt_->GetRetainedDevicesHeading());
351 retained_devices_header->SetMultiLine(true); 340 retained_devices_header->SetMultiLine(true);
352 retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); 341 retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
353 retained_devices_header->SizeToFit(scrollable_width); 342 retained_devices_header->SizeToFit(content_width);
354 scroll_layout->AddView(retained_devices_header); 343 scroll_layout->AddView(retained_devices_header);
355 344
356 scroll_layout->StartRow(0, column_set_id); 345 scroll_layout->StartRow(0, column_set_id);
357 PermissionDetails details; 346 PermissionDetails details;
358 for (size_t i = 0; i < prompt_->GetRetainedDeviceCount(); ++i) { 347 for (size_t i = 0; i < prompt_->GetRetainedDeviceCount(); ++i) {
359 details.push_back(prompt_->GetRetainedDeviceMessageString(i)); 348 details.push_back(prompt_->GetRetainedDeviceMessageString(i));
360 } 349 }
361 ExpandableContainerView* issue_advice_view = 350 ExpandableContainerView* issue_advice_view =
362 new ExpandableContainerView(details, scrollable_width, false); 351 new ExpandableContainerView(details, content_width, false);
363 scroll_layout->AddView(issue_advice_view); 352 scroll_layout->AddView(issue_advice_view);
364 } 353 }
365 354
366 DCHECK_GE(prompt_->type(), 0); 355 DCHECK_GE(prompt_->type(), 0);
367 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", 356 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type",
368 prompt_->type(), 357 prompt_->type(),
369 ExtensionInstallPrompt::NUM_PROMPT_TYPES); 358 ExtensionInstallPrompt::NUM_PROMPT_TYPES);
370 359
371 scroll_view_->ClipHeightTo( 360 scroll_view_->ClipHeightTo(
372 0, 361 0,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 443 column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
455 444
456 layout->StartRow(0, column_set_id); 445 layout->StartRow(0, column_set_id);
457 views::Label* title = 446 views::Label* title =
458 new views::Label(prompt_->GetDialogTitle(), 447 new views::Label(prompt_->GetDialogTitle(),
459 ui::ResourceBundle::GetSharedInstance().GetFontList( 448 ui::ResourceBundle::GetSharedInstance().GetFontList(
460 ui::ResourceBundle::MediumFont)); 449 ui::ResourceBundle::MediumFont));
461 title->SetMultiLine(true); 450 title->SetMultiLine(true);
462 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); 451 title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
463 title->SizeToFit(left_column_width); 452 title->SizeToFit(left_column_width);
464 layout->AddView(title); 453
454 // Center align the title along the vertical axis.
455 layout->AddView(title, 1, 1, views::GridLayout::LEADING,
karandeepb 2016/08/19 02:30:02 This helps decrease the gap b/w the title and body
456 views::GridLayout::CENTER);
465 457
466 // Scale down to icon size, but allow smaller icons (don't scale up). 458 // Scale down to icon size, but allow smaller icons (don't scale up).
467 const gfx::ImageSkia* image = prompt_->icon().ToImageSkia(); 459 const gfx::ImageSkia* image = prompt_->icon().ToImageSkia();
468 gfx::Size size(image->width(), image->height()); 460 gfx::Size size(image->width(), image->height());
469 if (size.width() > kIconSize || size.height() > kIconSize) 461 if (size.width() > kIconSize || size.height() > kIconSize)
470 size = gfx::Size(kIconSize, kIconSize); 462 size = gfx::Size(kIconSize, kIconSize);
471 views::ImageView* icon = new views::ImageView(); 463 views::ImageView* icon = new views::ImageView();
472 icon->SetImageSize(size); 464 icon->SetImageSize(size);
473 icon->SetImage(*image); 465 icon->SetImage(*image);
474 466
475 int icon_row_span = 1; // Always span the title. 467 // Span the title row. In case the webstore data is available, also span the
476 if (prompt_->has_webstore_data()) { 468 // rating, user_count and store_link rows.
477 // Also span the rating, user_count and store_link rows. 469 const int icon_row_span = prompt_->has_webstore_data() ? 4 : 1;
478 icon_row_span += 3;
479 // Note: Do not span the permissions here, there's a separator in between!
480 } else {
481 // Also span the scrollable container with permissions, retained files etc.
482 icon_row_span += 1;
483 }
484 layout->AddView(icon, 1, icon_row_span); 470 layout->AddView(icon, 1, icon_row_span);
485 471
486 return layout; 472 return layout;
487 } 473 }
488 474
489 void ExtensionInstallDialogView::OnNativeThemeChanged( 475 void ExtensionInstallDialogView::OnNativeThemeChanged(
490 const ui::NativeTheme* theme) { 476 const ui::NativeTheme* theme) {
491 scroll_view_->SetBackgroundColor( 477 scroll_view_->SetBackgroundColor(
492 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)); 478 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground));
493 } 479 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 expanded ? gfx::VectorIconId::FIND_PREV : gfx::VectorIconId::FIND_NEXT, 733 expanded ? gfx::VectorIconId::FIND_PREV : gfx::VectorIconId::FIND_NEXT,
748 gfx::kChromeIconGrey); 734 gfx::kChromeIconGrey);
749 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); 735 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon);
750 } 736 }
751 737
752 // static 738 // static
753 ExtensionInstallPrompt::ShowDialogCallback 739 ExtensionInstallPrompt::ShowDialogCallback
754 ExtensionInstallPrompt::GetViewsShowDialogCallback() { 740 ExtensionInstallPrompt::GetViewsShowDialogCallback() {
755 return base::Bind(&ShowExtensionInstallDialogImpl); 741 return base::Bind(&ShowExtensionInstallDialogImpl);
756 } 742 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698