Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ADD_TO_APP_LAUNCHER_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ADD_TO_APP_LAUNCHER_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/common/content_settings_types.h" | |
| 10 #include "ui/gfx/animation/animation_delegate.h" | 9 #include "ui/gfx/animation/animation_delegate.h" |
| 11 #include "ui/gfx/animation/slide_animation.h" | 10 #include "ui/gfx/animation/slide_animation.h" |
| 12 #include "ui/views/painter.h" | 11 #include "ui/views/painter.h" |
| 13 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
| 14 #include "ui/views/widget/widget_observer.h" | |
| 15 | 13 |
| 16 class ContentSettingImageModel; | |
| 17 class LocationBarView; | 14 class LocationBarView; |
| 18 | 15 |
| 19 namespace content { | 16 namespace content { |
| 20 class WebContents; | 17 class WebContents; |
| 21 } | 18 } |
| 22 | 19 |
| 23 namespace gfx { | 20 namespace gfx { |
| 24 class FontList; | 21 class FontList; |
| 25 } | 22 } |
| 26 | 23 |
| 27 namespace views { | 24 namespace views { |
| 28 class ImageView; | 25 class ImageView; |
| 29 class Label; | 26 class Label; |
| 30 } | 27 } |
| 31 | 28 |
| 32 // The ContentSettingImageView displays an icon and optional text label for | 29 // The AddToAppLauncherView displays a UI to allow adding the current page to |
| 33 // various content settings affordances in the location bar (i.e. plugin | 30 // the App Launcher in the location bar. |
| 34 // blocking, geolocation). | 31 class AddToAppLauncherView : public gfx::AnimationDelegate, public views::View { |
| 35 class ContentSettingImageView : public gfx::AnimationDelegate, | |
| 36 public views::View, | |
| 37 public views::WidgetObserver { | |
| 38 public: | 32 public: |
| 39 ContentSettingImageView(ContentSettingsType content_type, | 33 AddToAppLauncherView(LocationBarView* parent, |
| 40 LocationBarView* parent, | 34 const gfx::FontList& font_list, |
| 41 const gfx::FontList& font_list, | 35 SkColor text_color, |
| 42 SkColor text_color, | 36 SkColor parent_background_color); |
| 43 SkColor parent_background_color); | 37 virtual ~AddToAppLauncherView(); |
| 44 virtual ~ContentSettingImageView(); | |
| 45 | 38 |
| 46 // Updates the decoration from the shown WebContents. | 39 // Updates the decoration from the shown WebContents. |
| 47 void Update(content::WebContents* web_contents); | 40 void Update(content::WebContents* web_contents); |
| 48 | 41 |
| 49 private: | 42 private: |
| 50 // Number of milliseconds spent animating open; also the time spent animating | 43 // Number of milliseconds spent animating open; also the time spent animating |
| 51 // closed. | 44 // closed. |
| 52 static const int kOpenTimeMS; | 45 static const int kOpenTimeMS; |
| 53 | 46 |
| 54 // The total animation time, including open and close as well as an | 47 // The total animation time, including open and close as well as an |
| 55 // intervening "stay open" period. | 48 // intervening "stay open" period. |
| 56 static const int kAnimationDurationMS; | 49 static const int kAnimationDurationMS; |
| 57 | 50 |
| 58 // Amount of padding at the edges of the bubble. If |by_icon| is true, this | 51 // Amount of padding at the edges of the bubble. If |by_icon| is true, this |
| 59 // is the padding next to the icon; otherwise it's the padding next to the | 52 // is the padding next to the icon; otherwise it's the padding next to the |
| 60 // label. (We increase padding next to the label by the amount of padding | 53 // label. (We increase padding next to the label by the amount of padding |
| 61 // "built in" to the icon in order to make the bubble appear to have | 54 // "built in" to the icon in order to make the bubble appear to have |
| 62 // symmetrical padding.) | 55 // symmetrical padding.) |
| 63 static int GetBubbleOuterPadding(bool by_icon); | 56 static int GetBubbleOuterPadding(bool by_icon); |
| 64 | 57 |
| 65 // gfx::AnimationDelegate: | 58 // gfx::AnimationDelegate: |
| 66 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 59 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 67 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 60 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 68 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; | 61 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE; |
| 69 | 62 |
| 70 // views::View: | 63 // views::View: |
| 71 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 64 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 72 virtual void Layout() OVERRIDE; | 65 virtual void Layout() OVERRIDE; |
| 73 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | |
| 74 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | |
| 75 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | |
| 76 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; | 66 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; |
| 77 | 67 |
| 78 // views::WidgetObserver: | |
| 79 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | |
| 80 | |
| 81 bool background_showing() const { | 68 bool background_showing() const { |
| 82 return slide_animator_.is_animating() || pause_animation_; | 69 return slide_animator_.is_animating() || pause_animation_; |
| 83 } | 70 } |
| 84 | 71 |
| 85 int GetTotalSpacingWhileAnimating() const; | 72 int GetTotalSpacingWhileAnimating() const; |
| 86 void OnClick(); | 73 void OnClick(); |
|
calamity
2014/06/11 02:05:23
This isn't defined.
benwells
2014/06/11 04:09:48
Done.
| |
| 87 | 74 |
| 88 LocationBarView* parent_; // Weak, owns us. | 75 LocationBarView* parent_; // Weak, owns us. |
| 89 scoped_ptr<ContentSettingImageModel> content_setting_image_model_; | |
| 90 scoped_ptr<views::Painter> background_painter_; | 76 scoped_ptr<views::Painter> background_painter_; |
| 91 views::ImageView* icon_; | 77 views::ImageView* icon_; |
| 92 views::Label* text_label_; | 78 views::Label* text_label_; |
| 93 gfx::SlideAnimation slide_animator_; | 79 gfx::SlideAnimation slide_animator_; |
| 94 bool pause_animation_; | 80 bool pause_animation_; |
| 95 double pause_animation_state_; | 81 double pause_animation_state_; |
|
calamity
2014/06/11 02:05:23
pause_animation_ and pause_animation_state_ are un
benwells
2014/06/11 04:09:48
Done.
| |
| 96 views::Widget* bubble_widget_; | |
| 97 | 82 |
| 98 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageView); | 83 DISALLOW_COPY_AND_ASSIGN(AddToAppLauncherView); |
| 99 }; | 84 }; |
| 100 | 85 |
| 101 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_ | 86 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ADD_TO_APP_LAUNCHER_VIEW_H_ |
| OLD | NEW |