Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/translate_decoration.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/translate_decoration.mm b/chrome/browser/ui/cocoa/location_bar/translate_decoration.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f0f3288c7306caace5aaea2a9eeb2f599f4049cc |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/location_bar/translate_decoration.mm |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" |
| + |
| +#include "chrome/app/chrome_command_ids.h" |
| +#include "chrome/browser/command_updater.h" |
| +#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| +#include "grit/generated_resources.h" |
| +#include "grit/theme_resources.h" |
| +#include "ui/base/l10n/l10n_util_mac.h" |
| + |
| +TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater) |
| + : command_updater_(command_updater) { |
| + SetLit(false); |
| +} |
| + |
| +TranslateDecoration::~TranslateDecoration() {} |
| + |
| +void TranslateDecoration::SetLit(bool on) { |
| + is_lit_ = on; |
|
groby-ooo-7-16
2014/02/27 19:19:02
You can probably get rid of the is_lit_ member - i
hajimehoshi
2014/02/28 04:25:22
Done (Removed. Thanks!)
|
| + const int image_id = is_lit_ ? IDR_TRANSLATE_ACTIVE : IDR_TRANSLATE; |
| + SetImage(OmniboxViewMac::ImageForResource(image_id)); |
| +} |
| + |
| +NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) { |
| + const NSRect draw_frame = GetDrawRectInFrame(frame); |
| + return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); |
| +} |
| + |
| +bool TranslateDecoration::AcceptsMousePress() { return true; } |
|
Robert Sesek
2014/02/27 20:45:01
Put the body on its own line in .cc files.
hajimehoshi
2014/02/28 04:25:22
Done. (You meant .mm files?)
|
| + |
| +bool TranslateDecoration::OnMousePressed(NSRect frame) { |
| + command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE); |
| + return true; |
| +} |
| + |
| +NSString* TranslateDecoration::GetToolTip() { |
| + return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE); |
| +} |