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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_install_dialog_view.h

Issue 363523002: Fix extension scrollbar regression bug, and add a regression test to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fixes to clean up code Created 6 years, 5 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALL_DIALOG_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALL_DIALOG_VIEW_H_
7
8 #include "base/basictypes.h"
9 #include "base/command_line.h"
10 #include "base/compiler_specific.h"
11 #include "base/i18n/rtl.h"
12 #include "base/metrics/histogram.h"
13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/extensions/bundle_installer.h"
16 #include "chrome/browser/extensions/extension_install_prompt.h"
17 #include "chrome/browser/extensions/extension_install_prompt_experiment.h"
18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/views/constrained_window_views.h"
20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/extensions/extension_constants.h"
22 #include "chrome/installer/util/browser_distribution.h"
23 #include "content/public/browser/page_navigator.h"
24 #include "content/public/browser/web_contents.h"
25 #include "extensions/common/extension.h"
26 #include "grit/chromium_strings.h"
27 #include "grit/generated_resources.h"
28 #include "grit/google_chrome_strings.h"
29 #include "grit/theme_resources.h"
30 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/gfx/animation/animation_delegate.h"
33 #include "ui/gfx/animation/slide_animation.h"
34 #include "ui/gfx/text_utils.h"
35 #include "ui/gfx/transform.h"
36 #include "ui/views/background.h"
37 #include "ui/views/border.h"
38 #include "ui/views/controls/button/checkbox.h"
39 #include "ui/views/controls/button/image_button.h"
40 #include "ui/views/controls/button/label_button.h"
41 #include "ui/views/controls/image_view.h"
42 #include "ui/views/controls/label.h"
43 #include "ui/views/controls/link.h"
44 #include "ui/views/controls/link_listener.h"
45 #include "ui/views/controls/scroll_view.h"
46 #include "ui/views/controls/separator.h"
47 #include "ui/views/layout/box_layout.h"
48 #include "ui/views/layout/grid_layout.h"
49 #include "ui/views/layout/layout_constants.h"
50 #include "ui/views/view.h"
51 #include "ui/views/widget/widget.h"
52 #include "ui/views/window/dialog_client_view.h"
53 #include "ui/views/window/dialog_delegate.h"
Finnur 2014/07/16 10:36:12 Are you sure you need all these includes in the he
Chris Thompson 2014/07/16 20:13:28 Forward declared as much as I could, and then thre
54
55 typedef std::vector<base::string16> PermissionDetails;
56 class ExpandableContainerView;
57
58 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data);
Finnur 2014/07/16 10:36:12 Does this need to be in the .h file? I only see a
Chris Thompson 2014/07/16 20:13:28 Missed this one. Removed.
59
60 // Creates a string for displaying |message| to the user. If it has to look
61 // like a entry in a bullet point list, one is added.
62 base::string16 PrepareForDisplay(const base::string16& message,
Finnur 2014/07/16 10:36:12 Same here.
Chris Thompson 2014/07/16 20:13:28 Missed this one. Removed.
63 bool bullet_point);
64
65 //} // namespace
Finnur 2014/07/16 10:36:12 Remove?
Chris Thompson 2014/07/16 20:13:29 Missed this one. Removed.
66
67 // A custom scrollable view implementation for the dialog.
68 class CustomScrollableView : public views::View {
69 public:
70 CustomScrollableView();
71 virtual ~CustomScrollableView();
72
73 private:
74 virtual void Layout() OVERRIDE;
75
76 DISALLOW_COPY_AND_ASSIGN(CustomScrollableView);
77 };
78
79 // Implements the extension installation dialog for TOOLKIT_VIEWS.
80 class ExtensionInstallDialogView : public views::DialogDelegateView,
81 public views::LinkListener,
82 public views::ButtonListener {
83 public:
84 ExtensionInstallDialogView(
85 content::PageNavigator* navigator,
86 ExtensionInstallPrompt::Delegate* delegate,
87 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt);
88 virtual ~ExtensionInstallDialogView();
89
90 const views::ScrollView* scroll_view() const { return scroll_view_; }
Finnur 2014/07/16 10:36:12 nit: Document.
Chris Thompson 2014/07/16 20:13:28 Added a brief comment on what this does/is useful
91
92 // Called when one of the child elements has expanded/collapsed.
93 void ContentsChanged();
94
95 private:
96 // views::DialogDelegateView:
97 virtual int GetDialogButtons() const OVERRIDE;
98 virtual base::string16 GetDialogButtonLabel(
99 ui::DialogButton button) const OVERRIDE;
100 virtual int GetDefaultDialogButton() const OVERRIDE;
101 virtual bool Cancel() OVERRIDE;
102 virtual bool Accept() OVERRIDE;
103 virtual ui::ModalType GetModalType() const OVERRIDE;
104 virtual base::string16 GetWindowTitle() const OVERRIDE;
105 virtual void Layout() OVERRIDE;
106 virtual gfx::Size GetPreferredSize() const OVERRIDE;
107 virtual void ViewHierarchyChanged(
108 const ViewHierarchyChangedDetails& details) OVERRIDE;
109
110 // views::LinkListener:
111 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
112
113 // views::ButtonListener:
114 virtual void ButtonPressed(views::Button* sender,
115 const ui::Event& event) OVERRIDE;
116
117 // Experimental: Toggles inline permission explanations with an animation.
118 void ToggleInlineExplanations();
119
120 // Creates a layout consisting of dialog header, extension name and icon.
121 views::GridLayout* CreateLayout(
122 views::View* parent,
123 int left_column_width,
124 int column_set_id,
125 bool single_detail_row) const;
126
127 bool is_inline_install() const {
128 return prompt_->type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT;
129 }
130
131 bool is_bundle_install() const {
132 return prompt_->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT;
133 }
134
135 bool is_external_install() const {
136 return prompt_->type() == ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT;
137 }
138
139 // Updates the histogram that holds installation accepted/aborted data.
140 void UpdateInstallResultHistogram(bool accepted) const;
141
142 // Updates the histogram that holds data about whether "Show details" or
143 // "Show permissions" links were shown and/or clicked.
144 void UpdateLinkActionHistogram(int action_type) const;
145
146 content::PageNavigator* navigator_;
147 ExtensionInstallPrompt::Delegate* delegate_;
148 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt_;
149
150 // The scroll view containing all the details for the dialog (including all
151 // collapsible/expandable sections).
152 views::ScrollView* scroll_view_;
153
154 // The container view for the scroll view.
155 CustomScrollableView* scrollable_;
156
157 // The container for the simpler view with only the dialog header and the
158 // extension icon. Used for the experiment where the permissions are
159 // initially hidden when the dialog shows.
160 CustomScrollableView* scrollable_header_only_;
161
162 // The preferred size of the dialog.
163 gfx::Size dialog_size_;
164
165 // Experimental: "Show details" link to expand inline explanations and reveal
166 // permision dialog.
167 views::Link* show_details_link_;
168
169 // Experimental: Label for showing information about the checkboxes.
170 views::Label* checkbox_info_label_;
171
172 // Experimental: Contains pointers to inline explanation views.
173 typedef std::vector<ExpandableContainerView*> InlineExplanations;
174 InlineExplanations inline_explanations_;
175
176 // Experimental: Number of unchecked checkboxes in the permission list.
177 // If this becomes zero, the accept button is enabled, otherwise disabled.
178 int unchecked_boxes_;
179
180 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView);
181 };
182
183 // A simple view that prepends a view with a bullet with the help of a grid
184 // layout.
185 class BulletedView : public views::View {
186 public:
187 explicit BulletedView(views::View* view);
188 private:
189 DISALLOW_COPY_AND_ASSIGN(BulletedView);
190 };
191
192 // A simple view that prepends a view with a checkbox with the help of a grid
193 // layout. Used for the permission experiment.
194 // TODO(meacer): Remove once the experiment is completed.
195 class CheckboxedView : public views::View {
196 public:
197 CheckboxedView(views::View* view, views::ButtonListener* listener);
198 private:
199 DISALLOW_COPY_AND_ASSIGN(CheckboxedView);
200 };
201
202 // A view to display text with an expandable details section.
203 class ExpandableContainerView : public views::View,
204 public views::ButtonListener,
205 public views::LinkListener,
206 public gfx::AnimationDelegate {
207 public:
208 ExpandableContainerView(ExtensionInstallDialogView* owner,
209 const base::string16& description,
210 const PermissionDetails& details,
211 int horizontal_space,
212 bool parent_bulleted,
213 bool show_expand_link,
214 bool lighter_color_details);
215 virtual ~ExpandableContainerView();
216
217 // views::View:
218 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE;
219
220 // views::ButtonListener:
221 virtual void ButtonPressed(views::Button* sender,
222 const ui::Event& event) OVERRIDE;
223
224 // views::LinkListener:
225 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
226
227 // gfx::AnimationDelegate:
228 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
229 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
230
231 // Expand/Collapse the detail section for this ExpandableContainerView.
232 void ToggleDetailLevel();
233
234 // Expand the detail section without any animation.
235 // TODO(meacer): Remove once the experiment is completed.
236 void ExpandWithoutAnimation();
237
238 private:
239 // A view which displays all the details of an IssueAdviceInfoEntry.
240 class DetailsView : public views::View {
241 public:
242 explicit DetailsView(int horizontal_space, bool parent_bulleted,
243 bool lighter_color);
244 virtual ~DetailsView() {}
245
246 // views::View:
247 virtual gfx::Size GetPreferredSize() const OVERRIDE;
248
249 void AddDetail(const base::string16& detail);
250
251 // Animates this to be a height proportional to |state|.
252 void AnimateToState(double state);
253
254 private:
255 views::GridLayout* layout_;
256 double state_;
257
258 // Whether the detail text should be shown with a lighter color.
259 bool lighter_color_;
260
261 DISALLOW_COPY_AND_ASSIGN(DetailsView);
262 };
263
264 // The dialog that owns |this|. It's also an ancestor in the View hierarchy.
265 ExtensionInstallDialogView* owner_;
266
267 // A view for showing |issue_advice.details|.
268 DetailsView* details_view_;
269
270 // The 'more details' link shown under the heading (changes to 'hide details'
271 // when the details section is expanded).
272 views::Link* more_details_;
273
274 gfx::SlideAnimation slide_animation_;
275
276 // The up/down arrow next to the 'more detail' link (points up/down depending
277 // on whether the details section is expanded).
278 views::ImageButton* arrow_toggle_;
279
280 // Whether the details section is expanded.
281 bool expanded_;
282
283 DISALLOW_COPY_AND_ASSIGN(ExpandableContainerView);
284 };
285
286 void ShowExtensionInstallDialogImpl(
287 const ExtensionInstallPrompt::ShowParams& show_params,
288 ExtensionInstallPrompt::Delegate* delegate,
289 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt);
290
291 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALL_DIALOG_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698