Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/views/location_bar/ev_bubble_view.cc

Issue 1423263004: [MD] Use programmatic rendering for omnibox chips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" 5 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
6 #include "grit/theme_resources.h" 6 #include "grit/theme_resources.h"
7 #include "ui/base/resource/material_design/material_design_controller.h" 7 #include "ui/base/resource/material_design/material_design_controller.h"
8 #include "ui/views/controls/label.h" 8 #include "ui/views/controls/label.h"
9 #include "ui/views/painter.h" 9 #include "ui/views/painter.h"
10 10
11 EVBubbleView::EVBubbleView(const gfx::FontList& font_list, 11 EVBubbleView::EVBubbleView(const gfx::FontList& font_list,
12 SkColor text_color, 12 SkColor text_color,
13 SkColor parent_background_color, 13 SkColor parent_background_color,
14 LocationBarView* location_bar) 14 LocationBarView* location_bar)
15 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_VALID, 15 : IconLabelBubbleView(IDR_OMNIBOX_HTTPS_VALID,
16 font_list, 16 font_list,
17 text_color, 17 text_color,
18 parent_background_color, 18 parent_background_color,
19 true), 19 true),
20 text_color_(text_color),
20 page_info_helper_(this, location_bar) { 21 page_info_helper_(this, location_bar) {
21 if (ui::MaterialDesignController::IsModeMaterial()) { 22 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);
26 } else {
27 static const int kBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); 23 static const int kBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE);
28 SetBackgroundImageGrid(kBackgroundImages); 24 SetBackgroundImageGrid(kBackgroundImages);
29 } 25 }
30 } 26 }
31 27
32 EVBubbleView::~EVBubbleView() { 28 EVBubbleView::~EVBubbleView() {
33 } 29 }
34 30
35 gfx::Size EVBubbleView::GetMinimumSize() const { 31 gfx::Size EVBubbleView::GetMinimumSize() const {
36 return GetMinimumSizeForPreferredSize(GetPreferredSize()); 32 return GetMinimumSizeForPreferredSize(GetPreferredSize());
37 } 33 }
38 34
39 bool EVBubbleView::OnMousePressed(const ui::MouseEvent& event) { 35 bool EVBubbleView::OnMousePressed(const ui::MouseEvent& event) {
40 // We want to show the dialog on mouse release; that is the standard behavior 36 // We want to show the dialog on mouse release; that is the standard behavior
41 // for buttons. 37 // for buttons.
42 return true; 38 return true;
43 } 39 }
44 40
45 void EVBubbleView::OnMouseReleased(const ui::MouseEvent& event) { 41 void EVBubbleView::OnMouseReleased(const ui::MouseEvent& event) {
46 page_info_helper_.ProcessEvent(event); 42 page_info_helper_.ProcessEvent(event);
47 } 43 }
48 44
49 void EVBubbleView::OnGestureEvent(ui::GestureEvent* event) { 45 void EVBubbleView::OnGestureEvent(ui::GestureEvent* event) {
50 if (event->type() == ui::ET_GESTURE_TAP) { 46 if (event->type() == ui::ET_GESTURE_TAP) {
51 page_info_helper_.ProcessEvent(*event); 47 page_info_helper_.ProcessEvent(*event);
52 event->SetHandled(); 48 event->SetHandled();
53 } 49 }
54 } 50 }
55 51
52 SkColor EVBubbleView::GetTextColor() const {
53 return text_color_;
54 }
55
56 SkColor EVBubbleView::GetBorderColor() const {
57 return GetTextColor();
58 }
59
56 gfx::Size EVBubbleView::GetMinimumSizeForLabelText( 60 gfx::Size EVBubbleView::GetMinimumSizeForLabelText(
57 const base::string16& text) const { 61 const base::string16& text) const {
58 views::Label label(text, font_list()); 62 views::Label label(text, font_list());
59 return GetMinimumSizeForPreferredSize( 63 return GetMinimumSizeForPreferredSize(
60 GetSizeForLabelWidth(label.GetPreferredSize().width())); 64 GetSizeForLabelWidth(label.GetPreferredSize().width()));
61 } 65 }
62 66
63 gfx::Size EVBubbleView::GetMinimumSizeForPreferredSize(gfx::Size size) const { 67 gfx::Size EVBubbleView::GetMinimumSizeForPreferredSize(gfx::Size size) const {
64 const int kMinCharacters = 10; 68 const int kMinCharacters = 10;
65 size.SetToMin( 69 size.SetToMin(
66 GetSizeForLabelWidth(font_list().GetExpectedTextWidth(kMinCharacters))); 70 GetSizeForLabelWidth(font_list().GetExpectedTextWidth(kMinCharacters)));
67 return size; 71 return size;
68 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698