blob: c30bc8185dc382aac85abb96989cb4dcccd9cf0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
#include "grit/theme_resources.h"
#include "ui/views/controls/label.h"
#include "ui/views/painter.h"
namespace {
const int kBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE);
}
EVBubbleView::EVBubbleView(const gfx::FontList& font_list,
SkColor text_color,
SkColor parent_background_color,
LocationBarView* location_bar)
: IconLabelBubbleView(kBackgroundImages, NULL, IDR_OMNIBOX_HTTPS_VALID,
font_list, text_color, parent_background_color, true),
page_info_helper_(this, location_bar) {
}
EVBubbleView::~EVBubbleView() {
}
gfx::Size EVBubbleView::GetMinimumSize() const {
return GetMinimumSizeForPreferredSize(GetPreferredSize());
}
bool EVBubbleView::OnMousePressed(const ui::MouseEvent& event) {
// We want to show the dialog on mouse release; that is the standard behavior
// for buttons.
return true;
}
void EVBubbleView::OnMouseReleased(const ui::MouseEvent& event) {
page_info_helper_.ProcessEvent(event);
}
void EVBubbleView::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
page_info_helper_.ProcessEvent(*event);
event->SetHandled();
}
}
gfx::Size EVBubbleView::GetMinimumSizeForLabelText(
const base::string16& text) const {
views::Label label(text, font_list());
return GetMinimumSizeForPreferredSize(
GetSizeForLabelWidth(label.GetPreferredSize().width()));
}
gfx::Size EVBubbleView::GetMinimumSizeForPreferredSize(gfx::Size size) const {
const int kMinCharacters = 10;
size.SetToMin(
GetSizeForLabelWidth(font_list().GetExpectedTextWidth(kMinCharacters)));
return size;
}
|