| Index: chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm b/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
|
| index 0547d31263d4c6743a557055be5c0b5c770ca383..8cf73254e444b31b3dae94db158c6661dd7cd532 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
|
| @@ -7,8 +7,10 @@
|
| #import "base/logging.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
|
| +#import "chrome/browser/ui/cocoa/themed_window.h"
|
| #include "grit/theme_resources.h"
|
| #include "skia/ext/skia_utils_mac.h"
|
| +#import "ui/base/cocoa/nsview_additions.h"
|
| #include "ui/base/material_design/material_design_controller.h"
|
| #include "ui/gfx/color_palette.h"
|
| #include "ui/gfx/font_list.h"
|
| @@ -16,6 +18,9 @@
|
|
|
| namespace {
|
|
|
| +// This is used to increase the right margin of this decoration.
|
| +const CGFloat kRightSideMargin = 1.0;
|
| +
|
| // TODO(shess): In general, decorations that don't fit in the
|
| // available space are omitted. This one never goes to omitted, it
|
| // sticks at 150px, which AFAICT follows the Windows code. Since the
|
| @@ -48,12 +53,19 @@ NSColor* ColorWithRGBBytes(int rr, int gg, int bb) {
|
| alpha:1.0];
|
| }
|
|
|
| +const int kMaterialFontSize = 11;
|
| +const int kMaterialCornerRadius = 2;
|
| +
|
| } // namespace
|
|
|
| EVBubbleDecoration::EVBubbleDecoration(LocationIconDecoration* location_icon)
|
| : location_icon_(location_icon) {
|
| if (ui::MaterialDesignController::IsModeMaterial()) {
|
| SetTextColor(GetBackgroundBorderColor());
|
| + // The EV chip text in Material Design uses a slightly smaller font than the
|
| + // default, and has to be moved down slightly.
|
| + SetFont([NSFont systemFontOfSize:kMaterialFontSize]);
|
| + SetBaselineOffset(1);
|
| } else {
|
| // Color tuples stolen from location_bar_view_gtk.cc.
|
| SetTextColor(ColorWithRGBBytes(0x07, 0x95, 0x00));
|
| @@ -63,7 +75,7 @@ EVBubbleDecoration::EVBubbleDecoration(LocationIconDecoration* location_icon)
|
| EVBubbleDecoration::~EVBubbleDecoration() {}
|
|
|
| NSColor* EVBubbleDecoration::GetBackgroundBorderColor() {
|
| - return skia::SkColorToCalibratedNSColor(gfx::kGoogleGreen700);
|
| + return skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700);
|
| }
|
|
|
| void EVBubbleDecoration::SetFullLabel(NSString* label) {
|
| @@ -71,6 +83,46 @@ void EVBubbleDecoration::SetFullLabel(NSString* label) {
|
| SetLabel(full_label_);
|
| }
|
|
|
| +void EVBubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame,
|
| + NSRect frame,
|
| + NSView* control_view) {
|
| + if (!ui::MaterialDesignController::IsModeMaterial()) {
|
| + BubbleDecoration::DrawWithBackgroundInFrame(background_frame, frame,
|
| + control_view);
|
| + return;
|
| + }
|
| +
|
| + NSRect rect = NSInsetRect(background_frame, 0, 3);
|
| + rect.size.width -= kRightSideMargin;
|
| +
|
| + CGFloat line_width = [control_view cr_lineWidth];
|
| + bool in_dark_mode = [[control_view window] inIncognitoModeWithSystemTheme];
|
| + // Only adjust the path rect by 1/2 the line width if it's going to be
|
| + // stroked (so that the stroke lines fall along pixel lines).
|
| + if (!in_dark_mode) {
|
| + rect = NSInsetRect(rect, line_width / 2., line_width / 2.);
|
| + }
|
| + NSBezierPath* path =
|
| + [NSBezierPath bezierPathWithRoundedRect:rect
|
| + xRadius:kMaterialCornerRadius
|
| + yRadius:kMaterialCornerRadius];
|
| + [path setLineWidth:line_width];
|
| + if (in_dark_mode) {
|
| + [[NSColor whiteColor] set];
|
| + [path fill];
|
| + } else {
|
| + [[NSColor colorWithSRGBRed:46 / 255.
|
| + green:135 / 255.
|
| + blue:50 / 255.
|
| + alpha:0.05] set];
|
| + [path fill];
|
| + [GetBackgroundBorderColor() set];
|
| + [path stroke];
|
| + }
|
| +
|
| + DrawInFrame(frame, control_view);
|
| +}
|
| +
|
| NSPoint EVBubbleDecoration::GetBubblePointInFrame(NSRect frame) {
|
| NSRect image_rect = GetImageRectInFrame(frame);
|
| return NSMakePoint(NSMidX(image_rect),
|
|
|