| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 location_icon_view_->set_drag_controller(this); | 236 location_icon_view_->set_drag_controller(this); |
| 237 AddChildView(location_icon_view_); | 237 AddChildView(location_icon_view_); |
| 238 | 238 |
| 239 ev_bubble_view_ = | 239 ev_bubble_view_ = |
| 240 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 240 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
| 241 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), | 241 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), |
| 242 this); | 242 this); |
| 243 ev_bubble_view_->set_drag_controller(this); | 243 ev_bubble_view_->set_drag_controller(this); |
| 244 AddChildView(ev_bubble_view_); | 244 AddChildView(ev_bubble_view_); |
| 245 | 245 |
| 246 // URL edit field. | 246 // Initialize the Omnibox view. |
| 247 // View container for URL edit field. | |
| 248 location_entry_.reset(CreateOmniboxView(this, model_, profile_, | 247 location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
| 249 command_updater_, mode_ == POPUP, this)); | 248 command_updater_, mode_ == POPUP, this)); |
| 250 SetLocationEntryFocusable(true); | 249 SetLocationEntryFocusable(true); |
| 251 | |
| 252 location_entry_view_ = location_entry_->AddToView(this); | 250 location_entry_view_ = location_entry_->AddToView(this); |
| 253 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | |
| 254 | 251 |
| 255 selected_keyword_view_ = new SelectedKeywordView( | 252 selected_keyword_view_ = new SelectedKeywordView( |
| 256 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 253 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
| 257 GetColor(ToolbarModel::NONE, TEXT), | 254 GetColor(ToolbarModel::NONE, TEXT), |
| 258 profile_); | 255 profile_); |
| 259 selected_keyword_view_->SetFont(font_); | 256 selected_keyword_view_->SetFont(font_); |
| 260 AddChildView(selected_keyword_view_); | 257 AddChildView(selected_keyword_view_); |
| 261 | 258 |
| 262 keyword_hint_view_ = new KeywordHintView(profile_, this); | 259 keyword_hint_view_ = new KeywordHintView(profile_, this); |
| 263 keyword_hint_view_->SetFont(font_); | 260 keyword_hint_view_->SetFont(font_); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 SchedulePaint(); | 620 SchedulePaint(); |
| 624 } | 621 } |
| 625 | 622 |
| 626 string16 LocationBarView::GetInstantSuggestion() const { | 623 string16 LocationBarView::GetInstantSuggestion() const { |
| 627 return HasValidSuggestText() ? suggested_text_view_->text() : string16(); | 624 return HasValidSuggestText() ? suggested_text_view_->text() : string16(); |
| 628 } | 625 } |
| 629 | 626 |
| 630 void LocationBarView::SetLocationEntryFocusable(bool focusable) { | 627 void LocationBarView::SetLocationEntryFocusable(bool focusable) { |
| 631 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); | 628 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); |
| 632 if (omnibox_views) | 629 if (omnibox_views) |
| 633 omnibox_views->SetLocationEntryFocusable(focusable); | 630 omnibox_views->set_focusable(focusable); |
| 634 else | 631 else |
| 635 set_focusable(focusable); | 632 set_focusable(focusable); |
| 636 } | 633 } |
| 637 | 634 |
| 638 bool LocationBarView::IsLocationEntryFocusableInRootView() const { | 635 bool LocationBarView::IsLocationEntryFocusableInRootView() const { |
| 639 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); | 636 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(location_entry_.get()); |
| 640 if (omnibox_views) | 637 return omnibox_views ? omnibox_views->IsFocusable() : View::IsFocusable(); |
| 641 return omnibox_views->IsLocationEntryFocusableInRootView(); | |
| 642 return views::View::IsFocusable(); | |
| 643 } | 638 } |
| 644 | 639 |
| 645 gfx::Size LocationBarView::GetPreferredSize() { | 640 gfx::Size LocationBarView::GetPreferredSize() { |
| 646 int sizing_image_id = mode_ == POPUP ? IDR_LOCATIONBG_POPUPMODE_CENTER : | 641 int sizing_image_id = mode_ == POPUP ? IDR_LOCATIONBG_POPUPMODE_CENTER : |
| 647 IDR_LOCATION_BAR_BORDER; | 642 IDR_LOCATION_BAR_BORDER; |
| 648 return gfx::Size( | 643 return gfx::Size( |
| 649 0, GetThemeProvider()->GetImageSkiaNamed(sizing_image_id)->height()); | 644 0, GetThemeProvider()->GetImageSkiaNamed(sizing_image_id)->height()); |
| 650 } | 645 } |
| 651 | 646 |
| 652 void LocationBarView::Layout() { | 647 void LocationBarView::Layout() { |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1453 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1459 int total_height = | 1454 int total_height = |
| 1460 use_preferred_size ? GetPreferredSize().height() : height(); | 1455 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1461 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1456 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1462 } | 1457 } |
| 1463 | 1458 |
| 1464 bool LocationBarView::HasValidSuggestText() const { | 1459 bool LocationBarView::HasValidSuggestText() const { |
| 1465 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1460 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1466 !suggested_text_view_->text().empty(); | 1461 !suggested_text_view_->text().empty(); |
| 1467 } | 1462 } |
| OLD | NEW |