OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/location_bar/ev_bubble_decoration.h" | 5 #import "chrome/browser/cocoa/location_bar/ev_bubble_decoration.h" |
6 | 6 |
7 #include "app/text_elider.h" | 7 #include "app/text_elider.h" |
8 #import "base/logging.h" | 8 #import "base/logging.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #import "chrome/browser/cocoa/image_utils.h" | 10 #import "chrome/browser/cocoa/image_utils.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (all_width <= width) { | 72 if (all_width <= width) { |
73 SetLabel(full_label_); | 73 SetLabel(full_label_); |
74 return all_width; | 74 return all_width; |
75 } | 75 } |
76 | 76 |
77 // Width left for laying out the label. | 77 // Width left for laying out the label. |
78 const CGFloat width_left = width - GetWidthForImageAndLabel(image, @""); | 78 const CGFloat width_left = width - GetWidthForImageAndLabel(image, @""); |
79 | 79 |
80 // Middle-elide the label to fit |width_left|. This leaves the | 80 // Middle-elide the label to fit |width_left|. This leaves the |
81 // prefix and the trailing country code in place. | 81 // prefix and the trailing country code in place. |
82 gfx::Font font = gfx::Font::CreateFont( | 82 gfx::Font font(base::SysNSStringToWide([font_ fontName]), |
83 base::SysNSStringToWide([font_ fontName]), [font_ pointSize]); | 83 [font_ pointSize]); |
84 NSString* elided_label = base::SysWideToNSString( | 84 NSString* elided_label = base::SysWideToNSString( |
85 ElideText(base::SysNSStringToWide(full_label_), font, width_left, true)); | 85 ElideText(base::SysNSStringToWide(full_label_), font, width_left, true)); |
86 | 86 |
87 // Use the elided label. | 87 // Use the elided label. |
88 SetLabel(elided_label); | 88 SetLabel(elided_label); |
89 return GetWidthForImageAndLabel(image, elided_label); | 89 return GetWidthForImageAndLabel(image, elided_label); |
90 } | 90 } |
91 | 91 |
92 // Pass mouse operations through to location icon. | 92 // Pass mouse operations through to location icon. |
93 bool EVBubbleDecoration::IsDraggable() { | 93 bool EVBubbleDecoration::IsDraggable() { |
94 return location_icon_->IsDraggable(); | 94 return location_icon_->IsDraggable(); |
95 } | 95 } |
96 | 96 |
97 NSPasteboard* EVBubbleDecoration::GetDragPasteboard() { | 97 NSPasteboard* EVBubbleDecoration::GetDragPasteboard() { |
98 return location_icon_->GetDragPasteboard(); | 98 return location_icon_->GetDragPasteboard(); |
99 } | 99 } |
100 | 100 |
101 NSImage* EVBubbleDecoration::GetDragImage() { | 101 NSImage* EVBubbleDecoration::GetDragImage() { |
102 return location_icon_->GetDragImage(); | 102 return location_icon_->GetDragImage(); |
103 } | 103 } |
104 | 104 |
105 bool EVBubbleDecoration::OnMousePressed(NSRect frame) { | 105 bool EVBubbleDecoration::OnMousePressed(NSRect frame) { |
106 return location_icon_->OnMousePressed(frame); | 106 return location_icon_->OnMousePressed(frame); |
107 } | 107 } |
OLD | NEW |