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

Unified Diff: chrome/browser/ui/views/extensions/extension_install_dialog_view.cc

Issue 2716353003: [Extensions UI] Initially disabled OK button for extension install prompts. (Closed)
Patch Set: Addressing Devlin's comments. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..e36d5b66f5a7d315c54bc203cbd8168555966a25 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();
@@ -181,7 +185,8 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
prompt_(std::move(prompt)),
container_(NULL),
scroll_view_(NULL),
- handled_result_(false) {
+ handled_result_(false),
+ install_button_enabled_(false) {
InitView();
}
@@ -595,6 +600,35 @@ views::View* ExtensionInstallDialogView::CreateExtraView() {
return store_link;
}
+bool ExtensionInstallDialogView::IsDialogButtonEnabled(
+ ui::DialogButton button) const {
+ if (button == ui::DIALOG_BUTTON_OK)
+ return install_button_enabled_;
+ return true;
+}
+
+void ExtensionInstallDialogView::SetInstallButtonDelayForTesting(
+ 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 && !install_button_enabled_) {
+ // This base::Unretained is safe because the task is owned by the timer,
+ // which is in turn owned by this object.
+ timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(g_install_delay_in_ms),
+ base::Bind(&ExtensionInstallDialogView::EnableInstallButton,
+ base::Unretained(this)));
+ }
+}
+
+void ExtensionInstallDialogView::EnableInstallButton() {
+ install_button_enabled_ = true;
+ GetDialogClientView()->UpdateDialogButtons();
+}
+
void ExtensionInstallDialogView::UpdateInstallResultHistogram(bool accepted)
const {
if (prompt_->type() == ExtensionInstallPrompt::INSTALL_PROMPT)

Powered by Google App Engine
This is Rietveld 408576698