| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 187 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 188 profile_->GetPrefs(), this); | 188 profile_->GetPrefs(), this); |
| 189 } | 189 } |
| 190 | 190 |
| 191 LocationBarView::~LocationBarView() { | 191 LocationBarView::~LocationBarView() { |
| 192 if (template_url_service_) | 192 if (template_url_service_) |
| 193 template_url_service_->RemoveObserver(this); | 193 template_url_service_->RemoveObserver(this); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void LocationBarView::Init() { | 196 void LocationBarView::Init(views::View* popup_parent_view) { |
| 197 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 197 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 198 if (mode_ == POPUP) { | 198 if (mode_ == POPUP) { |
| 199 font_ = rb.GetFont(ui::ResourceBundle::BaseFont); | 199 font_ = rb.GetFont(ui::ResourceBundle::BaseFont); |
| 200 } else { | 200 } else { |
| 201 // Use a larger version of the system font. | 201 // Use a larger version of the system font. |
| 202 font_ = rb.GetFont(ui::ResourceBundle::MediumFont); | 202 font_ = rb.GetFont(ui::ResourceBundle::MediumFont); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // If this makes the font too big, try to make it smaller so it will fit. | 205 // If this makes the font too big, try to make it smaller so it will fit. |
| 206 const int height = GetInternalHeight(true); | 206 const int height = GetInternalHeight(true); |
| 207 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) | 207 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) |
| 208 font_ = font_.DeriveFont(-1); | 208 font_ = font_.DeriveFont(-1); |
| 209 | 209 |
| 210 location_icon_view_ = new LocationIconView(this); | 210 location_icon_view_ = new LocationIconView(this); |
| 211 AddChildView(location_icon_view_); | 211 AddChildView(location_icon_view_); |
| 212 location_icon_view_->SetVisible(true); | 212 location_icon_view_->SetVisible(true); |
| 213 location_icon_view_->set_drag_controller(this); | 213 location_icon_view_->set_drag_controller(this); |
| 214 | 214 |
| 215 ev_bubble_view_ = | 215 ev_bubble_view_ = |
| 216 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 216 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
| 217 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); | 217 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); |
| 218 AddChildView(ev_bubble_view_); | 218 AddChildView(ev_bubble_view_); |
| 219 ev_bubble_view_->SetVisible(false); | 219 ev_bubble_view_->SetVisible(false); |
| 220 ev_bubble_view_->set_drag_controller(this); | 220 ev_bubble_view_->set_drag_controller(this); |
| 221 | 221 |
| 222 // URL edit field. | 222 // URL edit field. |
| 223 // View container for URL edit field. | 223 // View container for URL edit field. |
| 224 location_entry_.reset(CreateOmniboxView(this, model_, profile_, | 224 location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
| 225 command_updater_, mode_ == POPUP, this)); | 225 command_updater_, mode_ == POPUP, this, popup_parent_view)); |
| 226 SetLocationEntryFocusable(true); | 226 SetLocationEntryFocusable(true); |
| 227 | 227 |
| 228 location_entry_view_ = location_entry_->AddToView(this); | 228 location_entry_view_ = location_entry_->AddToView(this); |
| 229 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | 229 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
| 230 | 230 |
| 231 selected_keyword_view_ = new SelectedKeywordView( | 231 selected_keyword_view_ = new SelectedKeywordView( |
| 232 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 232 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
| 233 GetColor(ToolbarModel::NONE, TEXT), profile_); | 233 GetColor(ToolbarModel::NONE, TEXT), profile_); |
| 234 AddChildView(selected_keyword_view_); | 234 AddChildView(selected_keyword_view_); |
| 235 selected_keyword_view_->SetFont(font_); | 235 selected_keyword_view_->SetFont(font_); |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1366 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1367 int total_height = | 1367 int total_height = |
| 1368 use_preferred_size ? GetPreferredSize().height() : height(); | 1368 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1369 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1369 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 bool LocationBarView::HasValidSuggestText() const { | 1372 bool LocationBarView::HasValidSuggestText() const { |
| 1373 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1373 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1374 !suggested_text_view_->text().empty(); | 1374 !suggested_text_view_->text().empty(); |
| 1375 } | 1375 } |
| OLD | NEW |