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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/extensions/bundle_installer.h" | 13 #include "chrome/browser/extensions/bundle_installer.h" |
14 #include "chrome/browser/extensions/extension_install_prompt.h" | 14 #include "chrome/browser/extensions/extension_install_prompt.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/views/constrained_window_views.h" | 16 #include "chrome/browser/ui/views/constrained_window_views.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/installer/util/browser_distribution.h" | 19 #include "chrome/installer/util/browser_distribution.h" |
20 #include "content/public/browser/page_navigator.h" | 20 #include "content/public/browser/page_navigator.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "grit/chromium_strings.h" | 22 #include "grit/chromium_strings.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "grit/google_chrome_strings.h" | 24 #include "grit/google_chrome_strings.h" |
25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
26 #include "ui/base/animation/animation_delegate.h" | |
27 #include "ui/base/animation/slide_animation.h" | |
28 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/animation/animation_delegate.h" |
| 29 #include "ui/gfx/animation/slide_animation.h" |
30 #include "ui/gfx/transform.h" | 30 #include "ui/gfx/transform.h" |
31 #include "ui/views/border.h" | 31 #include "ui/views/border.h" |
32 #include "ui/views/controls/button/image_button.h" | 32 #include "ui/views/controls/button/image_button.h" |
33 #include "ui/views/controls/image_view.h" | 33 #include "ui/views/controls/image_view.h" |
34 #include "ui/views/controls/label.h" | 34 #include "ui/views/controls/label.h" |
35 #include "ui/views/controls/link.h" | 35 #include "ui/views/controls/link.h" |
36 #include "ui/views/controls/link_listener.h" | 36 #include "ui/views/controls/link_listener.h" |
37 #include "ui/views/controls/scroll_view.h" | 37 #include "ui/views/controls/scroll_view.h" |
38 #include "ui/views/controls/separator.h" | 38 #include "ui/views/controls/separator.h" |
39 #include "ui/views/layout/box_layout.h" | 39 #include "ui/views/layout/box_layout.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 0); | 187 0); |
188 layout->StartRow(0, 0); | 188 layout->StartRow(0, 0); |
189 layout->AddView(new views::Label(PrepareForDisplay(string16(), true))); | 189 layout->AddView(new views::Label(PrepareForDisplay(string16(), true))); |
190 layout->AddView(view); | 190 layout->AddView(view); |
191 } | 191 } |
192 | 192 |
193 // A view to display text with an expandable details section. | 193 // A view to display text with an expandable details section. |
194 class ExpandableContainerView : public views::View, | 194 class ExpandableContainerView : public views::View, |
195 public views::ButtonListener, | 195 public views::ButtonListener, |
196 public views::LinkListener, | 196 public views::LinkListener, |
197 public ui::AnimationDelegate { | 197 public gfx::AnimationDelegate { |
198 public: | 198 public: |
199 ExpandableContainerView(ExtensionInstallDialogView* owner, | 199 ExpandableContainerView(ExtensionInstallDialogView* owner, |
200 const string16& description, | 200 const string16& description, |
201 const PermissionDetails& details, | 201 const PermissionDetails& details, |
202 int horizontal_space, | 202 int horizontal_space, |
203 bool parent_bulleted); | 203 bool parent_bulleted); |
204 virtual ~ExpandableContainerView(); | 204 virtual ~ExpandableContainerView(); |
205 | 205 |
206 // views::View: | 206 // views::View: |
207 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 207 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
208 | 208 |
209 // views::ButtonListener: | 209 // views::ButtonListener: |
210 virtual void ButtonPressed(views::Button* sender, | 210 virtual void ButtonPressed(views::Button* sender, |
211 const ui::Event& event) OVERRIDE; | 211 const ui::Event& event) OVERRIDE; |
212 | 212 |
213 // views::LinkListener: | 213 // views::LinkListener: |
214 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 214 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
215 | 215 |
216 // ui::AnimationDelegate: | 216 // gfx::AnimationDelegate: |
217 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 217 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
218 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 218 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
219 | 219 |
220 private: | 220 private: |
221 // A view which displays all the details of an IssueAdviceInfoEntry. | 221 // A view which displays all the details of an IssueAdviceInfoEntry. |
222 class DetailsView : public views::View { | 222 class DetailsView : public views::View { |
223 public: | 223 public: |
224 explicit DetailsView(int horizontal_space, bool parent_bulleted); | 224 explicit DetailsView(int horizontal_space, bool parent_bulleted); |
225 virtual ~DetailsView() {} | 225 virtual ~DetailsView() {} |
226 | 226 |
227 // views::View: | 227 // views::View: |
228 virtual gfx::Size GetPreferredSize() OVERRIDE; | 228 virtual gfx::Size GetPreferredSize() OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... |
248 | 248 |
249 // The dialog that owns |this|. It's also an ancestor in the View hierarchy. | 249 // The dialog that owns |this|. It's also an ancestor in the View hierarchy. |
250 ExtensionInstallDialogView* owner_; | 250 ExtensionInstallDialogView* owner_; |
251 | 251 |
252 // A view for showing |issue_advice.details|. | 252 // A view for showing |issue_advice.details|. |
253 DetailsView* details_view_; | 253 DetailsView* details_view_; |
254 | 254 |
255 // The '>' zippy control. | 255 // The '>' zippy control. |
256 views::ImageView* arrow_view_; | 256 views::ImageView* arrow_view_; |
257 | 257 |
258 ui::SlideAnimation slide_animation_; | 258 gfx::SlideAnimation slide_animation_; |
259 | 259 |
260 // The 'more details' link shown under the heading (changes to 'hide details' | 260 // The 'more details' link shown under the heading (changes to 'hide details' |
261 // when the details section is expanded). | 261 // when the details section is expanded). |
262 views::Link* more_details_; | 262 views::Link* more_details_; |
263 | 263 |
264 // The up/down arrow next to the 'more detail' link (points up/down depending | 264 // The up/down arrow next to the 'more detail' link (points up/down depending |
265 // on whether the details section is expanded). | 265 // on whether the details section is expanded). |
266 views::ImageButton* arrow_toggle_; | 266 views::ImageButton* arrow_toggle_; |
267 | 267 |
268 // Whether the details section is expanded. | 268 // Whether the details section is expanded. |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 views::Button* sender, const ui::Event& event) { | 848 views::Button* sender, const ui::Event& event) { |
849 ToggleDetailLevel(); | 849 ToggleDetailLevel(); |
850 } | 850 } |
851 | 851 |
852 void ExpandableContainerView::LinkClicked( | 852 void ExpandableContainerView::LinkClicked( |
853 views::Link* source, int event_flags) { | 853 views::Link* source, int event_flags) { |
854 ToggleDetailLevel(); | 854 ToggleDetailLevel(); |
855 } | 855 } |
856 | 856 |
857 void ExpandableContainerView::AnimationProgressed( | 857 void ExpandableContainerView::AnimationProgressed( |
858 const ui::Animation* animation) { | 858 const gfx::Animation* animation) { |
859 DCHECK_EQ(&slide_animation_, animation); | 859 DCHECK_EQ(&slide_animation_, animation); |
860 if (details_view_) | 860 if (details_view_) |
861 details_view_->AnimateToState(animation->GetCurrentValue()); | 861 details_view_->AnimateToState(animation->GetCurrentValue()); |
862 } | 862 } |
863 | 863 |
864 void ExpandableContainerView::AnimationEnded(const ui::Animation* animation) { | 864 void ExpandableContainerView::AnimationEnded(const gfx::Animation* animation) { |
865 if (animation->GetCurrentValue() != 0.0) { | 865 if (animation->GetCurrentValue() != 0.0) { |
866 arrow_toggle_->SetImage( | 866 arrow_toggle_->SetImage( |
867 views::Button::STATE_NORMAL, | 867 views::Button::STATE_NORMAL, |
868 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 868 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
869 IDR_UP_ARROW)); | 869 IDR_UP_ARROW)); |
870 } else { | 870 } else { |
871 arrow_toggle_->SetImage( | 871 arrow_toggle_->SetImage( |
872 views::Button::STATE_NORMAL, | 872 views::Button::STATE_NORMAL, |
873 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 873 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
874 IDR_DOWN_ARROW)); | 874 IDR_DOWN_ARROW)); |
875 } | 875 } |
876 | 876 |
877 more_details_->SetText(expanded_ ? | 877 more_details_->SetText(expanded_ ? |
878 l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS) : | 878 l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS) : |
879 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); | 879 l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); |
880 } | 880 } |
881 | 881 |
882 void ExpandableContainerView::ChildPreferredSizeChanged(views::View* child) { | 882 void ExpandableContainerView::ChildPreferredSizeChanged(views::View* child) { |
883 owner_->ContentsChanged(); | 883 owner_->ContentsChanged(); |
884 } | 884 } |
885 | 885 |
886 void ExpandableContainerView::ToggleDetailLevel() { | 886 void ExpandableContainerView::ToggleDetailLevel() { |
887 expanded_ = !expanded_; | 887 expanded_ = !expanded_; |
888 | 888 |
889 if (slide_animation_.IsShowing()) | 889 if (slide_animation_.IsShowing()) |
890 slide_animation_.Hide(); | 890 slide_animation_.Hide(); |
891 else | 891 else |
892 slide_animation_.Show(); | 892 slide_animation_.Show(); |
893 } | 893 } |
OLD | NEW |