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 "ash/launcher/tabbed_launcher_button.h" | 5 #include "ash/launcher/tabbed_launcher_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher_button_host.h" | 9 #include "ash/launcher/launcher_button_host.h" |
| 10 #include "ash/launcher/launcher_types.h" |
10 #include "grit/ui_resources.h" | 11 #include "grit/ui_resources.h" |
11 #include "ui/base/accessibility/accessible_view_state.h" | 12 #include "ui/base/accessibility/accessible_view_state.h" |
12 #include "ui/base/animation/multi_animation.h" | 13 #include "ui/base/animation/multi_animation.h" |
13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
16 #include "ui/gfx/insets.h" | 17 #include "ui/gfx/insets.h" |
17 | 18 |
18 namespace ash { | 19 namespace ash { |
19 namespace internal { | 20 namespace internal { |
20 | 21 |
21 TabbedLauncherButton::IconView::IconView(TabbedLauncherButton* host) | 22 TabbedLauncherButton::IconView::IconView( |
| 23 TabbedLauncherButton* host, |
| 24 TabbedLauncherButton::IncognitoState is_incognito) |
22 : host_(host), | 25 : host_(host), |
23 show_image_(true) { | 26 show_image_(true) { |
24 if (!browser_image_) { | 27 if (!browser_image_) { |
25 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 28 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
26 | 29 |
27 browser_image_ = new SkBitmap( | 30 browser_image_ = new SkBitmap( |
28 *rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER).ToSkBitmap()); | 31 *rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER).ToSkBitmap()); |
| 32 incognito_browser_image_ = new SkBitmap( |
| 33 *rb.GetImageNamed(IDR_AURA_LAUNCHER_INCOGNITO_BROWSER).ToSkBitmap()); |
29 browser_panel_image_ = new SkBitmap( | 34 browser_panel_image_ = new SkBitmap( |
30 *rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER_PANEL).ToSkBitmap()); | 35 *rb.GetImageNamed(IDR_AURA_LAUNCHER_BROWSER_PANEL).ToSkBitmap()); |
| 36 incognito_browser_panel_image_ = new SkBitmap( |
| 37 *rb.GetImageNamed( |
| 38 IDR_AURA_LAUNCHER_INCOGNITO_BROWSER_PANEL).ToSkBitmap()); |
31 } | 39 } |
32 set_icon_size(0); | 40 set_icon_size(0); |
33 LauncherButton::IconView::SetImage(*browser_image_); | 41 if (is_incognito == STATE_NOT_INCOGNITO) |
| 42 LauncherButton::IconView::SetImage(*browser_image_); |
| 43 else |
| 44 LauncherButton::IconView::SetImage(*incognito_browser_image_); |
34 } | 45 } |
35 | 46 |
36 TabbedLauncherButton::IconView::~IconView() { | 47 TabbedLauncherButton::IconView::~IconView() { |
37 } | 48 } |
38 | 49 |
39 void TabbedLauncherButton::IconView::AnimationEnded( | 50 void TabbedLauncherButton::IconView::AnimationEnded( |
40 const ui::Animation* animation) { | 51 const ui::Animation* animation) { |
41 AnimationProgressed(animation); | 52 AnimationProgressed(animation); |
42 // Hide the image when the animation is done. We'll show it again the next | 53 // Hide the image when the animation is done. We'll show it again the next |
43 // time SetImages is invoked. | 54 // time SetImages is invoked. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int x = (width() - image_.width()) / 2; | 96 int x = (width() - image_.width()) / 2; |
86 int y = (height() - image_.height()) / 2; | 97 int y = (height() - image_.height()) / 2; |
87 canvas->DrawBitmapInt(image_, x, y); | 98 canvas->DrawBitmapInt(image_, x, y); |
88 | 99 |
89 if (save_layer) | 100 if (save_layer) |
90 canvas->Restore(); | 101 canvas->Restore(); |
91 } | 102 } |
92 | 103 |
93 // static | 104 // static |
94 SkBitmap* TabbedLauncherButton::IconView::browser_image_ = NULL; | 105 SkBitmap* TabbedLauncherButton::IconView::browser_image_ = NULL; |
| 106 SkBitmap* TabbedLauncherButton::IconView::incognito_browser_image_ = NULL; |
95 SkBitmap* TabbedLauncherButton::IconView::browser_panel_image_ = NULL; | 107 SkBitmap* TabbedLauncherButton::IconView::browser_panel_image_ = NULL; |
| 108 SkBitmap* TabbedLauncherButton::IconView::incognito_browser_panel_image_ = NULL; |
96 | 109 |
97 TabbedLauncherButton* TabbedLauncherButton::Create( | 110 TabbedLauncherButton* TabbedLauncherButton::Create( |
98 views::ButtonListener* listener, | 111 views::ButtonListener* listener, |
99 LauncherButtonHost* host) { | 112 LauncherButtonHost* host, |
100 TabbedLauncherButton* button = new TabbedLauncherButton(listener, host); | 113 IncognitoState is_incognito) { |
| 114 TabbedLauncherButton* button = |
| 115 new TabbedLauncherButton(listener, host, is_incognito); |
101 button->Init(); | 116 button->Init(); |
102 return button; | 117 return button; |
103 } | 118 } |
104 | 119 |
105 TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener, | 120 TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener, |
106 LauncherButtonHost* host) | 121 LauncherButtonHost* host, |
107 : LauncherButton(listener, host) { | 122 IncognitoState is_incognito) |
| 123 : LauncherButton(listener, host), |
| 124 is_incognito_(is_incognito) { |
108 set_accessibility_focusable(true); | 125 set_accessibility_focusable(true); |
109 } | 126 } |
110 | 127 |
111 TabbedLauncherButton::~TabbedLauncherButton() { | 128 TabbedLauncherButton::~TabbedLauncherButton() { |
112 } | 129 } |
113 | 130 |
114 void TabbedLauncherButton::PrepareForImageChange() { | 131 void TabbedLauncherButton::PrepareForImageChange() { |
115 tabbed_icon_view()->PrepareForImageChange(); | 132 tabbed_icon_view()->PrepareForImageChange(); |
116 } | 133 } |
117 | 134 |
118 void TabbedLauncherButton::SetTabImage(const SkBitmap& image) { | 135 void TabbedLauncherButton::SetTabImage(const SkBitmap& image) { |
119 tabbed_icon_view()->SetTabImage(image); | 136 tabbed_icon_view()->SetTabImage(image); |
120 } | 137 } |
121 | 138 |
122 void TabbedLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) { | 139 void TabbedLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) { |
123 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 140 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
124 state->name = host()->GetAccessibleName(this); | 141 state->name = host()->GetAccessibleName(this); |
125 } | 142 } |
126 | 143 |
127 LauncherButton::IconView* TabbedLauncherButton::CreateIconView() { | 144 LauncherButton::IconView* TabbedLauncherButton::CreateIconView() { |
128 return new IconView(this); | 145 return new IconView(this, is_incognito_); |
129 } | 146 } |
130 | 147 |
131 } // namespace internal | 148 } // namespace internal |
132 } // namespace ash | 149 } // namespace ash |
OLD | NEW |