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

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

Issue 151283006: Mac OS X: Show the Translate icon on Omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue-307352-translate-bubble-2
Patch Set: groby's review Created 6 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
6
7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/command_updater.h"
9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
10 #include "grit/generated_resources.h"
11 #include "grit/theme_resources.h"
12 #include "ui/base/l10n/l10n_util_mac.h"
13
14 TranslateDecoration::TranslateDecoration(CommandUpdater* command_updater)
15 : command_updater_(command_updater) {
16 SetLit(false);
17 }
18
19 TranslateDecoration::~TranslateDecoration() {}
20
21 void TranslateDecoration::SetLit(bool on) {
22 is_lit_ = on;
23 const int image_id = is_lit_ ? IDR_TRANSLATE_ACTIVE : IDR_TRANSLATE;
24 SetImage(OmniboxViewMac::ImageForResource(image_id));
25 }
26
27 NSPoint TranslateDecoration::GetBubblePointInFrame(NSRect frame) {
28 const NSRect draw_frame = GetDrawRectInFrame(frame);
29 return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame));
30 }
31
32 bool TranslateDecoration::AcceptsMousePress() { return true; }
33
34 bool TranslateDecoration::OnMousePressed(NSRect frame) {
35 command_updater_->ExecuteCommand(IDC_TRANSLATE_PAGE);
36 return true;
37 }
38
39 NSString* TranslateDecoration::GetToolTip() {
40 return l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_TRANSLATE);
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698