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

Side by Side Diff: chrome/browser/ui/views/toolbar_view.cc

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added missing DropdownBarHostDelegate header file. Created 9 years, 7 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/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar_view.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/accessibility/browser_accessibility_state.h" 10 #include "chrome/browser/accessibility/browser_accessibility_state.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void ToolbarView::RemoveMenuListener(views::MenuListener* listener) { 264 void ToolbarView::RemoveMenuListener(views::MenuListener* listener) {
265 for (std::vector<views::MenuListener*>::iterator i(menu_listeners_.begin()); 265 for (std::vector<views::MenuListener*>::iterator i(menu_listeners_.begin());
266 i != menu_listeners_.end(); ++i) { 266 i != menu_listeners_.end(); ++i) {
267 if (*i == listener) { 267 if (*i == listener) {
268 menu_listeners_.erase(i); 268 menu_listeners_.erase(i);
269 return; 269 return;
270 } 270 }
271 } 271 }
272 } 272 }
273 273
274 SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) {
275 ui::ThemeProvider* tp = GetThemeProvider();
276
277 int id = 0;
278 switch (state) {
279 case views::CustomButton::BS_NORMAL: id = IDR_TOOLS; break;
280 case views::CustomButton::BS_HOT: id = IDR_TOOLS_H; break;
281 case views::CustomButton::BS_PUSHED: id = IDR_TOOLS_P; break;
282 default: NOTREACHED(); break;
283 }
284 SkBitmap icon = *tp->GetBitmapNamed(id);
285
286 #if defined(OS_WIN)
287 // Keep track of whether we were showing the badge before, so we don't send
288 // multiple UMA events for example when multiple Chrome windows are open.
289 static bool incompatibility_badge_showing = false;
290 // Save the old value before resetting it.
291 bool was_showing = incompatibility_badge_showing;
292 incompatibility_badge_showing = false;
293 #endif
294
295 bool add_badge = IsUpgradeRecommended() || ShouldShowIncompatibilityWarning();
296 if (!add_badge)
297 return icon;
298
299 // Draw the chrome app menu icon onto the canvas.
300 scoped_ptr<gfx::CanvasSkia> canvas(
301 new gfx::CanvasSkia(icon.width(), icon.height(), false));
302 canvas->DrawBitmapInt(icon, 0, 0);
303
304 SkBitmap badge;
305 // Only one badge can be active at any given time. The Upgrade notification
306 // is deemed most important, then the DLL conflict badge.
307 if (IsUpgradeRecommended()) {
308 badge = *tp->GetBitmapNamed(
309 UpgradeDetector::GetInstance()->GetIconResourceID(
310 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE));
311 } else if (ShouldShowIncompatibilityWarning()) {
312 #if defined(OS_WIN)
313 if (!was_showing)
314 UserMetrics::RecordAction(UserMetricsAction("ConflictBadge"));
315 badge = *tp->GetBitmapNamed(IDR_CONFLICT_BADGE);
316 incompatibility_badge_showing = true;
317 #else
318 NOTREACHED();
319 #endif
320 } else {
321 NOTREACHED();
322 }
323
324 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin);
325
326 return canvas->ExtractBitmap();
327 }
328
274 //////////////////////////////////////////////////////////////////////////////// 329 ////////////////////////////////////////////////////////////////////////////////
275 // ToolbarView, AccessiblePaneView overrides: 330 // ToolbarView, AccessiblePaneView overrides:
276 331
277 bool ToolbarView::SetPaneFocus( 332 bool ToolbarView::SetPaneFocus(
278 int view_storage_id, views::View* initial_focus) { 333 int view_storage_id, views::View* initial_focus) {
279 if (!AccessiblePaneView::SetPaneFocus(view_storage_id, initial_focus)) 334 if (!AccessiblePaneView::SetPaneFocus(view_storage_id, initial_focus))
280 return false; 335 return false;
281 336
282 location_bar_->SetShowFocusRect(true); 337 location_bar_->SetShowFocusRect(true);
283 return true; 338 return true;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); 746 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT));
692 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); 747 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED));
693 } 748 }
694 749
695 void ToolbarView::UpdateAppMenuBadge() { 750 void ToolbarView::UpdateAppMenuBadge() {
696 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); 751 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL));
697 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); 752 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT));
698 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); 753 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED));
699 SchedulePaint(); 754 SchedulePaint();
700 } 755 }
701
702 SkBitmap ToolbarView::GetAppMenuIcon(views::CustomButton::ButtonState state) {
703 ui::ThemeProvider* tp = GetThemeProvider();
704
705 int id = 0;
706 switch (state) {
707 case views::CustomButton::BS_NORMAL: id = IDR_TOOLS; break;
708 case views::CustomButton::BS_HOT: id = IDR_TOOLS_H; break;
709 case views::CustomButton::BS_PUSHED: id = IDR_TOOLS_P; break;
710 default: NOTREACHED(); break;
711 }
712 SkBitmap icon = *tp->GetBitmapNamed(id);
713
714 #if defined(OS_WIN)
715 // Keep track of whether we were showing the badge before, so we don't send
716 // multiple UMA events for example when multiple Chrome windows are open.
717 static bool incompatibility_badge_showing = false;
718 // Save the old value before resetting it.
719 bool was_showing = incompatibility_badge_showing;
720 incompatibility_badge_showing = false;
721 #endif
722
723 bool add_badge = IsUpgradeRecommended() || ShouldShowIncompatibilityWarning();
724 if (!add_badge)
725 return icon;
726
727 // Draw the chrome app menu icon onto the canvas.
728 scoped_ptr<gfx::CanvasSkia> canvas(
729 new gfx::CanvasSkia(icon.width(), icon.height(), false));
730 canvas->DrawBitmapInt(icon, 0, 0);
731
732 SkBitmap badge;
733 // Only one badge can be active at any given time. The Upgrade notification
734 // is deemed most important, then the DLL conflict badge.
735 if (IsUpgradeRecommended()) {
736 badge = *tp->GetBitmapNamed(
737 UpgradeDetector::GetInstance()->GetIconResourceID(
738 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE));
739 } else if (ShouldShowIncompatibilityWarning()) {
740 #if defined(OS_WIN)
741 if (!was_showing)
742 UserMetrics::RecordAction(UserMetricsAction("ConflictBadge"));
743 badge = *tp->GetBitmapNamed(IDR_CONFLICT_BADGE);
744 incompatibility_badge_showing = true;
745 #else
746 NOTREACHED();
747 #endif
748 } else {
749 NOTREACHED();
750 }
751
752 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin);
753
754 return canvas->ExtractBitmap();
755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698