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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 2382443007: Clean up NativeTheme (particularly CommonTheme). (Closed)
Patch Set: tdandersonreview Created 4 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_menu.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 default: 188 default:
189 return theme->GetSystemColor( 189 return theme->GetSystemColor(
190 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor); 190 ui::NativeTheme::kColorId_EnabledMenuButtonBorderColor);
191 } 191 }
192 } 192 }
193 193
194 static SkColor BackgroundColor(const View* view, 194 static SkColor BackgroundColor(const View* view,
195 views::Button::ButtonState state) { 195 views::Button::ButtonState state) {
196 const ui::NativeTheme* theme = view->GetNativeTheme(); 196 const ui::NativeTheme* theme = view->GetNativeTheme();
197 switch (state) { 197 switch (state) {
198 case views::Button::STATE_PRESSED:
199 return theme->GetSystemColor(
200 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
198 case views::Button::STATE_HOVERED: 201 case views::Button::STATE_HOVERED:
199 // Hovered should be handled in DrawBackground. 202 // Hovered should be handled in DrawBackground.
200 NOTREACHED(); 203 NOTREACHED();
201 return theme->GetSystemColor(
202 ui::NativeTheme::kColorId_HoverMenuItemBackgroundColor);
203 case views::Button::STATE_PRESSED:
204 return theme->GetSystemColor(
205 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor);
206 default: 204 default:
207 return theme->GetSystemColor( 205 return theme->GetSystemColor(
208 ui::NativeTheme::kColorId_MenuBackgroundColor); 206 ui::NativeTheme::kColorId_MenuBackgroundColor);
209 } 207 }
210 } 208 }
211 209
212 void DrawBackground(gfx::Canvas* canvas, 210 void DrawBackground(gfx::Canvas* canvas,
213 const views::View* view, 211 const views::View* view,
214 const gfx::Rect& bounds, 212 const gfx::Rect& bounds,
215 views::Button::ButtonState state) const { 213 views::Button::ButtonState state) const {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 723 }
726 724
727 ~RecentTabsMenuModelDelegate() override { 725 ~RecentTabsMenuModelDelegate() override {
728 model_->SetMenuModelDelegate(NULL); 726 model_->SetMenuModelDelegate(NULL);
729 } 727 }
730 728
731 const gfx::FontList* GetLabelFontListAt(int index) const { 729 const gfx::FontList* GetLabelFontListAt(int index) const {
732 return model_->GetLabelFontListAt(index); 730 return model_->GetLabelFontListAt(index);
733 } 731 }
734 732
735 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const {
736 // The items for which we get a font list, should be shown in the bolded
737 // color.
738 return GetLabelFontListAt(index) ? true : false;
739 }
740
741 // ui::MenuModelDelegate implementation: 733 // ui::MenuModelDelegate implementation:
742 734
743 void OnIconChanged(int index) override { 735 void OnIconChanged(int index) override {
744 int command_id = model_->GetCommandIdAt(index); 736 int command_id = model_->GetCommandIdAt(index);
745 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); 737 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id);
746 DCHECK(item); 738 DCHECK(item);
747 gfx::Image icon; 739 gfx::Image icon;
748 model_->GetIconAt(index, &icon); 740 model_->GetIconAt(index, &icon);
749 item->SetIcon(*icon.ToImageSkia()); 741 item->SetIcon(*icon.ToImageSkia());
750 } 742 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 } 848 }
857 849
858 const gfx::FontList* AppMenu::GetLabelFontList(int command_id) const { 850 const gfx::FontList* AppMenu::GetLabelFontList(int command_id) const {
859 if (IsRecentTabsCommand(command_id)) { 851 if (IsRecentTabsCommand(command_id)) {
860 return recent_tabs_menu_model_delegate_->GetLabelFontListAt( 852 return recent_tabs_menu_model_delegate_->GetLabelFontListAt(
861 ModelIndexFromCommandId(command_id)); 853 ModelIndexFromCommandId(command_id));
862 } 854 }
863 return NULL; 855 return NULL;
864 } 856 }
865 857
866 bool AppMenu::GetShouldUseDisabledEmphasizedForegroundColor( 858 bool AppMenu::GetShouldUseNormalForegroundColor(int command_id) const {
867 int command_id) const { 859 return IsRecentTabsCommand(command_id);
868 if (IsRecentTabsCommand(command_id)) {
869 return recent_tabs_menu_model_delegate_->
870 GetShouldUseDisabledEmphasizedForegroundColor(
871 ModelIndexFromCommandId(command_id));
872 }
873 return false;
874 } 860 }
875 861
876 base::string16 AppMenu::GetTooltipText(int command_id, 862 base::string16 AppMenu::GetTooltipText(int command_id,
877 const gfx::Point& p) const { 863 const gfx::Point& p) const {
878 return IsBookmarkCommand(command_id) ? 864 return IsBookmarkCommand(command_id) ?
879 bookmark_menu_delegate_->GetTooltipText(command_id, p) : base::string16(); 865 bookmark_menu_delegate_->GetTooltipText(command_id, p) : base::string16();
880 } 866 }
881 867
882 bool AppMenu::IsTriggerableEvent(views::MenuItemView* menu, 868 bool AppMenu::IsTriggerableEvent(views::MenuItemView* menu,
883 const ui::Event& e) { 869 const ui::Event& e) {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 0, 1236 0,
1251 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1237 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1252 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1238 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1253 } 1239 }
1254 1240
1255 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1241 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1256 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1242 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1257 DCHECK(ix != command_id_to_entry_.end()); 1243 DCHECK(ix != command_id_to_entry_.end());
1258 return ix->second.second; 1244 return ix->second.second;
1259 } 1245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698