Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| index ee59f1810df80d6c187de363f216dcd40eb08c02..d83e9e9541dff5702c4b0b4aefd01376cac6b90c 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| @@ -30,6 +30,7 @@ |
| #include "chrome/browser/ui/browser_tabstrip.h" |
| #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| +#include "chrome/browser/ui/search/search.h" |
| #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| #include "chrome/browser/ui/view_ids.h" |
| #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
| @@ -189,6 +190,7 @@ LocationBarView::LocationBarView(Browser* browser, |
| star_view_(NULL), |
| web_intents_button_view_(NULL), |
| action_box_button_view_(NULL), |
| + search_bubble_view_(NULL), |
| mode_(mode), |
| show_focus_rect_(false), |
| template_url_service_(NULL), |
| @@ -305,6 +307,7 @@ void LocationBarView::Init() { |
| AddChildView(star_view_); |
| star_view_->SetVisible(true); |
| } |
| + |
| if (extensions::FeatureSwitch::action_box()->IsEnabled() && |
| mode_ == NORMAL && browser_) { |
| action_box_button_view_ = new ActionBoxButtonView(browser_, |
| @@ -315,6 +318,15 @@ void LocationBarView::Init() { |
| star_view_->SetVisible(false); |
| } |
| + if (chrome::search::IsInstantExtendedAPIEnabled(profile_)) { |
|
Peter Kasting
2012/12/05 21:13:20
I don't think you should check this here. Let the
kuan
2012/12/11 21:10:29
Done.
|
| + search_bubble_view_ = new IconLabelBubbleView( |
| + kSelectedKeywordBackgroundImages, -1, |
| + GetColor(ToolbarModel::NONE, TEXT)); |
| + AddChildView(search_bubble_view_); |
| + search_bubble_view_->SetFont(font_); |
| + search_bubble_view_->SetVisible(false); |
| + } |
| + |
| registrar_.Add(this, |
| chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| content::Source<Profile>(profile_)); |
| @@ -734,6 +746,22 @@ void LocationBarView::Layout() { |
| entry_width -= web_intents_button_view_->GetPreferredSize().width() + |
| GetItemPadding(); |
| } |
| + if (search_bubble_view_) { |
|
Peter Kasting
2012/12/05 21:13:20
This conditional can be removed once you make the
kuan
2012/12/11 21:10:29
Done.
|
| + search_bubble_view_->SetVisible(false); |
|
Peter Kasting
2012/12/05 21:13:20
You should be controlling the visibility of this o
kuan
2012/12/11 21:10:29
Done.
|
| + if (model_->GetSecurityLevel() == ToolbarModel::SECURE && |
|
Peter Kasting
2012/12/05 21:13:20
Nit: Again, I don't think you should check this.
kuan
2012/12/11 21:10:29
Done.
|
| + model_->WouldReplaceSearchURLWithSearchTerms()) { |
| + const TemplateURL* template_url = |
| + TemplateURLServiceFactory::GetForProfile(profile_)-> |
| + GetDefaultSearchProvider(); |
| + if (template_url) { |
| + search_bubble_view_->SetLabel(l10n_util::GetStringFUTF16( |
| + IDS_OMNIBOX_EV_SEARCH_TEXT, template_url->short_name())); |
| + search_bubble_view_->SetVisible(true); |
| + entry_width -= search_bubble_view_->GetPreferredSize().width() + |
| + GetItemPadding(); |
| + } |
| + } |
| + } |
| // The gap between the edit and whatever is to its right is shortened. |
| entry_width += kEditInternalSpace; |
| @@ -867,6 +895,15 @@ void LocationBarView::Layout() { |
| web_intents_button_view_->GetBuiltInHorizontalPadding(); |
| } |
| + // Now the search bubble view. |
| + if (search_bubble_view_ && search_bubble_view_->visible()) { |
| + gfx::Size size = search_bubble_view_->GetPreferredSize(); |
| + offset -= size.width(); |
| + search_bubble_view_->SetBounds(offset, location_y + kBubbleVerticalPadding, |
| + size.width(), size.height()); |
| + offset -= GetItemPadding(); |
| + } |
| + |
| // Now lay out items to the left of the edit field. |
| if (location_icon_view_->visible()) { |
| location_icon_view_->SetBounds( |