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

Side by Side 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: Removing cocoa changes, which will be done using a separate change. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "ui/views/border.h" 44 #include "ui/views/border.h"
45 #include "ui/views/controls/button/image_button.h" 45 #include "ui/views/controls/button/image_button.h"
46 #include "ui/views/controls/image_view.h" 46 #include "ui/views/controls/image_view.h"
47 #include "ui/views/controls/label.h" 47 #include "ui/views/controls/label.h"
48 #include "ui/views/controls/link.h" 48 #include "ui/views/controls/link.h"
49 #include "ui/views/controls/scroll_view.h" 49 #include "ui/views/controls/scroll_view.h"
50 #include "ui/views/controls/separator.h" 50 #include "ui/views/controls/separator.h"
51 #include "ui/views/layout/box_layout.h" 51 #include "ui/views/layout/box_layout.h"
52 #include "ui/views/layout/grid_layout.h" 52 #include "ui/views/layout/grid_layout.h"
53 #include "ui/views/widget/widget.h" 53 #include "ui/views/widget/widget.h"
54 #include "ui/views/window/dialog_client_view.h"
54 55
55 using content::OpenURLParams; 56 using content::OpenURLParams;
56 using content::Referrer; 57 using content::Referrer;
57 using extensions::ExperienceSamplingEvent; 58 using extensions::ExperienceSamplingEvent;
58 59
59 namespace { 60 namespace {
60 61
61 // Width of the bullet column in BulletedView. 62 // Width of the bullet column in BulletedView.
62 constexpr int kBulletWidth = 20; 63 constexpr int kBulletWidth = 20;
63 64
(...skipping 19 matching lines...) Expand all
83 // points. If the parent is using bullets for its items, then a padding of one 84 // points. If the parent is using bullets for its items, then a padding of one
84 // unit will make the child item (which has no bullet) look like a sibling of 85 // unit will make the child item (which has no bullet) look like a sibling of
85 // its parent. Therefore increase the indentation by one more unit to show that 86 // its parent. Therefore increase the indentation by one more unit to show that
86 // it is in fact a child item (with no missing bullet) and not a sibling. 87 // it is in fact a child item (with no missing bullet) and not a sibling.
87 int GetLeftPaddingForBulletedItems(bool parent_bulleted) { 88 int GetLeftPaddingForBulletedItems(bool parent_bulleted) {
88 return LayoutDelegate::Get()->GetMetric( 89 return LayoutDelegate::Get()->GetMetric(
89 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING) * 90 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING) *
90 (parent_bulleted ? 2 : 1); 91 (parent_bulleted ? 2 : 1);
91 } 92 }
92 93
94 // Time delay before the install button is enabled after initial display.
95 int g_install_delay_in_ms = 500;
96
93 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) { 97 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) {
94 views::View* parent = static_cast<views::View*>(data); 98 views::View* parent = static_cast<views::View*>(data);
95 views::ImageView* image_view = new views::ImageView(); 99 views::ImageView* image_view = new views::ImageView();
96 image_view->SetImage(*skia_image); 100 image_view->SetImage(*skia_image);
97 parent->AddChildView(image_view); 101 parent->AddChildView(image_view);
98 } 102 }
99 103
100 // Creates a string for displaying |message| to the user. If it has to look 104 // Creates a string for displaying |message| to the user. If it has to look
101 // like a entry in a bullet point list, one is added. 105 // like a entry in a bullet point list, one is added.
102 base::string16 PrepareForDisplay(const base::string16& message, 106 base::string16 PrepareForDisplay(const base::string16& message,
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 views::View* ExtensionInstallDialogView::CreateExtraView() { 592 views::View* ExtensionInstallDialogView::CreateExtraView() {
589 if (!prompt_->has_webstore_data()) 593 if (!prompt_->has_webstore_data())
590 return nullptr; 594 return nullptr;
591 595
592 views::Link* store_link = new views::Link( 596 views::Link* store_link = new views::Link(
593 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); 597 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK));
594 store_link->set_listener(this); 598 store_link->set_listener(this);
595 return store_link; 599 return store_link;
596 } 600 }
597 601
602 bool ExtensionInstallDialogView::IsDialogButtonEnabled(
603 ui::DialogButton button) const {
604 if (button == ui::DIALOG_BUTTON_OK)
605 return install_enabled_;
606 return true;
607 }
608
609 void ExtensionInstallDialogView::SetInstallDelayForTesting(int delay_in_ms) {
610 g_install_delay_in_ms = delay_in_ms;
611 }
612
613 void ExtensionInstallDialogView::VisibilityChanged(views::View* starting_from,
614 bool is_visible) {
615 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.
616 timer_.Start(FROM_HERE,
617 base::TimeDelta::FromMilliseconds(g_install_delay_in_ms),
618 base::Bind(&ExtensionInstallDialogView::EnableInstall,
619 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.
620 }
621 }
622
623 void ExtensionInstallDialogView::EnableInstall() {
624 install_enabled_ = true;
625 GetDialogClientView()->UpdateDialogButtons();
626 }
627
598 void ExtensionInstallDialogView::UpdateInstallResultHistogram(bool accepted) 628 void ExtensionInstallDialogView::UpdateInstallResultHistogram(bool accepted)
599 const { 629 const {
600 if (prompt_->type() == ExtensionInstallPrompt::INSTALL_PROMPT) 630 if (prompt_->type() == ExtensionInstallPrompt::INSTALL_PROMPT)
601 UMA_HISTOGRAM_BOOLEAN("Extensions.InstallPrompt.Accepted", accepted); 631 UMA_HISTOGRAM_BOOLEAN("Extensions.InstallPrompt.Accepted", accepted);
602 } 632 }
603 633
604 // ExpandableContainerView::DetailsView ---------------------------------------- 634 // ExpandableContainerView::DetailsView ----------------------------------------
605 635
606 ExpandableContainerView::DetailsView::DetailsView(int horizontal_space, 636 ExpandableContainerView::DetailsView::DetailsView(int horizontal_space,
607 bool parent_bulleted) 637 bool parent_bulleted)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 gfx::ImageSkia icon = gfx::CreateVectorIcon( 786 gfx::ImageSkia icon = gfx::CreateVectorIcon(
757 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey); 787 expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey);
758 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); 788 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon);
759 } 789 }
760 790
761 // static 791 // static
762 ExtensionInstallPrompt::ShowDialogCallback 792 ExtensionInstallPrompt::ShowDialogCallback
763 ExtensionInstallPrompt::GetViewsShowDialogCallback() { 793 ExtensionInstallPrompt::GetViewsShowDialogCallback() {
764 return base::Bind(&ShowExtensionInstallDialogImpl); 794 return base::Bind(&ShowExtensionInstallDialogImpl);
765 } 795 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698