Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
| 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" | |
| 13 | 18 |
| 14 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater) | 19 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater) |
| 15 : command_updater_(command_updater) { | 20 : command_updater_(command_updater) { |
| 16 SetLit(false); | 21 SetLit(false, false); |
| 17 } | 22 } |
| 18 | 23 |
| 19 TranslateDecoration::~TranslateDecoration() {} | 24 TranslateDecoration::~TranslateDecoration() {} |
| 20 | 25 |
| 21 void TranslateDecoration::SetLit(bool on) { | 26 void TranslateDecoration::SetLit(bool on, bool locationBarIsDark) { |
| 22 const int image_id = on ? IDR_TRANSLATE_ACTIVE : IDR_TRANSLATE; | 27 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 23 SetImage(OmniboxViewMac::ImageForResource(image_id)); | 28 SkColor vectorIconColor = locationBarIsDark ? SK_ColorWHITE |
| 29 : gfx::kChromeIconGrey; | |
| 30 NSImage *theImage = | |
|
Avi (use Gerrit)
2016/03/15 16:03:06
space after the *
shrike
2016/03/15 17:54:56
Thank you.
| |
| 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; | |
| 37 SetImage(OmniboxViewMac::ImageForResource(image_id)); | |
| 38 } | |
| 24 } | 39 } |
| 25 | 40 |
| 26 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) { | 41 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) { |
| 27 const NSRect draw_frame = GetDrawRectInFrame(frame); | 42 const NSRect draw_frame = GetDrawRectInFrame(frame); |
| 28 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); | 43 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); |
| 29 } | 44 } |
| 30 | 45 |
| 31 bool TranslateDecoration::AcceptsMousePress() { | 46 bool TranslateDecoration::AcceptsMousePress() { |
| 32 return true; | 47 return true; |
| 33 } | 48 } |
| 34 | 49 |
| 35 bool TranslateDecoration::OnMousePressed(NSRect frame, NSPoint location) { | 50 bool TranslateDecoration::OnMousePressed(NSRect frame, NSPoint location) { |
| 36 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE); | 51 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE); |
| 37 return true; | 52 return true; |
| 38 } | 53 } |
| 39 | 54 |
| 40 NSString* TranslateDecoration::GetToolTip() { | 55 NSString* TranslateDecoration::GetToolTip() { |
| 41 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE); | 56 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE); |
| 42 } | 57 } |
| OLD | NEW |