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/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const TabContentsWrapper* wrapper = delegate->GetTabContentsWrapper(); | 80 const TabContentsWrapper* wrapper = delegate->GetTabContentsWrapper(); |
81 return wrapper ? wrapper->web_contents() : NULL; | 81 return wrapper ? wrapper->web_contents() : NULL; |
82 } | 82 } |
83 | 83 |
84 // A utility function to cast OmniboxView to OmniboxViewViews. | 84 // A utility function to cast OmniboxView to OmniboxViewViews. |
85 OmniboxViewViews* AsViews(OmniboxView* view) { | 85 OmniboxViewViews* AsViews(OmniboxView* view) { |
86 DCHECK(views::Widget::IsPureViews()); | 86 DCHECK(views::Widget::IsPureViews()); |
87 return static_cast<OmniboxViewViews*>(view); | 87 return static_cast<OmniboxViewViews*>(view); |
88 } | 88 } |
89 | 89 |
| 90 // Height of the location bar's round corner region. |
| 91 // TODO(jamescook): Update all Chrome platforms to use the new art and metrics |
| 92 // from Ash, crbug.com/118228 |
| 93 #if defined(USE_ASH) |
| 94 const int kBorderRoundCornerHeight = 5; |
| 95 #else |
| 96 const int kBorderRoundCornerHeight = 6; |
| 97 #endif |
| 98 |
| 99 // Width of location bar's round corner region. |
| 100 #if defined(USE_ASH) |
| 101 const int kBorderRoundCornerWidth = 4; |
| 102 #else |
| 103 const int kBorderRoundCornerWidth = 5; |
| 104 #endif |
| 105 |
| 106 // Radius of the round corners inside the location bar. |
| 107 #if defined(USE_ASH) |
| 108 const int kBorderCornerRadius = 2; |
| 109 #endif |
| 110 |
90 } // namespace | 111 } // namespace |
91 | 112 |
92 // static | 113 // static |
| 114 #if defined(USE_ASH) |
| 115 const int LocationBarView::kNormalHorizontalEdgeThickness = 2; |
| 116 const int LocationBarView::kVerticalEdgeThickness = 3; |
| 117 #else |
93 const int LocationBarView::kNormalHorizontalEdgeThickness = 1; | 118 const int LocationBarView::kNormalHorizontalEdgeThickness = 1; |
94 const int LocationBarView::kVerticalEdgeThickness = 2; | 119 const int LocationBarView::kVerticalEdgeThickness = 2; |
| 120 #endif // defined(USE_ASH) |
95 const int LocationBarView::kItemPadding = 3; | 121 const int LocationBarView::kItemPadding = 3; |
96 const int LocationBarView::kIconInternalPadding = 2; | 122 const int LocationBarView::kIconInternalPadding = 2; |
97 const int LocationBarView::kEdgeItemPadding = kItemPadding; | 123 const int LocationBarView::kEdgeItemPadding = kItemPadding; |
98 const int LocationBarView::kBubbleHorizontalPadding = 1; | 124 const int LocationBarView::kBubbleHorizontalPadding = 1; |
99 const char LocationBarView::kViewClassName[] = | 125 const char LocationBarView::kViewClassName[] = |
100 "browser/ui/views/location_bar/LocationBarView"; | 126 "browser/ui/views/location_bar/LocationBarView"; |
101 | 127 |
102 static const int kEVBubbleBackgroundImages[] = { | 128 static const int kEVBubbleBackgroundImages[] = { |
103 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L, | 129 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_L, |
104 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C, | 130 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_C, |
105 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R, | 131 IDR_OMNIBOX_EV_BUBBLE_BACKGROUND_R, |
106 }; | 132 }; |
107 | 133 |
108 static const int kSelectedKeywordBackgroundImages[] = { | 134 static const int kSelectedKeywordBackgroundImages[] = { |
109 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, | 135 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, |
110 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, | 136 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, |
111 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, | 137 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, |
112 }; | 138 }; |
113 | 139 |
114 // Height of the location bar's round corner region. | |
115 static const int kBorderRoundCornerHeight = 6; | |
116 // Width of location bar's round corner region. | |
117 static const int kBorderRoundCornerWidth = 5; | |
118 | |
119 // LocationBarView ----------------------------------------------------------- | 140 // LocationBarView ----------------------------------------------------------- |
120 | 141 |
121 LocationBarView::LocationBarView(Browser* browser, | 142 LocationBarView::LocationBarView(Browser* browser, |
122 ToolbarModel* model, | 143 ToolbarModel* model, |
123 Delegate* delegate, | 144 Delegate* delegate, |
124 Mode mode) | 145 Mode mode) |
125 : browser_(browser), | 146 : browser_(browser), |
126 model_(model), | 147 model_(model), |
127 delegate_(delegate), | 148 delegate_(delegate), |
128 disposition_(CURRENT_TAB), | 149 disposition_(CURRENT_TAB), |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 // reverse; this antialiases better (see comments in | 782 // reverse; this antialiases better (see comments in |
762 // AutocompletePopupContentsView::OnPaint()). | 783 // AutocompletePopupContentsView::OnPaint()). |
763 gfx::Rect bounds(GetContentsBounds()); | 784 gfx::Rect bounds(GetContentsBounds()); |
764 bounds.Inset(0, kVerticalEdgeThickness); | 785 bounds.Inset(0, kVerticalEdgeThickness); |
765 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND)); | 786 SkColor color(GetColor(ToolbarModel::NONE, BACKGROUND)); |
766 if (mode_ == NORMAL) { | 787 if (mode_ == NORMAL) { |
767 SkPaint paint; | 788 SkPaint paint; |
768 paint.setColor(color); | 789 paint.setColor(color); |
769 paint.setStyle(SkPaint::kFill_Style); | 790 paint.setStyle(SkPaint::kFill_Style); |
770 paint.setAntiAlias(true); | 791 paint.setAntiAlias(true); |
| 792 #if defined(USE_ASH) |
| 793 // On Ash the omnibox uses smaller corners. |
| 794 const SkScalar radius(SkIntToScalar(kBorderCornerRadius)); |
| 795 #else |
771 // The round corners of the omnibox match the round corners of the dropdown | 796 // The round corners of the omnibox match the round corners of the dropdown |
772 // below, and all our other bubbles. | 797 // below, and all our other bubbles. |
773 const SkScalar radius(SkIntToScalar( | 798 const SkScalar radius(SkIntToScalar( |
774 views::BubbleBorder::GetCornerRadius())); | 799 views::BubbleBorder::GetCornerRadius())); |
| 800 #endif |
775 bounds.Inset(kNormalHorizontalEdgeThickness, 0); | 801 bounds.Inset(kNormalHorizontalEdgeThickness, 0); |
776 canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius, | 802 canvas->sk_canvas()->drawRoundRect(gfx::RectToSkRect(bounds), radius, |
777 radius, paint); | 803 radius, paint); |
778 } else { | 804 } else { |
779 canvas->FillRect(bounds, color); | 805 canvas->FillRect(bounds, color); |
780 } | 806 } |
781 | 807 |
782 if (show_focus_rect_ && HasFocus()) { | 808 if (show_focus_rect_ && HasFocus()) { |
783 gfx::Rect r = location_entry_view_->bounds(); | 809 gfx::Rect r = location_entry_view_->bounds(); |
784 #if defined(OS_WIN) | 810 #if defined(OS_WIN) |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 !suggested_text_view_->GetText().empty(); | 1306 !suggested_text_view_->GetText().empty(); |
1281 } | 1307 } |
1282 | 1308 |
1283 #if !defined(USE_AURA) | 1309 #if !defined(USE_AURA) |
1284 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1310 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1285 CHECK(!views::Widget::IsPureViews()); | 1311 CHECK(!views::Widget::IsPureViews()); |
1286 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1312 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1287 } | 1313 } |
1288 #endif | 1314 #endif |
1289 #endif | 1315 #endif |
OLD | NEW |