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 const int kBulletWidth = 20; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 rating->AddChildView(rating_count); | 239 rating->AddChildView(rating_count); |
241 | 240 |
242 layout->StartRow(0, column_set_id); | 241 layout->StartRow(0, column_set_id); |
243 views::Label* user_count = | 242 views::Label* user_count = |
244 new views::Label(prompt_->GetUserCount(), small_font_list); | 243 new views::Label(prompt_->GetUserCount(), small_font_list); |
245 user_count->SetAutoColorReadabilityEnabled(false); | 244 user_count->SetAutoColorReadabilityEnabled(false); |
246 user_count->SetEnabledColor(SK_ColorGRAY); | 245 user_count->SetEnabledColor(SK_ColorGRAY); |
247 layout->AddView(user_count); | 246 layout->AddView(user_count); |
248 } | 247 } |
249 | 248 |
249 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); | |
250 const int related_control_vert_spacing = layout_delegate->GetMetric( | |
tapted
2017/03/20 03:41:52
maybe just `vertical_padding` ? (same in AddPermis
Patti Lor
2017/03/21 06:24:30
Done.
| |
251 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING); | |
250 if (prompt_->ShouldShowPermissions()) { | 252 if (prompt_->ShouldShowPermissions()) { |
251 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 253 layout->AddPaddingRow(0, related_control_vert_spacing); |
252 layout->StartRow(0, column_set_id); | 254 layout->StartRow(0, column_set_id); |
253 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, | 255 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, |
254 views::GridLayout::FILL); | 256 views::GridLayout::FILL); |
255 } | 257 } |
256 | 258 |
257 const int content_width = left_column_width + | 259 const int content_width = |
258 LayoutDelegate::Get()->GetMetric( | 260 left_column_width + |
259 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN) + | 261 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN) + |
260 kIconSize; | 262 kIconSize; |
261 | 263 |
262 // Create the scrollable view which will contain the permissions and retained | 264 // Create the scrollable view which will contain the permissions and retained |
263 // files/devices. It will span the full content width. | 265 // files/devices. It will span the full content width. |
264 CustomScrollableView* scrollable = new CustomScrollableView(); | 266 CustomScrollableView* scrollable = new CustomScrollableView(); |
265 views::GridLayout* scroll_layout = new views::GridLayout(scrollable); | 267 views::GridLayout* scroll_layout = new views::GridLayout(scrollable); |
266 scrollable->SetLayoutManager(scroll_layout); | 268 scrollable->SetLayoutManager(scroll_layout); |
267 | 269 |
268 views::ColumnSet* scrollable_column_set = | 270 views::ColumnSet* scrollable_column_set = |
269 scroll_layout->AddColumnSet(column_set_id); | 271 scroll_layout->AddColumnSet(column_set_id); |
270 | 272 |
271 scrollable_column_set->AddColumn( | 273 scrollable_column_set->AddColumn( |
272 views::GridLayout::LEADING, views::GridLayout::LEADING, | 274 views::GridLayout::LEADING, views::GridLayout::LEADING, |
273 0, // no resizing | 275 0, // no resizing |
274 views::GridLayout::USE_PREF, content_width, content_width); | 276 views::GridLayout::USE_PREF, content_width, content_width); |
275 | 277 |
276 // Pad to the very right of the dialog, so the scrollbar will be on the edge. | 278 // Pad to the very right of the dialog, so the scrollbar will be on the edge. |
277 scrollable_column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 279 const int button_margin = |
280 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN); | |
tapted
2017/03/20 03:41:52
Similar thing here... this should maybe be PANEL_C
Patti Lor
2017/03/21 06:24:30
Should we be keeping track of these somehow? e.g.
tapted
2017/03/22 03:05:59
Yeah.. I think we can eventually just remove DIALO
Patti Lor
2017/03/22 05:57:40
O, ok, that's easy then :)
| |
281 scrollable_column_set->AddPaddingColumn(0, button_margin); | |
278 | 282 |
279 layout->StartRow(0, column_set_id); | 283 layout->StartRow(0, column_set_id); |
280 scroll_view_ = new views::ScrollView(); | 284 scroll_view_ = new views::ScrollView(); |
281 scroll_view_->set_hide_horizontal_scrollbar(true); | 285 scroll_view_->set_hide_horizontal_scrollbar(true); |
282 scroll_view_->SetContents(scrollable); | 286 scroll_view_->SetContents(scrollable); |
283 layout->AddView(scroll_view_, 4, 1); | 287 layout->AddView(scroll_view_, 4, 1); |
284 | 288 |
285 if (prompt_->ShouldShowPermissions()) { | 289 if (prompt_->ShouldShowPermissions()) { |
286 bool has_permissions = | 290 bool has_permissions = |
287 prompt_->GetPermissionCount( | 291 prompt_->GetPermissionCount( |
288 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0; | 292 ExtensionInstallPrompt::PermissionsType::ALL_PERMISSIONS) > 0; |
289 if (has_permissions) { | 293 if (has_permissions) { |
290 AddPermissions( | 294 AddPermissions( |
291 scroll_layout, rb, column_set_id, content_width, | 295 scroll_layout, rb, column_set_id, content_width, |
292 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS); | 296 ExtensionInstallPrompt::PermissionsType::REGULAR_PERMISSIONS); |
293 AddPermissions( | 297 AddPermissions( |
294 scroll_layout, rb, column_set_id, content_width, | 298 scroll_layout, rb, column_set_id, content_width, |
295 ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS); | 299 ExtensionInstallPrompt::PermissionsType::WITHHELD_PERMISSIONS); |
296 } else { | 300 } else { |
297 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 301 scroll_layout->AddPaddingRow(0, related_control_vert_spacing); |
298 scroll_layout->StartRow(0, column_set_id); | 302 scroll_layout->StartRow(0, column_set_id); |
299 views::Label* permission_label = new views::Label( | 303 views::Label* permission_label = new views::Label( |
300 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); | 304 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); |
301 permission_label->SetMultiLine(true); | 305 permission_label->SetMultiLine(true); |
302 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 306 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
303 permission_label->SizeToFit(content_width); | 307 permission_label->SizeToFit(content_width); |
304 scroll_layout->AddView(permission_label); | 308 scroll_layout->AddView(permission_label); |
305 } | 309 } |
306 } | 310 } |
307 | 311 |
308 if (prompt_->GetRetainedFileCount()) { | 312 if (prompt_->GetRetainedFileCount()) { |
309 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 313 scroll_layout->AddPaddingRow(0, related_control_vert_spacing); |
310 | 314 |
311 scroll_layout->StartRow(0, column_set_id); | 315 scroll_layout->StartRow(0, column_set_id); |
312 views::Label* retained_files_header = | 316 views::Label* retained_files_header = |
313 new views::Label(prompt_->GetRetainedFilesHeading()); | 317 new views::Label(prompt_->GetRetainedFilesHeading()); |
314 retained_files_header->SetMultiLine(true); | 318 retained_files_header->SetMultiLine(true); |
315 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 319 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
316 retained_files_header->SizeToFit(content_width); | 320 retained_files_header->SizeToFit(content_width); |
317 scroll_layout->AddView(retained_files_header); | 321 scroll_layout->AddView(retained_files_header); |
318 | 322 |
319 scroll_layout->StartRow(0, column_set_id); | 323 scroll_layout->StartRow(0, column_set_id); |
320 PermissionDetails details; | 324 PermissionDetails details; |
321 for (size_t i = 0; i < prompt_->GetRetainedFileCount(); ++i) { | 325 for (size_t i = 0; i < prompt_->GetRetainedFileCount(); ++i) { |
322 details.push_back(prompt_->GetRetainedFile(i)); | 326 details.push_back(prompt_->GetRetainedFile(i)); |
323 } | 327 } |
324 ExpandableContainerView* issue_advice_view = | 328 ExpandableContainerView* issue_advice_view = |
325 new ExpandableContainerView(details, content_width, false); | 329 new ExpandableContainerView(details, content_width, false); |
326 scroll_layout->AddView(issue_advice_view); | 330 scroll_layout->AddView(issue_advice_view); |
327 } | 331 } |
328 | 332 |
329 if (prompt_->GetRetainedDeviceCount()) { | 333 if (prompt_->GetRetainedDeviceCount()) { |
330 scroll_layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 334 scroll_layout->AddPaddingRow(0, related_control_vert_spacing); |
331 | 335 |
332 scroll_layout->StartRow(0, column_set_id); | 336 scroll_layout->StartRow(0, column_set_id); |
333 views::Label* retained_devices_header = | 337 views::Label* retained_devices_header = |
334 new views::Label(prompt_->GetRetainedDevicesHeading()); | 338 new views::Label(prompt_->GetRetainedDevicesHeading()); |
335 retained_devices_header->SetMultiLine(true); | 339 retained_devices_header->SetMultiLine(true); |
336 retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 340 retained_devices_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
337 retained_devices_header->SizeToFit(content_width); | 341 retained_devices_header->SizeToFit(content_width); |
338 scroll_layout->AddView(retained_devices_header); | 342 scroll_layout->AddView(retained_devices_header); |
339 | 343 |
340 scroll_layout->StartRow(0, column_set_id); | 344 scroll_layout->StartRow(0, column_set_id); |
341 PermissionDetails details; | 345 PermissionDetails details; |
342 for (size_t i = 0; i < prompt_->GetRetainedDeviceCount(); ++i) { | 346 for (size_t i = 0; i < prompt_->GetRetainedDeviceCount(); ++i) { |
343 details.push_back(prompt_->GetRetainedDeviceMessageString(i)); | 347 details.push_back(prompt_->GetRetainedDeviceMessageString(i)); |
344 } | 348 } |
345 ExpandableContainerView* issue_advice_view = | 349 ExpandableContainerView* issue_advice_view = |
346 new ExpandableContainerView(details, content_width, false); | 350 new ExpandableContainerView(details, content_width, false); |
347 scroll_layout->AddView(issue_advice_view); | 351 scroll_layout->AddView(issue_advice_view); |
348 } | 352 } |
349 | 353 |
350 DCHECK_GE(prompt_->type(), 0); | 354 DCHECK_GE(prompt_->type(), 0); |
351 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", | 355 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", |
352 prompt_->type(), | 356 prompt_->type(), |
353 ExtensionInstallPrompt::NUM_PROMPT_TYPES); | 357 ExtensionInstallPrompt::NUM_PROMPT_TYPES); |
354 | 358 |
355 scroll_view_->ClipHeightTo( | 359 scroll_view_->ClipHeightTo( |
356 0, | 360 0, |
357 std::min(kScrollViewMaxHeight, scrollable->GetPreferredSize().height())); | 361 std::min(kScrollViewMaxHeight, scrollable->GetPreferredSize().height())); |
358 | 362 |
359 dialog_size_ = gfx::Size( | 363 dialog_size_ = gfx::Size(content_width + 2 * button_margin, |
360 content_width + 2 * views::kButtonHEdgeMarginNew, | 364 container_->GetPreferredSize().height()); |
361 container_->GetPreferredSize().height()); | |
362 | 365 |
363 std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog; | 366 std::string event_name = ExperienceSamplingEvent::kExtensionInstallDialog; |
364 event_name.append( | 367 event_name.append( |
365 ExtensionInstallPrompt::PromptTypeToString(prompt_->type())); | 368 ExtensionInstallPrompt::PromptTypeToString(prompt_->type())); |
366 sampling_event_ = ExperienceSamplingEvent::Create(event_name); | 369 sampling_event_ = ExperienceSamplingEvent::Create(event_name); |
367 } | 370 } |
368 | 371 |
369 bool ExtensionInstallDialogView::AddPermissions( | 372 bool ExtensionInstallDialogView::AddPermissions( |
370 views::GridLayout* layout, | 373 views::GridLayout* layout, |
371 ui::ResourceBundle& rb, | 374 ui::ResourceBundle& rb, |
372 int column_set_id, | 375 int column_set_id, |
373 int left_column_width, | 376 int left_column_width, |
374 ExtensionInstallPrompt::PermissionsType perm_type) { | 377 ExtensionInstallPrompt::PermissionsType perm_type) { |
375 if (prompt_->GetPermissionCount(perm_type) == 0) | 378 if (prompt_->GetPermissionCount(perm_type) == 0) |
376 return false; | 379 return false; |
377 | 380 |
378 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 381 const int related_control_vert_spacing = LayoutDelegate::Get()->GetMetric( |
382 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING); | |
383 layout->AddPaddingRow(0, related_control_vert_spacing); | |
379 | 384 |
380 layout->StartRow(0, column_set_id); | 385 layout->StartRow(0, column_set_id); |
381 views::Label* permissions_header = | 386 views::Label* permissions_header = |
382 new views::Label(prompt_->GetPermissionsHeading(perm_type)); | 387 new views::Label(prompt_->GetPermissionsHeading(perm_type)); |
383 permissions_header->SetMultiLine(true); | 388 permissions_header->SetMultiLine(true); |
384 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 389 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
385 permissions_header->SizeToFit(left_column_width); | 390 permissions_header->SizeToFit(left_column_width); |
386 layout->AddView(permissions_header); | 391 layout->AddView(permissions_header); |
387 | 392 |
388 for (size_t i = 0; i < prompt_->GetPermissionCount(perm_type); ++i) { | 393 for (size_t i = 0; i < prompt_->GetPermissionCount(perm_type); ++i) { |
389 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 394 layout->AddPaddingRow(0, related_control_vert_spacing); |
390 layout->StartRow(0, column_set_id); | 395 layout->StartRow(0, column_set_id); |
391 views::Label* permission_label = | 396 views::Label* permission_label = |
392 new views::Label(prompt_->GetPermission(i, perm_type)); | 397 new views::Label(prompt_->GetPermission(i, perm_type)); |
393 | 398 |
394 permission_label->SetMultiLine(true); | 399 permission_label->SetMultiLine(true); |
395 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 400 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
396 permission_label->SizeToFit(left_column_width - kBulletWidth); | 401 permission_label->SizeToFit(left_column_width - kBulletWidth); |
397 layout->AddView(new BulletedView(permission_label)); | 402 layout->AddView(new BulletedView(permission_label)); |
398 | 403 |
399 // If we have more details to provide, show them in collapsed form. | 404 // If we have more details to provide, show them in collapsed form. |
400 if (!prompt_->GetPermissionsDetails(i, perm_type).empty()) { | 405 if (!prompt_->GetPermissionsDetails(i, perm_type).empty()) { |
401 layout->StartRow(0, column_set_id); | 406 layout->StartRow(0, column_set_id); |
402 PermissionDetails details; | 407 PermissionDetails details; |
403 details.push_back(PrepareForDisplay( | 408 details.push_back(PrepareForDisplay( |
404 prompt_->GetPermissionsDetails(i, perm_type), false)); | 409 prompt_->GetPermissionsDetails(i, perm_type), false)); |
405 ExpandableContainerView* details_container = | 410 ExpandableContainerView* details_container = |
406 new ExpandableContainerView(details, left_column_width, true); | 411 new ExpandableContainerView(details, left_column_width, true); |
407 layout->AddView(details_container); | 412 layout->AddView(details_container); |
408 } | 413 } |
409 } | 414 } |
410 return true; | 415 return true; |
411 } | 416 } |
412 | 417 |
413 views::GridLayout* ExtensionInstallDialogView::CreateLayout( | 418 views::GridLayout* ExtensionInstallDialogView::CreateLayout( |
414 int left_column_width, | 419 int left_column_width, |
415 int column_set_id) { | 420 int column_set_id) { |
416 container_ = new views::View(); | 421 container_ = new views::View(); |
422 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); | |
423 const int button_margin = | |
tapted
2017/03/20 03:41:52
I think sensible names are button_margin->horizont
Patti Lor
2017/03/21 06:24:30
Done.
| |
424 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN); | |
425 const int content_margin = | |
426 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN); | |
417 // This is basically views::GridLayout::CreatePanel, but without a top or | 427 // This is basically views::GridLayout::CreatePanel, but without a top or |
418 // right margin (we effectively get a top margin anyway from the empty dialog | 428 // right margin (we effectively get a top margin anyway from the empty dialog |
419 // title, and we add an explicit padding column as a right margin below). | 429 // title, and we add an explicit padding column as a right margin below). |
420 views::GridLayout* layout = new views::GridLayout(container_); | 430 views::GridLayout* layout = new views::GridLayout(container_); |
421 layout->SetInsets(0, views::kButtonHEdgeMarginNew, | 431 layout->SetInsets(0, button_margin, content_margin, 0); |
422 LayoutDelegate::Get()->GetMetric( | |
423 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), | |
424 0); | |
425 container_->SetLayoutManager(layout); | 432 container_->SetLayoutManager(layout); |
426 AddChildView(container_); | 433 AddChildView(container_); |
427 | 434 |
428 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); | 435 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); |
429 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, | 436 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, |
430 0, // no resizing | 437 0, // no resizing |
431 views::GridLayout::USE_PREF, | 438 views::GridLayout::USE_PREF, |
432 0, // no fixed width | 439 0, // no fixed width |
433 left_column_width); | 440 left_column_width); |
434 column_set->AddPaddingColumn( | 441 column_set->AddPaddingColumn(0, content_margin); |
tapted
2017/03/20 03:41:52
PANEL_CONTENT_MARGIN probably doesn't belong in th
Patti Lor
2017/03/21 06:24:29
I think it's arbitrary - this is the only place in
tapted
2017/03/22 03:05:59
looks great!
| |
435 0, LayoutDelegate::Get()->GetMetric( | |
436 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); | |
437 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, | 442 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
438 0, // no resizing | 443 0, // no resizing |
439 views::GridLayout::USE_PREF, | 444 views::GridLayout::USE_PREF, |
440 0, // no fixed width | 445 0, // no fixed width |
441 kIconSize); | 446 kIconSize); |
442 column_set->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 447 column_set->AddPaddingColumn(0, button_margin); |
443 | 448 |
444 layout->StartRow(0, column_set_id); | 449 layout->StartRow(0, column_set_id); |
445 views::Label* title = | 450 views::Label* title = |
446 new views::Label(prompt_->GetDialogTitle(), | 451 new views::Label(prompt_->GetDialogTitle(), |
447 ui::ResourceBundle::GetSharedInstance().GetFontList( | 452 ui::ResourceBundle::GetSharedInstance().GetFontList( |
448 ui::ResourceBundle::MediumFont)); | 453 ui::ResourceBundle::MediumFont)); |
449 title->SetMultiLine(true); | 454 title->SetMultiLine(true); |
450 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 455 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
451 title->SizeToFit(left_column_width); | 456 title->SizeToFit(left_column_width); |
452 | 457 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 bool parent_bulleted) | 585 bool parent_bulleted) |
581 : layout_(new views::GridLayout(this)), | 586 : layout_(new views::GridLayout(this)), |
582 state_(0) { | 587 state_(0) { |
583 SetLayoutManager(layout_); | 588 SetLayoutManager(layout_); |
584 views::ColumnSet* column_set = layout_->AddColumnSet(0); | 589 views::ColumnSet* column_set = layout_->AddColumnSet(0); |
585 // If the parent is using bullets for its items, then a padding of one unit | 590 // If the parent is using bullets for its items, then a padding of one unit |
586 // will make the child item (which has no bullet) look like a sibling of its | 591 // will make the child item (which has no bullet) look like a sibling of its |
587 // parent. Therefore increase the indentation by one more unit to show that it | 592 // parent. Therefore increase the indentation by one more unit to show that it |
588 // is in fact a child item (with no missing bullet) and not a sibling. | 593 // is in fact a child item (with no missing bullet) and not a sibling. |
589 int padding = | 594 int padding = |
590 views::kRelatedControlHorizontalSpacing * (parent_bulleted ? 2 : 1); | 595 LayoutDelegate::Get()->GetMetric( |
596 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING) * | |
597 (parent_bulleted ? 2 : 1); | |
591 column_set->AddPaddingColumn(0, padding); | 598 column_set->AddPaddingColumn(0, padding); |
592 column_set->AddColumn(views::GridLayout::LEADING, | 599 column_set->AddColumn(views::GridLayout::LEADING, |
593 views::GridLayout::LEADING, | 600 views::GridLayout::LEADING, |
594 0, | 601 0, |
595 views::GridLayout::FIXED, | 602 views::GridLayout::FIXED, |
596 horizontal_space - padding, | 603 horizontal_space - padding, |
597 0); | 604 0); |
598 } | 605 } |
599 | 606 |
600 void ExpandableContainerView::DetailsView::AddDetail( | 607 void ExpandableContainerView::DetailsView::AddDetail( |
601 const base::string16& detail) { | 608 const base::string16& detail) { |
602 layout_->StartRowWithPadding(0, 0, | 609 layout_->StartRowWithPadding( |
603 0, views::kRelatedControlSmallVerticalSpacing); | 610 0, 0, 0, |
611 LayoutDelegate::Get()->GetMetric( | |
612 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); | |
tapted
2017/03/20 03:41:52
HORIZONTAL doesn't look right here
Patti Lor
2017/03/21 06:24:30
Oops, fixed!
tapted
2017/03/22 03:05:59
ping?
Patti Lor
2017/03/22 05:57:40
Eek, sorry. Thanks for catching it, it should be a
| |
604 views::Label* detail_label = | 613 views::Label* detail_label = |
605 new views::Label(PrepareForDisplay(detail, false)); | 614 new views::Label(PrepareForDisplay(detail, false)); |
606 detail_label->SetMultiLine(true); | 615 detail_label->SetMultiLine(true); |
607 detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 616 detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
608 layout_->AddView(detail_label); | 617 layout_->AddView(detail_label); |
609 } | 618 } |
610 | 619 |
611 gfx::Size ExpandableContainerView::DetailsView::GetPreferredSize() const { | 620 gfx::Size ExpandableContainerView::DetailsView::GetPreferredSize() const { |
612 gfx::Size size = views::View::GetPreferredSize(); | 621 gfx::Size size = views::View::GetPreferredSize(); |
613 return gfx::Size(size.width(), size.height() * state_); | 622 return gfx::Size(size.width(), size.height() * state_); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 link->SetText(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); | 666 link->SetText(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); |
658 link_col_width = std::max(link_col_width, link->GetPreferredSize().width()); | 667 link_col_width = std::max(link_col_width, link->GetPreferredSize().width()); |
659 | 668 |
660 column_set = layout->AddColumnSet(++column_set_id); | 669 column_set = layout->AddColumnSet(++column_set_id); |
661 // Padding to the left of the More Details column. If the parent is using | 670 // Padding to the left of the More Details column. If the parent is using |
662 // bullets for its items, then a padding of one unit will make the child | 671 // bullets for its items, then a padding of one unit will make the child |
663 // item (which has no bullet) look like a sibling of its parent. Therefore | 672 // item (which has no bullet) look like a sibling of its parent. Therefore |
664 // increase the indentation by one more unit to show that it is in fact a | 673 // 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. | 674 // child item (with no missing bullet) and not a sibling. |
666 column_set->AddPaddingColumn( | 675 column_set->AddPaddingColumn( |
667 0, views::kRelatedControlHorizontalSpacing * (parent_bulleted ? 2 : 1)); | 676 0, LayoutDelegate::Get()->GetMetric( |
677 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING) * | |
678 (parent_bulleted ? 2 : 1)); | |
tapted
2017/03/20 03:41:52
This should be pulled out (with its comment) to a
Patti Lor
2017/03/21 06:24:30
Done.
| |
668 // The More Details column. | 679 // The More Details column. |
669 column_set->AddColumn(views::GridLayout::LEADING, | 680 column_set->AddColumn(views::GridLayout::LEADING, |
670 views::GridLayout::LEADING, | 681 views::GridLayout::LEADING, |
671 0, | 682 0, |
672 views::GridLayout::FIXED, | 683 views::GridLayout::FIXED, |
673 link_col_width, | 684 link_col_width, |
674 link_col_width); | 685 link_col_width); |
675 // The Up/Down arrow column. | 686 // The Up/Down arrow column. |
676 column_set->AddColumn(views::GridLayout::LEADING, | 687 column_set->AddColumn(views::GridLayout::LEADING, |
677 views::GridLayout::TRAILING, | 688 views::GridLayout::TRAILING, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 gfx::ImageSkia icon = gfx::CreateVectorIcon( | 751 gfx::ImageSkia icon = gfx::CreateVectorIcon( |
741 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); | 752 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); |
742 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); | 753 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); |
743 } | 754 } |
744 | 755 |
745 // static | 756 // static |
746 ExtensionInstallPrompt::ShowDialogCallback | 757 ExtensionInstallPrompt::ShowDialogCallback |
747 ExtensionInstallPrompt::GetViewsShowDialogCallback() { | 758 ExtensionInstallPrompt::GetViewsShowDialogCallback() { |
748 return base::Bind(&ShowExtensionInstallDialogImpl); | 759 return base::Bind(&ShowExtensionInstallDialogImpl); |
749 } | 760 } |
OLD | NEW |