| 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 "chrome/grit/theme_resources.h" | 11 #include "chrome/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 | 14 |
| 15 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater) | 15 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater) |
| 16 : command_updater_(command_updater) { | 16 : command_updater_(command_updater) { |
| 17 SetLit(false, false); | 17 SetLit(false, false); |
| 18 } | 18 } |
| 19 | 19 |
| 20 TranslateDecoration::~TranslateDecoration() {} | 20 TranslateDecoration::~TranslateDecoration() {} |
| 21 | 21 |
| 22 void TranslateDecoration::SetLit(bool on, bool location_bar_is_dark) { | 22 void TranslateDecoration::SetLit(bool on, bool location_bar_is_dark) { |
| 23 if (!ui::MaterialDesignController::IsModeMaterial()) { | |
| 24 const int image_id = on ? IDR_TRANSLATE_ACTIVE : IDR_TRANSLATE; | |
| 25 SetImage(OmniboxViewMac::ImageForResource(image_id)); | |
| 26 return; | |
| 27 } | |
| 28 SetImage(GetMaterialIcon(location_bar_is_dark)); | 23 SetImage(GetMaterialIcon(location_bar_is_dark)); |
| 29 } | 24 } |
| 30 | 25 |
| 31 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) { | 26 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) { |
| 32 const NSRect draw_frame = GetDrawRectInFrame(frame); | 27 const NSRect draw_frame = GetDrawRectInFrame(frame); |
| 33 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); | 28 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); |
| 34 } | 29 } |
| 35 | 30 |
| 36 bool TranslateDecoration::AcceptsMousePress() { | 31 bool TranslateDecoration::AcceptsMousePress() { |
| 37 return true; | 32 return true; |
| 38 } | 33 } |
| 39 | 34 |
| 40 bool TranslateDecoration::OnMousePressed(NSRect frame, NSPoint location) { | 35 bool TranslateDecoration::OnMousePressed(NSRect frame, NSPoint location) { |
| 41 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE); | 36 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE); |
| 42 return true; | 37 return true; |
| 43 } | 38 } |
| 44 | 39 |
| 45 NSString* TranslateDecoration::GetToolTip() { | 40 NSString* TranslateDecoration::GetToolTip() { |
| 46 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE); | 41 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE); |
| 47 } | 42 } |
| 48 | 43 |
| 49 gfx::VectorIconId TranslateDecoration::GetMaterialVectorIconId() const { | 44 gfx::VectorIconId TranslateDecoration::GetMaterialVectorIconId() const { |
| 50 return gfx::VectorIconId::TRANSLATE; | 45 return gfx::VectorIconId::TRANSLATE; |
| 51 } | 46 } |
| OLD | NEW |