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

Side by Side Diff: ash/launcher/tabbed_launcher_button.cc

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

Powered by Google App Engine
This is Rietveld 408576698