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/base/resource/material_design/material_design_controller.h"
8 #include "ui/views/controls/label.h"
9 #include "ui/views/painter.h"
11 EVBubbleView::EVBubbleView(const gfx::FontList
& font_list
,
13 SkColor parent_background_color
,
14 LocationBarView
* location_bar
)
15 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_VALID
,
18 parent_background_color
,
20 page_info_helper_(this, location_bar
) {
21 if (ui::MaterialDesignController::IsModeMaterial()) {
22 // The insets for IDR_OMNIBOX_EV_BUBBLE for which to perfom nine-slicing.
23 static const int kImageInset
= 4;
24 gfx::Insets
insets(kImageInset
, kImageInset
, kImageInset
, kImageInset
);
25 SetBackgroundImageWithInsets(IDR_OMNIBOX_EV_BUBBLE
, insets
);
27 static const int kBackgroundImages
[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE
);
28 SetBackgroundImageGrid(kBackgroundImages
);
32 EVBubbleView::~EVBubbleView() {
35 gfx::Size
EVBubbleView::GetMinimumSize() const {
36 return GetMinimumSizeForPreferredSize(GetPreferredSize());
39 bool EVBubbleView::OnMousePressed(const ui::MouseEvent
& event
) {
40 // We want to show the dialog on mouse release; that is the standard behavior
45 void EVBubbleView::OnMouseReleased(const ui::MouseEvent
& event
) {
46 page_info_helper_
.ProcessEvent(event
);
49 void EVBubbleView::OnGestureEvent(ui::GestureEvent
* event
) {
50 if (event
->type() == ui::ET_GESTURE_TAP
) {
51 page_info_helper_
.ProcessEvent(*event
);
56 gfx::Size
EVBubbleView::GetMinimumSizeForLabelText(
57 const base::string16
& text
) const {
58 views::Label
label(text
, font_list());
59 return GetMinimumSizeForPreferredSize(
60 GetSizeForLabelWidth(label
.GetPreferredSize().width()));
63 gfx::Size
EVBubbleView::GetMinimumSizeForPreferredSize(gfx::Size size
) const {
64 const int kMinCharacters
= 10;
66 GetSizeForLabelWidth(font_list().GetExpectedTextWidth(kMinCharacters
)));