| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 layout->StartRow(0, column_set_id); | 466 layout->StartRow(0, column_set_id); |
| 467 views::Label* permission_label = new views::Label( | 467 views::Label* permission_label = new views::Label( |
| 468 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); | 468 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); |
| 469 permission_label->SetMultiLine(true); | 469 permission_label->SetMultiLine(true); |
| 470 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 470 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 471 permission_label->SizeToFit(left_column_width); | 471 permission_label->SizeToFit(left_column_width); |
| 472 layout->AddView(permission_label); | 472 layout->AddView(permission_label); |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 if (prompt->GetRetainedFileCount()) { | 476 int space_for_files_and_devices = left_column_width; |
| 477 // Slide in under the permissions, if there are any. If there are | 477 if (prompt->GetRetainedFileCount() || prompt->GetRetainedDeviceCount()) { |
| 478 // either, the retained files prompt stretches all the way to the | 478 // Slide in under the permissions, if there are any. If there are either, |
| 479 // right of the dialog. If there are no permissions, the retained | 479 // the retained files and devices prompts stretch all the way to the right |
| 480 // files prompt just takes up the left column. | 480 // of the dialog. If there are no permissions, the retained files and |
| 481 int space_for_files = left_column_width; | 481 // devices prompts just take up the left column. |
| 482 |
| 482 if (prompt->GetPermissionCount()) { | 483 if (prompt->GetPermissionCount()) { |
| 483 space_for_files += kIconSize; | 484 space_for_files_and_devices += kIconSize; |
| 484 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); | 485 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); |
| 485 column_set->AddColumn(views::GridLayout::FILL, | 486 column_set->AddColumn(views::GridLayout::FILL, |
| 486 views::GridLayout::FILL, | 487 views::GridLayout::FILL, |
| 487 1, | 488 1, |
| 488 views::GridLayout::USE_PREF, | 489 views::GridLayout::USE_PREF, |
| 489 0, // no fixed width | 490 0, // no fixed width |
| 490 space_for_files); | 491 space_for_files_and_devices); |
| 491 } | 492 } |
| 493 } |
| 492 | 494 |
| 495 if (prompt->GetRetainedFileCount()) { |
| 493 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 496 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 494 | 497 |
| 495 layout->StartRow(0, column_set_id); | 498 layout->StartRow(0, column_set_id); |
| 496 views::Label* retained_files_header = NULL; | 499 views::Label* retained_header = NULL; |
| 497 retained_files_header = new views::Label(prompt->GetRetainedFilesHeading()); | 500 retained_header = new views::Label(prompt->GetRetainedFilesHeading()); |
| 498 retained_files_header->SetMultiLine(true); | 501 retained_header->SetMultiLine(true); |
| 499 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 502 retained_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 500 retained_files_header->SizeToFit(space_for_files); | 503 retained_header->SizeToFit(space_for_files_and_devices); |
| 501 layout->AddView(retained_files_header); | 504 layout->AddView(retained_header); |
| 502 | 505 |
| 503 layout->StartRow(0, column_set_id); | 506 layout->StartRow(0, column_set_id); |
| 504 PermissionDetails details; | 507 PermissionDetails details; |
| 505 for (size_t i = 0; i < prompt->GetRetainedFileCount(); ++i) | 508 for (size_t i = 0; i < prompt->GetRetainedFileCount(); ++i) |
| 506 details.push_back(prompt->GetRetainedFile(i)); | 509 details.push_back(prompt->GetRetainedFile(i)); |
| 507 ExpandableContainerView* issue_advice_view = | 510 ExpandableContainerView* issue_advice_view = |
| 508 new ExpandableContainerView( | 511 new ExpandableContainerView(this, |
| 509 this, base::string16(), details, space_for_files, | 512 base::string16(), |
| 510 false, true, false); | 513 details, |
| 514 space_for_files_and_devices, |
| 515 false, |
| 516 true, |
| 517 false); |
| 511 layout->AddView(issue_advice_view); | 518 layout->AddView(issue_advice_view); |
| 512 } | 519 } |
| 513 | 520 |
| 521 if (prompt->GetRetainedDeviceCount()) { |
| 522 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 523 |
| 524 layout->StartRow(0, column_set_id); |
| 525 views::Label* retained_header = NULL; |
| 526 retained_header = new views::Label(prompt->GetRetainedDevicesHeading()); |
| 527 retained_header->SetMultiLine(true); |
| 528 retained_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 529 retained_header->SizeToFit(space_for_files_and_devices); |
| 530 layout->AddView(retained_header); |
| 531 |
| 532 layout->StartRow(0, column_set_id); |
| 533 PermissionDetails details; |
| 534 for (size_t i = 0; i < prompt->GetRetainedDeviceCount(); ++i) |
| 535 details.push_back(prompt->GetRetainedDeviceMessageString(i)); |
| 536 ExpandableContainerView* issue_advice_view = |
| 537 new ExpandableContainerView(this, |
| 538 base::string16(), |
| 539 details, |
| 540 space_for_files_and_devices, |
| 541 false, |
| 542 true, |
| 543 false); |
| 544 layout->AddView(issue_advice_view); |
| 545 } |
| 546 |
| 514 DCHECK(prompt->type() >= 0); | 547 DCHECK(prompt->type() >= 0); |
| 515 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", | 548 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", |
| 516 prompt->type(), | 549 prompt->type(), |
| 517 ExtensionInstallPrompt::NUM_PROMPT_TYPES); | 550 ExtensionInstallPrompt::NUM_PROMPT_TYPES); |
| 518 | 551 |
| 519 if (prompt->ShouldShowPermissions()) { | 552 if (prompt->ShouldShowPermissions()) { |
| 520 if (prompt->ShouldShowExplanationText()) { | 553 if (prompt->ShouldShowExplanationText()) { |
| 521 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); | 554 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); |
| 522 column_set->AddColumn(views::GridLayout::LEADING, | 555 column_set->AddColumn(views::GridLayout::LEADING, |
| 523 views::GridLayout::FILL, | 556 views::GridLayout::FILL, |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 void ExpandableContainerView::ExpandWithoutAnimation() { | 1111 void ExpandableContainerView::ExpandWithoutAnimation() { |
| 1079 expanded_ = true; | 1112 expanded_ = true; |
| 1080 details_view_->AnimateToState(1.0); | 1113 details_view_->AnimateToState(1.0); |
| 1081 } | 1114 } |
| 1082 | 1115 |
| 1083 // static | 1116 // static |
| 1084 ExtensionInstallPrompt::ShowDialogCallback | 1117 ExtensionInstallPrompt::ShowDialogCallback |
| 1085 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { | 1118 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { |
| 1086 return base::Bind(&ShowExtensionInstallDialogImpl); | 1119 return base::Bind(&ShowExtensionInstallDialogImpl); |
| 1087 } | 1120 } |
| OLD | NEW |