Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| index 38f05c54b5bf1bf7ef0c1174cecf847ed174fff9..852040f7df3be4a58280708944a520ac7a85a4c9 100644 |
| --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc |
| @@ -51,6 +51,7 @@ |
| #include "ui/views/layout/box_layout.h" |
| #include "ui/views/layout/grid_layout.h" |
| #include "ui/views/widget/widget.h" |
| +#include "ui/views/window/dialog_client_view.h" |
| using content::OpenURLParams; |
| using content::Referrer; |
| @@ -90,6 +91,9 @@ int GetLeftPaddingForBulletedItems(bool parent_bulleted) { |
| (parent_bulleted ? 2 : 1); |
| } |
| +// Time delay before the install button is enabled after initial display. |
| +int g_install_delay_in_ms = 500; |
| + |
| void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) { |
| views::View* parent = static_cast<views::View*>(data); |
| views::ImageView* image_view = new views::ImageView(); |
| @@ -595,6 +599,32 @@ views::View* ExtensionInstallDialogView::CreateExtraView() { |
| return store_link; |
| } |
| +bool ExtensionInstallDialogView::IsDialogButtonEnabled( |
| + ui::DialogButton button) const { |
| + if (button == ui::DIALOG_BUTTON_OK) |
| + return install_enabled_; |
| + return true; |
| +} |
| + |
| +void ExtensionInstallDialogView::SetInstallDelayForTesting(int delay_in_ms) { |
| + g_install_delay_in_ms = delay_in_ms; |
| +} |
| + |
| +void ExtensionInstallDialogView::VisibilityChanged(views::View* starting_from, |
| + bool is_visible) { |
| + if (is_visible) { |
|
Devlin
2017/03/31 22:21:41
We should make this:
if (is_visible && !install_en
Ackerman
2017/04/01 01:48:37
Done.
|
| + timer_.Start(FROM_HERE, |
| + base::TimeDelta::FromMilliseconds(g_install_delay_in_ms), |
| + base::Bind(&ExtensionInstallDialogView::EnableInstall, |
| + base::Unretained(this))); |
|
Devlin
2017/03/31 22:21:41
Each time I see this unretained, it makes me nervo
Ackerman
2017/04/01 01:48:37
Done.
|
| + } |
| +} |
| + |
| +void ExtensionInstallDialogView::EnableInstall() { |
| + install_enabled_ = true; |
| + GetDialogClientView()->UpdateDialogButtons(); |
| +} |
| + |
| void ExtensionInstallDialogView::UpdateInstallResultHistogram(bool accepted) |
| const { |
| if (prompt_->type() == ExtensionInstallPrompt::INSTALL_PROMPT) |