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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/translate_decoration.mm

Issue 1821823004: [Mac][Material Design] Update Omnibox dropdown on Mac to MD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback. Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" 5 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/command_updater.h" 8 #include "chrome/browser/command_updater.h"
9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
10 #include "chrome/grit/generated_resources.h" 10 #include "chrome/grit/generated_resources.h"
11 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
12 #include "ui/base/l10n/l10n_util_mac.h" 12 #include "ui/base/l10n/l10n_util_mac.h"
13 #include "ui/base/material_design/material_design_controller.h" 13 #include "ui/base/material_design/material_design_controller.h"
14 #include "ui/gfx/color_palette.h"
15 #include "ui/gfx/image/image_skia_util_mac.h"
16 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/gfx/vector_icons_public.h"
18 14
19 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater) 15 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater)
20 : command_updater_(command_updater) { 16 : command_updater_(command_updater) {
21 SetLit(false, false); 17 SetLit(false, false);
22 } 18 }
23 19
24 TranslateDecoration::~TranslateDecoration() {} 20 TranslateDecoration::~TranslateDecoration() {}
25 21
26 void TranslateDecoration::SetLit(bool on, bool locationBarIsDark) { 22 void TranslateDecoration::SetLit(bool on, bool location_bar_is_dark) {
27 if (ui::MaterialDesignController::IsModeMaterial()) { 23 if (!ui::MaterialDesignController::IsModeMaterial()) {
28 SkColor vectorIconColor = locationBarIsDark ? SK_ColorWHITE
29 : gfx::kChromeIconGrey;
30 NSImage* theImage =
31 NSImageFromImageSkia(gfx::CreateVectorIcon(gfx::VectorIconId::TRANSLATE,
32 16,
33 vectorIconColor));
34 SetImage(theImage);
35 } else {
36 const int image_id = on ? IDR_TRANSLATE_ACTIVE : IDR_TRANSLATE; 24 const int image_id = on ? IDR_TRANSLATE_ACTIVE : IDR_TRANSLATE;
37 SetImage(OmniboxViewMac::ImageForResource(image_id)); 25 SetImage(OmniboxViewMac::ImageForResource(image_id));
26 return;
38 } 27 }
28 SetImage(GetMaterialIcon(location_bar_is_dark));
39 } 29 }
40 30
41 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) { 31 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) {
42 const NSRect draw_frame = GetDrawRectInFrame(frame); 32 const NSRect draw_frame = GetDrawRectInFrame(frame);
43 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); 33 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame));
44 } 34 }
45 35
46 bool TranslateDecoration::AcceptsMousePress() { 36 bool TranslateDecoration::AcceptsMousePress() {
47 return true; 37 return true;
48 } 38 }
49 39
50 bool TranslateDecoration::OnMousePressed(NSRect frame, NSPoint location) { 40 bool TranslateDecoration::OnMousePressed(NSRect frame, NSPoint location) {
51 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE); 41 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE);
52 return true; 42 return true;
53 } 43 }
54 44
55 NSString* TranslateDecoration::GetToolTip() { 45 NSString* TranslateDecoration::GetToolTip() {
56 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE); 46 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE);
57 } 47 }
48
49 gfx::VectorIconId TranslateDecoration::GetMaterialVectorIconId() {
50 return gfx::VectorIconId::TRANSLATE;
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698