| OLD | NEW |
| 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/keyword_hint_view.h" | 5 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 14 #include "chrome/browser/ui/layout_constants.h" | |
| 15 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" | 14 #include "chrome/browser/ui/views/location_bar/background_with_1_px_border.h" |
| 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 17 #include "components/search_engines/template_url_service.h" | 17 #include "components/search_engines/template_url_service.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/gfx/color_utils.h" | 19 #include "ui/gfx/color_utils.h" |
| 20 #include "ui/strings/grit/ui_strings.h" | 20 #include "ui/strings/grit/ui_strings.h" |
| 21 #include "ui/views/border.h" | 21 #include "ui/views/border.h" |
| 22 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // This view sort of looks like a tab key. | 26 // This view sort of looks like a tab key. |
| 27 class TabKeyBubbleView : public views::Label { | 27 class TabKeyBubbleView : public views::Label { |
| 28 public: | 28 public: |
| 29 explicit TabKeyBubbleView(const gfx::FontList& font_list); | 29 explicit TabKeyBubbleView(const gfx::FontList& font_list); |
| 30 ~TabKeyBubbleView() override; | 30 ~TabKeyBubbleView() override; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // views::Label: | 33 // views::Label: |
| 34 gfx::Size GetPreferredSize() const override; | 34 gfx::Size GetPreferredSize() const override; |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(TabKeyBubbleView); | 36 DISALLOW_COPY_AND_ASSIGN(TabKeyBubbleView); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 TabKeyBubbleView::TabKeyBubbleView(const gfx::FontList& font_list) | 39 TabKeyBubbleView::TabKeyBubbleView(const gfx::FontList& font_list) |
| 40 : views::Label(l10n_util::GetStringUTF16(IDS_APP_TAB_KEY), font_list) { | 40 : views::Label(l10n_util::GetStringUTF16(IDS_APP_TAB_KEY), font_list) { |
| 41 SetBorder(views::CreateEmptyBorder( | 41 SetBorder(views::CreateEmptyBorder( |
| 42 gfx::Insets(GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING), 0))); | 42 gfx::Insets(LocationBarView::kBubbleVerticalPadding, 0))); |
| 43 } | 43 } |
| 44 | 44 |
| 45 TabKeyBubbleView::~TabKeyBubbleView() {} | 45 TabKeyBubbleView::~TabKeyBubbleView() {} |
| 46 | 46 |
| 47 gfx::Size TabKeyBubbleView::GetPreferredSize() const { | 47 gfx::Size TabKeyBubbleView::GetPreferredSize() const { |
| 48 gfx::Size size = views::Label::GetPreferredSize(); | 48 gfx::Size size = views::Label::GetPreferredSize(); |
| 49 constexpr int kPaddingInsideBorder = 5; | 49 constexpr int kPaddingInsideBorder = 5; |
| 50 // Even though the border is 1 px thick visibly, it takes 1 DIP logically. | 50 // Even though the border is 1 px thick visibly, it takes 1 DIP logically. |
| 51 size.Enlarge(2 * (kPaddingInsideBorder + 1), 0); | 51 size.Enlarge(2 * (kPaddingInsideBorder + 1), 0); |
| 52 return size; | 52 return size; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 views::Label* KeywordHintView::CreateLabel(const gfx::FontList& font_list, | 143 views::Label* KeywordHintView::CreateLabel(const gfx::FontList& font_list, |
| 144 SkColor text_color, | 144 SkColor text_color, |
| 145 SkColor background_color) { | 145 SkColor background_color) { |
| 146 views::Label* label = new views::Label(base::string16(), font_list); | 146 views::Label* label = new views::Label(base::string16(), font_list); |
| 147 label->SetEnabledColor(text_color); | 147 label->SetEnabledColor(text_color); |
| 148 label->SetBackgroundColor(background_color); | 148 label->SetBackgroundColor(background_color); |
| 149 AddChildView(label); | 149 AddChildView(label); |
| 150 return label; | 150 return label; |
| 151 } | 151 } |
| OLD | NEW |