Chromium Code Reviews| 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 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 } | 171 } |
| 172 | 172 |
| 173 //////////////////////////////////////////////////////////////////////////////// | 173 //////////////////////////////////////////////////////////////////////////////// |
| 174 // LocationBarView, public: | 174 // LocationBarView, public: |
| 175 | 175 |
| 176 void LocationBarView::Init() { | 176 void LocationBarView::Init() { |
| 177 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're | 177 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're |
| 178 // not prepared for that. | 178 // not prepared for that. |
| 179 DCHECK(GetWidget()); | 179 DCHECK(GetWidget()); |
| 180 | 180 |
| 181 const int kOmniboxPopupBorderImages[] = | 181 CreateBorderPainter(); |
|
Peter Kasting
2015/07/10 15:57:09
Just leave your new code inlined here instead of c
bruthig
2015/07/10 17:04:09
Done.
| |
| 182 IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER_AND_SHADOW); | |
| 183 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_TEXTFIELD); | |
| 184 border_painter_.reset(views::Painter::CreateImageGridPainter( | |
| 185 is_popup_mode_ ? kOmniboxPopupBorderImages : kOmniboxBorderImages)); | |
| 186 | 182 |
| 187 location_icon_view_ = new LocationIconView(this); | 183 location_icon_view_ = new LocationIconView(this); |
| 188 location_icon_view_->set_drag_controller(this); | 184 location_icon_view_->set_drag_controller(this); |
| 189 AddChildView(location_icon_view_); | 185 AddChildView(location_icon_view_); |
| 190 | 186 |
| 191 // Determine the main font. | 187 // Determine the main font. |
| 192 gfx::FontList font_list = ResourceBundle::GetSharedInstance().GetFontList( | 188 gfx::FontList font_list = ResourceBundle::GetSharedInstance().GetFontList( |
| 193 ResourceBundle::BaseFont); | 189 ResourceBundle::BaseFont); |
| 194 const int current_font_size = font_list.GetFontSize(); | 190 const int current_font_size = font_list.GetFontSize(); |
| 195 const int desired_font_size = browser_defaults::kOmniboxFontPixelSize; | 191 const int desired_font_size = browser_defaults::kOmniboxFontPixelSize; |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 } | 825 } |
| 830 | 826 |
| 831 //////////////////////////////////////////////////////////////////////////////// | 827 //////////////////////////////////////////////////////////////////////////////// |
| 832 // LocationBarView, private: | 828 // LocationBarView, private: |
| 833 | 829 |
| 834 // static | 830 // static |
| 835 int LocationBarView::IncrementalMinimumWidth(views::View* view) { | 831 int LocationBarView::IncrementalMinimumWidth(views::View* view) { |
| 836 return view->visible() ? (kItemPadding + view->GetMinimumSize().width()) : 0; | 832 return view->visible() ? (kItemPadding + view->GetMinimumSize().width()) : 0; |
| 837 } | 833 } |
| 838 | 834 |
| 835 void LocationBarView::CreateBorderPainter() { | |
| 836 if (is_popup_mode_) { | |
| 837 const int kOmniboxPopupBorderImages[] = | |
| 838 IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER_AND_SHADOW); | |
| 839 border_painter_.reset( | |
| 840 views::Painter::CreateImageGridPainter(kOmniboxPopupBorderImages)); | |
| 841 } else { | |
| 842 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 843 const gfx::Insets omnibox_border_insets(14, 9, 14, 9); | |
| 844 border_painter_.reset(views::Painter::CreateImagePainter( | |
| 845 *rb.GetImageSkiaNamed(IDR_OMNIBOX_BORDER), omnibox_border_insets)); | |
| 846 } | |
| 847 } | |
| 848 | |
| 839 int LocationBarView::GetHorizontalEdgeThickness() const { | 849 int LocationBarView::GetHorizontalEdgeThickness() const { |
| 840 // In maximized popup mode, there isn't any edge. | 850 // In maximized popup mode, there isn't any edge. |
| 841 return (is_popup_mode_ && browser_ && browser_->window() && | 851 return (is_popup_mode_ && browser_ && browser_->window() && |
| 842 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); | 852 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); |
| 843 } | 853 } |
| 844 | 854 |
| 845 bool LocationBarView::RefreshContentSettingViews() { | 855 bool LocationBarView::RefreshContentSettingViews() { |
| 846 bool visibility_changed = false; | 856 bool visibility_changed = false; |
| 847 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 857 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 848 i != content_setting_views_.end(); ++i) { | 858 i != content_setting_views_.end(); ++i) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1365 | 1375 |
| 1366 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1376 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1367 const SearchModel::State& new_state) { | 1377 const SearchModel::State& new_state) { |
| 1368 const bool visible = !GetToolbarModel()->input_in_progress() && | 1378 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1369 new_state.voice_search_supported; | 1379 new_state.voice_search_supported; |
| 1370 if (mic_search_view_->visible() != visible) { | 1380 if (mic_search_view_->visible() != visible) { |
| 1371 mic_search_view_->SetVisible(visible); | 1381 mic_search_view_->SetVisible(visible); |
| 1372 Layout(); | 1382 Layout(); |
| 1373 } | 1383 } |
| 1374 } | 1384 } |
| OLD | NEW |