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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_view.cc

Issue 6574011: Cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/infobars/infobar_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_view.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/views/infobars/infobar_background.h" 9 #include "chrome/browser/ui/views/infobars/infobar_background.h"
10 #include "chrome/browser/ui/views/infobars/infobar_button_border.h"
10 #include "chrome/browser/ui/views/infobars/infobar_container.h" 11 #include "chrome/browser/ui/views/infobars/infobar_container.h"
11 #include "chrome/browser/tab_contents/infobar_delegate.h" 12 #include "chrome/browser/tab_contents/infobar_delegate.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "grit/theme_resources.h" 14 #include "grit/theme_resources.h"
14 #include "third_party/skia/include/effects/SkGradientShader.h" 15 #include "third_party/skia/include/effects/SkGradientShader.h"
15 #include "ui/base/animation/slide_animation.h" 16 #include "ui/base/animation/slide_animation.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/canvas_skia_paint.h" 19 #include "ui/gfx/canvas_skia_paint.h"
19 #include "views/controls/button/image_button.h" 20 #include "views/controls/button/image_button.h"
21 #include "views/controls/button/menu_button.h"
22 #include "views/controls/button/text_button.h"
20 #include "views/controls/image_view.h" 23 #include "views/controls/image_view.h"
21 #include "views/controls/label.h" 24 #include "views/controls/label.h"
25 #include "views/controls/link.h"
22 #include "views/focus/external_focus_tracker.h" 26 #include "views/focus/external_focus_tracker.h"
23 #include "views/widget/widget.h" 27 #include "views/widget/widget.h"
24 28
25 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 #include <shellapi.h>
sky 2011/02/23 22:55:32 Shouldn't this include be at line 7?
Peter Kasting 2011/02/23 23:06:46 Elliot and I both think here is better.
31
32 #include "base/win/win_util.h"
33 #include "base/win/windows_version.h"
34 #include "ui/gfx/icon_util.h"
26 #include "ui/base/win/hwnd_util.h" 35 #include "ui/base/win/hwnd_util.h"
27 #endif 36 #endif
28 37
29 // static 38 // static
30 const int InfoBarView::kDefaultTargetHeight = 36; 39 const int InfoBarView::kDefaultTargetHeight = 36;
31 const int InfoBarView::kHorizontalPadding = 6; 40 const int InfoBarView::kHorizontalPadding = 6;
32 const int InfoBarView::kIconLabelSpacing = 6; 41 const int InfoBarView::kIconLabelSpacing = 6;
33 const int InfoBarView::kButtonButtonSpacing = 10; 42 const int InfoBarView::kButtonButtonSpacing = 10;
34 const int InfoBarView::kEndOfLabelSpacing = 16; 43 const int InfoBarView::kEndOfLabelSpacing = 16;
35 44
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 paint.setShader(NULL); 160 paint.setShader(NULL);
152 paint.setColor(SkColorSetA(ResourceBundle::toolbar_separator_color, 161 paint.setColor(SkColorSetA(ResourceBundle::toolbar_separator_color,
153 SkColorGetA(gradient_colors[0]))); 162 SkColorGetA(gradient_colors[0])));
154 paint.setStyle(SkPaint::kStroke_Style); 163 paint.setStyle(SkPaint::kStroke_Style);
155 canvas_skia->drawPath(border_path, paint); 164 canvas_skia->drawPath(border_path, paint);
156 } 165 }
157 166
158 InfoBarView::~InfoBarView() { 167 InfoBarView::~InfoBarView() {
159 } 168 }
160 169
170 // static
171 views::Label* InfoBarView::CreateLabel(const string16& text) {
172 views::Label* label = new views::Label(UTF16ToWideHack(text),
173 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont));
174 label->SetColor(SK_ColorBLACK);
175 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
176 return label;
177 }
178
179 // static
180 views::Link* InfoBarView::CreateLink(const string16& text,
181 views::LinkController* controller,
182 const SkColor& background_color) {
183 views::Link* link = new views::Link;
184 link->SetText(UTF16ToWideHack(text));
185 link->SetFont(
186 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont));
187 link->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
188 link->SetController(controller);
189 link->MakeReadableOverBackgroundColor(background_color);
190 return link;
191 }
192
193 // static
194 views::MenuButton* InfoBarView::CreateMenuButton(
195 const string16& text,
196 bool normal_has_border,
197 views::ViewMenuDelegate* menu_delegate) {
198 views::MenuButton* menu_button =
199 new views::MenuButton(NULL, UTF16ToWideHack(text), menu_delegate, true);
200 menu_button->set_border(new InfoBarButtonBorder);
201 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
202 menu_button->set_menu_marker(
203 rb.GetBitmapNamed(IDR_INFOBARBUTTON_MENU_DROPARROW));
204 if (normal_has_border) {
205 menu_button->SetNormalHasBorder(true);
206 menu_button->SetAnimationDuration(0);
207 }
208 menu_button->SetEnabledColor(SK_ColorBLACK);
209 menu_button->SetHighlightColor(SK_ColorBLACK);
210 menu_button->SetHoverColor(SK_ColorBLACK);
211 menu_button->SetFont(rb.GetFont(ResourceBundle::MediumFont));
212 return menu_button;
213 }
214
215 // static
216 views::TextButton* InfoBarView::CreateTextButton(
217 views::ButtonListener* listener,
218 const string16& text,
219 bool needs_elevation) {
220 views::TextButton* text_button =
221 new views::TextButton(listener, UTF16ToWideHack(text));
222 text_button->set_border(new InfoBarButtonBorder);
223 text_button->SetNormalHasBorder(true);
224 text_button->SetAnimationDuration(0);
225 text_button->SetEnabledColor(SK_ColorBLACK);
226 text_button->SetHighlightColor(SK_ColorBLACK);
227 text_button->SetHoverColor(SK_ColorBLACK);
228 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
229 text_button->SetFont(rb.GetFont(ResourceBundle::MediumFont));
230 #if defined(OS_WIN)
231 if (needs_elevation &&
232 (base::win::GetVersion() >= base::win::VERSION_VISTA) &&
233 base::win::UserAccountControlIsEnabled()) {
234 SHSTOCKICONINFO icon_info = { sizeof SHSTOCKICONINFO };
235 SHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, &icon_info);
236 text_button->SetIcon(*IconUtil::CreateSkBitmapFromHICON(icon_info.hIcon,
237 gfx::Size(GetSystemMetrics(SM_CXSMICON),
238 GetSystemMetrics(SM_CYSMICON))));
239 }
240 #endif
241 return text_button;
242 }
243
161 void InfoBarView::Layout() { 244 void InfoBarView::Layout() {
162 gfx::Size button_size = close_button_->GetPreferredSize(); 245 gfx::Size button_size = close_button_->GetPreferredSize();
163 close_button_->SetBounds(width() - kHorizontalPadding - button_size.width(), 246 close_button_->SetBounds(width() - kHorizontalPadding - button_size.width(),
164 OffsetY(this, button_size), button_size.width(), 247 OffsetY(this, button_size), button_size.width(),
165 button_size.height()); 248 button_size.height());
166 } 249 }
167 250
168 void InfoBarView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { 251 void InfoBarView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
169 View::ViewHierarchyChanged(is_add, parent, child); 252 View::ViewHierarchyChanged(is_add, parent, child);
170 253
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (restore_focus) 355 if (restore_focus)
273 focus_tracker_->FocusLastFocusedExternalView(); 356 focus_tracker_->FocusLastFocusedExternalView();
274 focus_tracker_->SetFocusManager(NULL); 357 focus_tracker_->SetFocusManager(NULL);
275 focus_tracker_.reset(); 358 focus_tracker_.reset();
276 } 359 }
277 } 360 }
278 361
279 void InfoBarView::DeleteSelf() { 362 void InfoBarView::DeleteSelf() {
280 delete this; 363 delete this;
281 } 364 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.h ('k') | chrome/browser/ui/views/infobars/link_infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698