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 #ifndef ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | 5 #ifndef ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
6 #define ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | 6 #define ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/launcher/launcher_button.h" | 9 #include "ash/launcher/launcher_button.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/timer.h" | 11 #include "base/timer.h" |
12 #include "ui/base/animation/animation_delegate.h" | 12 #include "ui/base/animation/animation_delegate.h" |
13 #include "ui/views/controls/button/image_button.h" | 13 #include "ui/views/controls/button/image_button.h" |
14 #include "ui/views/controls/glow_hover_controller.h" | 14 #include "ui/views/controls/glow_hover_controller.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 class MultiAnimation; | 17 class MultiAnimation; |
18 } | 18 } |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 | |
22 class LauncherItem; | |
23 | |
24 namespace internal { | 21 namespace internal { |
25 | 22 |
26 // Button used for items on the launcher corresponding to tabbed windows. | 23 // Button used for items on the launcher corresponding to tabbed windows. |
27 class TabbedLauncherButton : public LauncherButton { | 24 class TabbedLauncherButton : public LauncherButton { |
28 public: | 25 public: |
29 // Indicates if this button is incognito or not. | |
30 enum IncognitoState { | |
31 STATE_INCOGNITO, | |
32 STATE_NOT_INCOGNITO, | |
33 }; | |
34 | |
35 static TabbedLauncherButton* Create(views::ButtonListener* listener, | 26 static TabbedLauncherButton* Create(views::ButtonListener* listener, |
36 LauncherButtonHost* host, | 27 LauncherButtonHost* host); |
37 IncognitoState is_incognito); | |
38 virtual ~TabbedLauncherButton(); | 28 virtual ~TabbedLauncherButton(); |
39 | 29 |
40 // Notification that the images are about to change. Kicks off an animation. | 30 // Notification that the images are about to change. Kicks off an animation. |
41 void PrepareForImageChange(); | 31 void PrepareForImageChange(); |
42 | 32 |
43 // Sets the images to display for this entry. | 33 // Sets the images to display for this entry. |
44 void SetTabImage(const SkBitmap& image); | 34 void SetTabImage(const SkBitmap& image); |
45 | 35 |
46 protected: | 36 protected: |
47 TabbedLauncherButton(views::ButtonListener* listener, | 37 TabbedLauncherButton(views::ButtonListener* listener, |
48 LauncherButtonHost* host, | 38 LauncherButtonHost* host); |
49 IncognitoState is_incognito); | |
50 // View override. | 39 // View override. |
51 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 40 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
52 | 41 |
53 // LauncherButton override. | 42 // LauncherButton override. |
54 virtual IconView* CreateIconView() OVERRIDE; | 43 virtual IconView* CreateIconView() OVERRIDE; |
55 | 44 |
56 private: | 45 private: |
57 // Used as the delegate for |animation_|. | 46 // Used as the delegate for |animation_|. |
58 class IconView : public LauncherButton::IconView, | 47 class IconView : public LauncherButton::IconView, |
59 public ui::AnimationDelegate { | 48 public ui::AnimationDelegate { |
60 public: | 49 public: |
61 IconView(TabbedLauncherButton* host, IncognitoState is_incognito); | 50 explicit IconView(TabbedLauncherButton* host); |
62 virtual ~IconView(); | 51 virtual ~IconView(); |
63 | 52 |
64 // ui::AnimationDelegateImpl overrides: | 53 // ui::AnimationDelegateImpl overrides: |
65 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 54 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
66 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 55 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
67 | 56 |
68 // Notification that the images are about to change. Kicks off an animation. | 57 // Notification that the images are about to change. Kicks off an animation. |
69 void PrepareForImageChange(); | 58 void PrepareForImageChange(); |
70 | 59 |
71 // Sets the image to display for this entry. | 60 // Sets the image to display for this entry. |
(...skipping 10 matching lines...) Expand all Loading... |
82 // Used to animate image. | 71 // Used to animate image. |
83 scoped_ptr<ui::MultiAnimation> animation_; | 72 scoped_ptr<ui::MultiAnimation> animation_; |
84 | 73 |
85 // Should |image_| be shown? This is set to false soon after | 74 // Should |image_| be shown? This is set to false soon after |
86 // PrepareForImageChange() is invoked without a following call to | 75 // PrepareForImageChange() is invoked without a following call to |
87 // SetImages(). | 76 // SetImages(). |
88 bool show_image_; | 77 bool show_image_; |
89 | 78 |
90 // Background images. Which one is chosen depends on the type of the window. | 79 // Background images. Which one is chosen depends on the type of the window. |
91 static SkBitmap* browser_image_; | 80 static SkBitmap* browser_image_; |
92 static SkBitmap* incognito_browser_image_; | |
93 // TODO[dave] implement panel specific image. | 81 // TODO[dave] implement panel specific image. |
94 static SkBitmap* browser_panel_image_; | 82 static SkBitmap* browser_panel_image_; |
95 static SkBitmap* incognito_browser_panel_image_; | |
96 | 83 |
97 DISALLOW_COPY_AND_ASSIGN(IconView); | 84 DISALLOW_COPY_AND_ASSIGN(IconView); |
98 }; | 85 }; |
99 | 86 |
100 IconView* tabbed_icon_view() { | 87 IconView* tabbed_icon_view() { |
101 return static_cast<IconView*>(icon_view()); | 88 return static_cast<IconView*>(icon_view()); |
102 } | 89 } |
103 | 90 |
104 // Indicates if the tabbed browser associated with this is an incognito | |
105 // window. | |
106 const IncognitoState is_incognito_; | |
107 | |
108 DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton); | 91 DISALLOW_COPY_AND_ASSIGN(TabbedLauncherButton); |
109 }; | 92 }; |
110 | 93 |
111 } // namespace internal | 94 } // namespace internal |
112 } // namespace ash | 95 } // namespace ash |
113 | 96 |
114 #endif // ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ | 97 #endif // ASH_LAUNCHER_TABBED_LAUNCHER_BUTTON_H_ |
OLD | NEW |