1 // Copyright (c) 2012 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.
5 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
6 #include "grit/theme_resources.h"
7 #include "ui/views/controls/label.h"
8 #include "ui/views/painter.h"
12 const int kBackgroundImages
[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE
);
16 EVBubbleView::EVBubbleView(const gfx::FontList
& font_list
,
18 SkColor parent_background_color
,
19 LocationBarView
* location_bar
)
20 : IconLabelBubbleView(kBackgroundImages
, NULL
, IDR_OMNIBOX_HTTPS_VALID
,
21 font_list
, text_color
, parent_background_color
, true),
22 page_info_helper_(this, location_bar
) {
25 EVBubbleView::~EVBubbleView() {
28 gfx::Size
EVBubbleView::GetMinimumSize() const {
29 return GetMinimumSizeForPreferredSize(GetPreferredSize());
32 bool EVBubbleView::OnMousePressed(const ui::MouseEvent
& event
) {
33 // We want to show the dialog on mouse release; that is the standard behavior
38 void EVBubbleView::OnMouseReleased(const ui::MouseEvent
& event
) {
39 page_info_helper_
.ProcessEvent(event
);
42 void EVBubbleView::OnGestureEvent(ui::GestureEvent
* event
) {
43 if (event
->type() == ui::ET_GESTURE_TAP
) {
44 page_info_helper_
.ProcessEvent(*event
);
49 gfx::Size
EVBubbleView::GetMinimumSizeForLabelText(
50 const base::string16
& text
) const {
51 views::Label
label(text
, font_list());
52 return GetMinimumSizeForPreferredSize(
53 GetSizeForLabelWidth(label
.GetPreferredSize().width()));
56 gfx::Size
EVBubbleView::GetMinimumSizeForPreferredSize(gfx::Size size
) const {
57 const int kMinCharacters
= 10;
59 GetSizeForLabelWidth(font_list().GetExpectedTextWidth(kMinCharacters
)));