OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ev_bubble_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
6 | 6 |
7 #import "base/logging.h" | 7 #import "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" | 9 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
10 #import "chrome/browser/ui/cocoa/themed_window.h" | 10 #import "chrome/browser/ui/cocoa/themed_window.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const CGFloat kMinElidedBubbleWidth = 150.0; | 33 const CGFloat kMinElidedBubbleWidth = 150.0; |
34 | 34 |
35 // Maximum amount of available space to make the bubble, subject to | 35 // Maximum amount of available space to make the bubble, subject to |
36 // |kMinElidedBubbleWidth|. | 36 // |kMinElidedBubbleWidth|. |
37 const float kMaxBubbleFraction = 0.5; | 37 const float kMaxBubbleFraction = 0.5; |
38 | 38 |
39 // The info-bubble point should look like it points to the bottom of the lock | 39 // The info-bubble point should look like it points to the bottom of the lock |
40 // icon. Determined with Pixie.app. | 40 // icon. Determined with Pixie.app. |
41 const CGFloat kPageInfoBubblePointYOffset = 6.0; | 41 const CGFloat kPageInfoBubblePointYOffset = 6.0; |
42 | 42 |
43 // TODO(shess): This is ugly, find a better way. Using it right now | 43 // The base text color used for non-MD. |
44 // so that I can crib from gtk and still be able to see that I'm using | 44 const SkColor kBaseTextColor = SkColorSetRGB(0x07, 0x95, 0x00); |
45 // the same values easily. | |
46 NSColor* ColorWithRGBBytes(int rr, int gg, int bb) { | |
47 DCHECK_LE(rr, 255); | |
48 DCHECK_LE(bb, 255); | |
49 DCHECK_LE(gg, 255); | |
50 return [NSColor colorWithCalibratedRed:static_cast<float>(rr)/255.0 | |
51 green:static_cast<float>(gg)/255.0 | |
52 blue:static_cast<float>(bb)/255.0 | |
53 alpha:1.0]; | |
54 } | |
55 | 45 |
56 } // namespace | 46 } // namespace |
57 | 47 |
58 EVBubbleDecoration::EVBubbleDecoration(LocationIconDecoration* location_icon) | 48 EVBubbleDecoration::EVBubbleDecoration(LocationIconDecoration* location_icon) |
59 : location_icon_(location_icon) { | 49 : location_icon_(location_icon) { |
60 if (ui::MaterialDesignController::IsModeMaterial()) { | 50 if (ui::MaterialDesignController::IsModeMaterial()) { |
61 // On Retina the text label is 1px above the Omnibox textfield's text | 51 // On Retina the text label is 1px above the Omnibox textfield's text |
62 // baseline. If the Omnibox textfield also drew the label the baselines | 52 // baseline. If the Omnibox textfield also drew the label the baselines |
63 // would align. | 53 // would align. |
64 SetRetinaBaselineOffset(0.5); | 54 SetRetinaBaselineOffset(0.5); |
65 } else { | 55 } else { |
66 // Color tuples stolen from location_bar_view_gtk.cc. | 56 // Color tuples stolen from location_bar_view_gtk.cc. |
67 SetTextColor(ColorWithRGBBytes(0x07, 0x95, 0x00)); | 57 SetTextColor(skia::SkColorToSRGBNSColor(kBaseTextColor)); |
68 } | 58 } |
69 } | 59 } |
70 | 60 |
71 EVBubbleDecoration::~EVBubbleDecoration() {} | 61 EVBubbleDecoration::~EVBubbleDecoration() {} |
72 | 62 |
73 NSColor* EVBubbleDecoration::GetBackgroundBorderColor() { | 63 NSColor* EVBubbleDecoration::GetBackgroundBorderColor() { |
74 return skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700); | 64 return skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700); |
75 } | 65 } |
76 | 66 |
77 void EVBubbleDecoration::SetFullLabel(NSString* label) { | 67 void EVBubbleDecoration::SetFullLabel(NSString* label) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return location_icon_->OnMousePressed(frame, location); | 147 return location_icon_->OnMousePressed(frame, location); |
158 } | 148 } |
159 | 149 |
160 bool EVBubbleDecoration::AcceptsMousePress() { | 150 bool EVBubbleDecoration::AcceptsMousePress() { |
161 return true; | 151 return true; |
162 } | 152 } |
163 | 153 |
164 ui::NinePartImageIds EVBubbleDecoration::GetBubbleImageIds() { | 154 ui::NinePartImageIds EVBubbleDecoration::GetBubbleImageIds() { |
165 return IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); | 155 return IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); |
166 } | 156 } |
OLD | NEW |