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 "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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 #include "ui/native_theme/common_theme.h" | 42 #include "ui/native_theme/common_theme.h" |
43 #include "ui/views/border.h" | 43 #include "ui/views/border.h" |
44 #include "ui/views/controls/button/image_button.h" | 44 #include "ui/views/controls/button/image_button.h" |
45 #include "ui/views/controls/image_view.h" | 45 #include "ui/views/controls/image_view.h" |
46 #include "ui/views/controls/label.h" | 46 #include "ui/views/controls/label.h" |
47 #include "ui/views/controls/link.h" | 47 #include "ui/views/controls/link.h" |
48 #include "ui/views/controls/scroll_view.h" | 48 #include "ui/views/controls/scroll_view.h" |
49 #include "ui/views/controls/separator.h" | 49 #include "ui/views/controls/separator.h" |
50 #include "ui/views/layout/box_layout.h" | 50 #include "ui/views/layout/box_layout.h" |
51 #include "ui/views/layout/grid_layout.h" | 51 #include "ui/views/layout/grid_layout.h" |
52 #include "ui/views/layout/layout_constants.h" | |
53 #include "ui/views/widget/widget.h" | 52 #include "ui/views/widget/widget.h" |
54 | 53 |
55 using content::OpenURLParams; | 54 using content::OpenURLParams; |
56 using content::Referrer; | 55 using content::Referrer; |
57 using extensions::ExperienceSamplingEvent; | 56 using extensions::ExperienceSamplingEvent; |
58 | 57 |
59 namespace { | 58 namespace { |
60 | 59 |
61 // Width of the bullet column in BulletedView. | 60 // Width of the bullet column in BulletedView. |
62 const int kBulletWidth = 20; | 61 constexpr int kBulletWidth = 20; |
63 | 62 |
64 // Size of extension icon in top left of dialog. | 63 // Size of extension icon in top left of dialog. |
65 const int kIconSize = 64; | 64 constexpr int kIconSize = 64; |
65 | |
66 // The padding to put just above the link to view more details. | |
67 constexpr int kPaddingAboveDetailsLink = 4; | |
66 | 68 |
67 // The maximum height of the scroll view before it will show a scrollbar. | 69 // The maximum height of the scroll view before it will show a scrollbar. |
68 const int kScrollViewMaxHeight = 250; | 70 constexpr int kScrollViewMaxHeight = 250; |
69 | 71 |
70 // Width of the left column of the dialog when the extension requests | 72 // Width of the left column of the dialog when the extension requests |
71 // permissions. | 73 // permissions. |
72 const int kPermissionsLeftColumnWidth = 250; | 74 constexpr int kPermissionsLeftColumnWidth = 250; |
73 | 75 |
74 // Width of the left column of the dialog when the extension requests no | 76 // Width of the left column of the dialog when the extension requests no |
75 // permissions. | 77 // permissions. |
76 const int kNoPermissionsLeftColumnWidth = 200; | 78 constexpr int kNoPermissionsLeftColumnWidth = 200; |
77 | 79 |
78 // Width of the left column for external install prompts. The text is long in | 80 // Width of the left column for external install prompts. The text is long in |
79 // this case, so make it wider than normal. | 81 // this case, so make it wider than normal. |
80 const int kExternalInstallLeftColumnWidth = 350; | 82 constexpr int kExternalInstallLeftColumnWidth = 350; |
83 | |
84 // Get the appropriate indentation for an item if its parent is using bullet | |
85 // points. If the parent is using bullets for its items, then a padding of one | |
86 // unit will make the child item (which has no bullet) look like a sibling of | |
87 // its parent. Therefore increase the indentation by one more unit to show that | |
88 // it is in fact a child item (with no missing bullet) and not a sibling. | |
89 int GetLeftPaddingForBulletedItems(bool parent_bulleted) { | |
90 return LayoutDelegate::Get()->GetMetric( | |
91 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING) * | |
Peter Kasting
2017/03/23 04:21:34
Seems like this should be RELATED_CONTROL_HORIZONT
Patti Lor
2017/03/24 06:37:12
Yeah - Looks like I used the wrong when converting
| |
92 (parent_bulleted ? 2 : 1); | |
93 } | |
81 | 94 |
82 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) { | 95 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) { |
83 views::View* parent = static_cast<views::View*>(data); | 96 views::View* parent = static_cast<views::View*>(data); |
84 views::ImageView* image_view = new views::ImageView(); | 97 views::ImageView* image_view = new views::ImageView(); |
85 image_view->SetImage(*skia_image); | 98 image_view->SetImage(*skia_image); |
86 parent->AddChildView(image_view); | 99 parent->AddChildView(image_view); |
87 } | 100 } |
88 | 101 |
89 // Creates a string for displaying |message| to the user. If it has to look | 102 // Creates a string for displaying |message| to the user. If it has to look |
90 // like a entry in a bullet point list, one is added. | 103 // like a entry in a bullet point list, one is added. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 rating->AddChildView(rating_count); | 253 rating->AddChildView(rating_count); |
241 | 254 |
242 layout->StartRow(0, column_set_id); | 255 layout->StartRow(0, column_set_id); |
243 views::Label* user_count = | 256 views::Label* user_count = |
244 new views::Label(prompt_->GetUserCount(), small_font_list); | 257 new views::Label(prompt_->GetUserCount(), small_font_list); |
245 user_count->SetAutoColorReadabilityEnabled(false); | 258 user_count->SetAutoColorReadabilityEnabled(false); |
246 user_count->SetEnabledColor(SK_ColorGRAY); | 259 user_count->SetEnabledColor(SK_ColorGRAY); |
247 layout->AddView(user_count); | 260 layout->AddView(user_count); |
248 } | 261 } |
249 | 262 |
263 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); | |
264 const int vertical_padding = layout_delegate->GetMetric( | |
265 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING); | |
250 if (prompt_->ShouldShowPermissions()) { | 266 if (prompt_->ShouldShowPermissions()) { |
251 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 267 layout->AddPaddingRow(0, vertical_padding); |
252 layout->StartRow(0, column_set_id); | 268 layout->StartRow(0, column_set_id); |
253 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, | 269 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, |
254 views::GridLayout::FILL); | 270 views::GridLayout::FILL); |
255 } | 271 } |
256 | 272 |
257 const int content_width = left_column_width + | 273 const int content_width = |
258 LayoutDelegate::Get()->GetMetric( | 274 left_column_width + |
259 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN) + | 275 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN) + |
260 kIconSize; | 276 kIconSize; |
261 | 277 |
262 // Create the scrollable view which will contain the permissions and retained | 278 // Create the scrollable view which will contain the permissions and retained |
263 // files/devices. It will span the full content width. | 279 // files/devices. It will span the full content width. |
264 CustomScrollableView* scrollable = new CustomScrollableView(); | 280 CustomScrollableView* scrollable = new CustomScrollableView(); |
265 views::GridLayout* scroll_layout = new views::GridLayout(scrollable); | 281 views::GridLayout* scroll_layout = new views::GridLayout(scrollable); |
266 scrollable->SetLayoutManager(scroll_layout); | 282 scrollable->SetLayoutManager(scroll_layout); |
267 | 283 |
268 views::ColumnSet* scrollable_column_set = | 284 views::ColumnSet* scrollable_column_set = |
269 scroll_layout->AddColumnSet(column_set_id); | 285 scroll_layout->AddColumnSet(column_set_id); |
270 | 286 |
271 scrollable_column_set->AddColumn( | 287 scrollable_column_set->AddColumn( |
272 views::GridLayout::LEADING, views::GridLayout::LEADING, | 288 views::GridLayout::LEADING, views::GridLayout::LEADING, |
273 0, // no resizing | 289 0, // no resizing |
274 views::GridLayout::USE_PREF, content_width, content_width); | 290 views::GridLayout::USE_PREF, content_width, content_width); |
275 | 291 |
276 // Pad to the very right of the dialog, so the scrollbar will be on the edge. | 292 // Pad to the very right of the dialog, so the scrollbar will be on the edge. |
277 scrollable_column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 293 const int button_margin = |
294 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN); | |
295 scrollable_column_set->AddPaddingColumn(0, button_margin); | |
278 | 296 |
279 layout->StartRow(0, column_set_id); | 297 layout->StartRow(0, column_set_id); |
280 scroll_view_ = new views::ScrollView(); | 298 scroll_view_ = new views::ScrollView(); |
281 scroll_view_->set_hide_horizontal_scrollbar(true); | 299 scroll_view_->set_hide_horizontal_scrollbar(true); |
282 scroll_view_->SetContents(scrollable); | 300 scroll_view_->SetContents(scrollable); |
283 layout->AddView(scroll_view_, 4, 1); | 301 layout->AddView(scroll_view_, 4, 1); |
284 | 302 |
285 if (prompt_->ShouldShowPermissions()) { | 303 if (prompt_->ShouldShowPermissions()) { |
286 bool has_permissions = | 304 bool has_permissions = |
287 prompt_->GetPermissionCount( | 305 prompt_->GetPermissionCount( |
288 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0; | 306 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0; |
289 if (has_permissions) { | 307 if (has_permissions) { |
290 AddPermissions( | 308 AddPermissions( |
291 scroll_layout, rb, column_set_id, content_width, | 309 scroll_layout, rb, column_set_id, content_width, |
292 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS); | 310 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS); |
293 AddPermissions( | 311 AddPermissions( |
294 scroll_layout, rb, column_set_id, content_width, | 312 scroll_layout, rb, column_set_id, content_width, |
295 ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS); | 313 ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS); |
296 } else { | 314 } else { |
297 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 315 scroll_layout->AddPaddingRow(0, vertical_padding); |
298 scroll_layout->StartRow(0, column_set_id); | 316 scroll_layout->StartRow(0, column_set_id); |
299 views::Label* permission_label = new views::Label( | 317 views::Label* permission_label = new views::Label( |
300 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); | 318 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); |
301 permission_label->SetMultiLine(true); | 319 permission_label->SetMultiLine(true); |
302 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 320 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
303 permission_label->SizeToFit(content_width); | 321 permission_label->SizeToFit(content_width); |
304 scroll_layout->AddView(permission_label); | 322 scroll_layout->AddView(permission_label); |
305 } | 323 } |
306 } | 324 } |
307 | 325 |
308 if (prompt_->GetRetainedFileCount()) { | 326 if (prompt_->GetRetainedFileCount()) { |
309 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 327 scroll_layout->AddPaddingRow(0, vertical_padding); |
310 | 328 |
311 scroll_layout->StartRow(0, column_set_id); | 329 scroll_layout->StartRow(0, column_set_id); |
312 views::Label* retained_files_header = | 330 views::Label* retained_files_header = |
313 new views::Label(prompt_->GetRetainedFilesHeading()); | 331 new views::Label(prompt_->GetRetainedFilesHeading()); |
314 retained_files_header->SetMultiLine(true); | 332 retained_files_header->SetMultiLine(true); |
315 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 333 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
316 retained_files_header->SizeToFit(content_width); | 334 retained_files_header->SizeToFit(content_width); |
317 scroll_layout->AddView(retained_files_header); | 335 scroll_layout->AddView(retained_files_header); |
318 | 336 |
319 scroll_layout->StartRow(0, column_set_id); | 337 scroll_layout->StartRow(0, column_set_id); |
320 PermissionDetails details; | 338 PermissionDetails details; |
321 for (size_t i = 0; i < prompt_->GetRetainedFileCount(); ++i) { | 339 for (size_t i = 0; i < prompt_->GetRetainedFileCount(); ++i) { |
322 details.push_back(prompt_->GetRetainedFile(i)); | 340 details.push_back(prompt_->GetRetainedFile(i)); |
323 } | 341 } |
324 ExpandableContainerView* issue_advice_view = | 342 ExpandableContainerView* issue_advice_view = |
325 new ExpandableContainerView(details, content_width, false); | 343 new ExpandableContainerView(details, content_width, false); |
326 scroll_layout->AddView(issue_advice_view); | 344 scroll_layout->AddView(issue_advice_view); |
327 } | 345 } |
328 | 346 |
329 if (prompt_->GetRetainedDeviceCount()) { | 347 if (prompt_->GetRetainedDeviceCount()) { |
330 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 348 scroll_layout->AddPaddingRow(0, vertical_padding); |
331 | 349 |
332 scroll_layout->StartRow(0, column_set_id); | 350 scroll_layout->StartRow(0, column_set_id); |
333 views::Label* retained_devices_header = | 351 views::Label* retained_devices_header = |
334 new views::Label(prompt_->GetRetainedDevicesHeading()); | 352 new views::Label(prompt_->GetRetainedDevicesHeading()); |
335 retained_devices_header->SetMultiLine(true); | 353 retained_devices_header->SetMultiLine(true); |
336 retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 354 retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
337 retained_devices_header->SizeToFit(content_width); | 355 retained_devices_header->SizeToFit(content_width); |
338 scroll_layout->AddView(retained_devices_header); | 356 scroll_layout->AddView(retained_devices_header); |
339 | 357 |
340 scroll_layout->StartRow(0, column_set_id); | 358 scroll_layout->StartRow(0, column_set_id); |
341 PermissionDetails details; | 359 PermissionDetails details; |
342 for (size_t i = 0; i < prompt_->GetRetainedDeviceCount(); ++i) { | 360 for (size_t i = 0; i < prompt_->GetRetainedDeviceCount(); ++i) { |
343 details.push_back(prompt_->GetRetainedDeviceMessageString(i)); | 361 details.push_back(prompt_->GetRetainedDeviceMessageString(i)); |
344 } | 362 } |
345 ExpandableContainerView* issue_advice_view = | 363 ExpandableContainerView* issue_advice_view = |
346 new ExpandableContainerView(details, content_width, false); | 364 new ExpandableContainerView(details, content_width, false); |
347 scroll_layout->AddView(issue_advice_view); | 365 scroll_layout->AddView(issue_advice_view); |
348 } | 366 } |
349 | 367 |
350 DCHECK_GE(prompt_->type(), 0); | 368 DCHECK_GE(prompt_->type(), 0); |
351 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", | 369 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", |
352 prompt_->type(), | 370 prompt_->type(), |
353 ExtensionInstallPrompt::NUM_PROMPT_TYPES); | 371 ExtensionInstallPrompt::NUM_PROMPT_TYPES); |
354 | 372 |
355 scroll_view_->ClipHeightTo( | 373 scroll_view_->ClipHeightTo( |
356 0, | 374 0, |
357 std::min(kScrollViewMaxHeight, scrollable->GetPreferredSize().height())); | 375 std::min(kScrollViewMaxHeight, scrollable->GetPreferredSize().height())); |
358 | 376 |
359 dialog_size_ = gfx::Size( | 377 dialog_size_ = gfx::Size(content_width + 2 * button_margin, |
360 content_width + 2 * views::kButtonHEdgeMarginNew, | 378 container_->GetPreferredSize().height()); |
361 container_->GetPreferredSize().height()); | |
362 | 379 |
363 std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog; | 380 std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog; |
364 event_name.append( | 381 event_name.append( |
365 ExtensionInstallPrompt::PromptTypeToString(prompt_->type())); | 382 ExtensionInstallPrompt::PromptTypeToString(prompt_->type())); |
366 sampling_event_ = ExperienceSamplingEvent::Create(event_name); | 383 sampling_event_ = ExperienceSamplingEvent::Create(event_name); |
367 } | 384 } |
368 | 385 |
369 bool ExtensionInstallDialogView::AddPermissions( | 386 bool ExtensionInstallDialogView::AddPermissions( |
370 views::GridLayout* layout, | 387 views::GridLayout* layout, |
371 ui::ResourceBundle& rb, | 388 ui::ResourceBundle& rb, |
372 int column_set_id, | 389 int column_set_id, |
373 int left_column_width, | 390 int left_column_width, |
374 ExtensionInstallPrompt::PermissionsType perm_type) { | 391 ExtensionInstallPrompt::PermissionsType perm_type) { |
375 if (prompt_->GetPermissionCount(perm_type) == 0) | 392 if (prompt_->GetPermissionCount(perm_type) == 0) |
376 return false; | 393 return false; |
377 | 394 |
378 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 395 const int vertical_padding = LayoutDelegate::Get()->GetMetric( |
396 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING); | |
397 layout->AddPaddingRow(0, vertical_padding); | |
379 | 398 |
380 layout->StartRow(0, column_set_id); | 399 layout->StartRow(0, column_set_id); |
381 views::Label* permissions_header = | 400 views::Label* permissions_header = |
382 new views::Label(prompt_->GetPermissionsHeading(perm_type)); | 401 new views::Label(prompt_->GetPermissionsHeading(perm_type)); |
383 permissions_header->SetMultiLine(true); | 402 permissions_header->SetMultiLine(true); |
384 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 403 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
385 permissions_header->SizeToFit(left_column_width); | 404 permissions_header->SizeToFit(left_column_width); |
386 layout->AddView(permissions_header); | 405 layout->AddView(permissions_header); |
387 | 406 |
388 for (size_t i = 0; i < prompt_->GetPermissionCount(perm_type); ++i) { | 407 for (size_t i = 0; i < prompt_->GetPermissionCount(perm_type); ++i) { |
389 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 408 layout->AddPaddingRow(0, vertical_padding); |
390 layout->StartRow(0, column_set_id); | 409 layout->StartRow(0, column_set_id); |
391 views::Label* permission_label = | 410 views::Label* permission_label = |
392 new views::Label(prompt_->GetPermission(i, perm_type)); | 411 new views::Label(prompt_->GetPermission(i, perm_type)); |
393 | 412 |
394 permission_label->SetMultiLine(true); | 413 permission_label->SetMultiLine(true); |
395 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 414 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
396 permission_label->SizeToFit(left_column_width - kBulletWidth); | 415 permission_label->SizeToFit(left_column_width - kBulletWidth); |
397 layout->AddView(new BulletedView(permission_label)); | 416 layout->AddView(new BulletedView(permission_label)); |
398 | 417 |
399 // If we have more details to provide, show them in collapsed form. | 418 // If we have more details to provide, show them in collapsed form. |
400 if (!prompt_->GetPermissionsDetails(i, perm_type).empty()) { | 419 if (!prompt_->GetPermissionsDetails(i, perm_type).empty()) { |
401 layout->StartRow(0, column_set_id); | 420 layout->StartRow(0, column_set_id); |
402 PermissionDetails details; | 421 PermissionDetails details; |
403 details.push_back(PrepareForDisplay( | 422 details.push_back(PrepareForDisplay( |
404 prompt_->GetPermissionsDetails(i, perm_type), false)); | 423 prompt_->GetPermissionsDetails(i, perm_type), false)); |
405 ExpandableContainerView* details_container = | 424 ExpandableContainerView* details_container = |
406 new ExpandableContainerView(details, left_column_width, true); | 425 new ExpandableContainerView(details, left_column_width, true); |
407 layout->AddView(details_container); | 426 layout->AddView(details_container); |
408 } | 427 } |
409 } | 428 } |
410 return true; | 429 return true; |
411 } | 430 } |
412 | 431 |
413 views::GridLayout* ExtensionInstallDialogView::CreateLayout( | 432 views::GridLayout* ExtensionInstallDialogView::CreateLayout( |
414 int left_column_width, | 433 int left_column_width, |
415 int column_set_id) { | 434 int column_set_id) { |
416 container_ = new views::View(); | 435 container_ = new views::View(); |
417 // This is basically views::GridLayout::CreatePanel, but without a top or | 436 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); |
418 // right margin (we effectively get a top margin anyway from the empty dialog | 437 const int horizontal_margin = |
419 // title, and we add an explicit padding column as a right margin below). | 438 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN); |
439 const int bottom_margin = | |
440 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN); | |
441 | |
442 // This is views::GridLayout::CreatePanel(), but without a top or right | |
443 // margin. The empty dialog title will then become the top margin, and a | |
444 // padding column will be manually added to handle a right margin. This is | |
445 // done so that the extension icon can be shown on the right of the dialog | |
446 // title, but on the same y-axis, and the scroll view used to contain other | |
447 // content can have its scrollbar aligned with the right edge of the dialog. | |
420 views::GridLayout* layout = new views::GridLayout(container_); | 448 views::GridLayout* layout = new views::GridLayout(container_); |
421 layout->SetInsets(0, views::kButtonHEdgeMarginNew, | 449 layout->SetInsets(0, horizontal_margin, bottom_margin, 0); |
422 LayoutDelegate::Get()->GetMetric( | |
423 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), | |
424 0); | |
425 container_->SetLayoutManager(layout); | 450 container_->SetLayoutManager(layout); |
426 AddChildView(container_); | 451 AddChildView(container_); |
427 | 452 |
428 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); | 453 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); |
429 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, | 454 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, |
430 0, // no resizing | 455 0, // no resizing |
431 views::GridLayout::USE_PREF, | 456 views::GridLayout::USE_PREF, |
432 0, // no fixed width | 457 0, // no fixed width |
433 left_column_width); | 458 left_column_width); |
434 column_set->AddPaddingColumn( | 459 column_set->AddPaddingColumn( |
435 0, LayoutDelegate::Get()->GetMetric( | 460 0, layout_delegate->GetMetric( |
436 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); | 461 LayoutDelegate::Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING)); |
437 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, | 462 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
438 0, // no resizing | 463 0, // no resizing |
439 views::GridLayout::USE_PREF, | 464 views::GridLayout::USE_PREF, |
440 0, // no fixed width | 465 0, // no fixed width |
441 kIconSize); | 466 kIconSize); |
442 column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 467 column_set->AddPaddingColumn(0, horizontal_margin); |
443 | 468 |
444 layout->StartRow(0, column_set_id); | 469 layout->StartRow(0, column_set_id); |
445 views::Label* title = | 470 views::Label* title = |
446 new views::Label(prompt_->GetDialogTitle(), | 471 new views::Label(prompt_->GetDialogTitle(), |
447 ui::ResourceBundle::GetSharedInstance().GetFontList( | 472 ui::ResourceBundle::GetSharedInstance().GetFontList( |
448 ui::ResourceBundle::MediumFont)); | 473 ui::ResourceBundle::MediumFont)); |
449 title->SetMultiLine(true); | 474 title->SetMultiLine(true); |
450 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 475 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
451 title->SizeToFit(left_column_width); | 476 title->SizeToFit(left_column_width); |
452 | 477 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 } | 600 } |
576 | 601 |
577 // ExpandableContainerView::DetailsView ---------------------------------------- | 602 // ExpandableContainerView::DetailsView ---------------------------------------- |
578 | 603 |
579 ExpandableContainerView::DetailsView::DetailsView(int horizontal_space, | 604 ExpandableContainerView::DetailsView::DetailsView(int horizontal_space, |
580 bool parent_bulleted) | 605 bool parent_bulleted) |
581 : layout_(new views::GridLayout(this)), | 606 : layout_(new views::GridLayout(this)), |
582 state_(0) { | 607 state_(0) { |
583 SetLayoutManager(layout_); | 608 SetLayoutManager(layout_); |
584 views::ColumnSet* column_set = layout_->AddColumnSet(0); | 609 views::ColumnSet* column_set = layout_->AddColumnSet(0); |
585 // If the parent is using bullets for its items, then a padding of one unit | 610 column_set->AddPaddingColumn(0, |
586 // will make the child item (which has no bullet) look like a sibling of its | 611 GetLeftPaddingForBulletedItems(parent_bulleted)); |
Peter Kasting
2017/03/23 04:21:33
Nit: Pull the left padding out into a temp instead
Patti Lor
2017/03/24 06:37:12
Done.
| |
587 // parent. Therefore increase the indentation by one more unit to show that it | 612 column_set->AddColumn( |
588 // is in fact a child item (with no missing bullet) and not a sibling. | 613 views::GridLayout::LEADING, views::GridLayout::LEADING, 0, |
589 int padding = | 614 views::GridLayout::FIXED, |
590 views::kRelatedControlHorizontalSpacing * (parent_bulleted ? 2 : 1); | 615 horizontal_space - GetLeftPaddingForBulletedItems(parent_bulleted), 0); |
591 column_set->AddPaddingColumn(0, padding); | |
592 column_set->AddColumn(views::GridLayout::LEADING, | |
593 views::GridLayout::LEADING, | |
594 0, | |
595 views::GridLayout::FIXED, | |
596 horizontal_space - padding, | |
597 0); | |
598 } | 616 } |
599 | 617 |
600 void ExpandableContainerView::DetailsView::AddDetail( | 618 void ExpandableContainerView::DetailsView::AddDetail( |
601 const base::string16& detail) { | 619 const base::string16& detail) { |
602 layout_->StartRowWithPadding(0, 0, | 620 layout_->StartRowWithPadding(0, 0, 0, kPaddingAboveDetailsLink); |
Peter Kasting
2017/03/23 04:21:34
Why add this as a custom value for this file inste
Patti Lor
2017/03/24 06:37:12
Oh - I'd assumed that we were removing stuff from
| |
603 0, views::kRelatedControlSmallVerticalSpacing); | |
604 views::Label* detail_label = | 621 views::Label* detail_label = |
605 new views::Label(PrepareForDisplay(detail, false)); | 622 new views::Label(PrepareForDisplay(detail, false)); |
606 detail_label->SetMultiLine(true); | 623 detail_label->SetMultiLine(true); |
607 detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 624 detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
608 layout_->AddView(detail_label); | 625 layout_->AddView(detail_label); |
609 } | 626 } |
610 | 627 |
611 gfx::Size ExpandableContainerView::DetailsView::GetPreferredSize() const { | 628 gfx::Size ExpandableContainerView::DetailsView::GetPreferredSize() const { |
612 gfx::Size size = views::View::GetPreferredSize(); | 629 gfx::Size size = views::View::GetPreferredSize(); |
613 return gfx::Size(size.width(), size.height() * state_); | 630 return gfx::Size(size.width(), size.height() * state_); |
(...skipping 28 matching lines...) Expand all Loading... | |
642 | 659 |
643 details_view_ = new DetailsView(horizontal_space, parent_bulleted); | 660 details_view_ = new DetailsView(horizontal_space, parent_bulleted); |
644 | 661 |
645 layout->StartRow(0, column_set_id); | 662 layout->StartRow(0, column_set_id); |
646 layout->AddView(details_view_); | 663 layout->AddView(details_view_); |
647 | 664 |
648 for (size_t i = 0; i < details.size(); ++i) | 665 for (size_t i = 0; i < details.size(); ++i) |
649 details_view_->AddDetail(details[i]); | 666 details_view_->AddDetail(details[i]); |
650 | 667 |
651 // Make sure the link width column is as wide as needed for both Show and | 668 // Make sure the link width column is as wide as needed for both Show and |
652 // Hide details, so that the arrow doesn't shift horizontally when we | 669 // Hide details, so that the arrow doesn't shift horizontally when we toggle. |
653 // toggle. | |
654 views::Link* link = new views::Link( | 670 views::Link* link = new views::Link( |
655 l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS)); | 671 l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS)); |
656 int link_col_width = link->GetPreferredSize().width(); | 672 int link_col_width = link->GetPreferredSize().width(); |
657 link->SetText(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); | 673 link->SetText(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); |
658 link_col_width = std::max(link_col_width, link->GetPreferredSize().width()); | 674 link_col_width = std::max(link_col_width, link->GetPreferredSize().width()); |
659 | 675 |
660 column_set = layout->AddColumnSet(++column_set_id); | 676 column_set = layout->AddColumnSet(++column_set_id); |
661 // Padding to the left of the More Details column. If the parent is using | 677 // Padding to the left of the More Details column. |
662 // bullets for its items, then a padding of one unit will make the child | 678 column_set->AddPaddingColumn(0, |
663 // item (which has no bullet) look like a sibling of its parent. Therefore | 679 GetLeftPaddingForBulletedItems(parent_bulleted)); |
664 // increase the indentation by one more unit to show that it is in fact a | |
665 // child item (with no missing bullet) and not a sibling. | |
666 column_set->AddPaddingColumn( | |
667 0, views::kRelatedControlHorizontalSpacing * (parent_bulleted ? 2 : 1)); | |
668 // The More Details column. | 680 // The More Details column. |
669 column_set->AddColumn(views::GridLayout::LEADING, | 681 column_set->AddColumn(views::GridLayout::LEADING, |
670 views::GridLayout::LEADING, | 682 views::GridLayout::LEADING, |
671 0, | 683 0, |
672 views::GridLayout::FIXED, | 684 views::GridLayout::FIXED, |
673 link_col_width, | 685 link_col_width, |
674 link_col_width); | 686 link_col_width); |
675 // The Up/Down arrow column. | 687 // The Up/Down arrow column. |
676 column_set->AddColumn(views::GridLayout::LEADING, | 688 column_set->AddColumn(views::GridLayout::LEADING, |
677 views::GridLayout::TRAILING, | 689 views::GridLayout::TRAILING, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 gfx::ImageSkia icon = gfx::CreateVectorIcon( | 752 gfx::ImageSkia icon = gfx::CreateVectorIcon( |
741 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); | 753 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); |
742 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); | 754 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); |
743 } | 755 } |
744 | 756 |
745 // static | 757 // static |
746 ExtensionInstallPrompt::ShowDialogCallback | 758 ExtensionInstallPrompt::ShowDialogCallback |
747 ExtensionInstallPrompt::GetViewsShowDialogCallback() { | 759 ExtensionInstallPrompt::GetViewsShowDialogCallback() { |
748 return base::Bind(&ShowExtensionInstallDialogImpl); | 760 return base::Bind(&ShowExtensionInstallDialogImpl); |
749 } | 761 } |
OLD | NEW |