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 c923a07aa062ead570208f23c5ab2fa9f84aeb8a..748922498619c53c69cf02a2f7ed079ca5e9b5c3 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| @@ -45,6 +45,7 @@ |
| #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" |
| +#include "chrome/browser/ui/views/location_bar/search_token_view.h" |
| #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| #include "chrome/browser/ui/views/location_bar/star_view.h" |
| #include "chrome/browser/ui/views/location_bar/web_intents_button_view.h" |
| @@ -76,6 +77,7 @@ |
| #include "ui/views/border.h" |
| #include "ui/views/button_drag_utils.h" |
| #include "ui/views/controls/label.h" |
| +#include "ui/views/layout/layout_constants.h" |
| #include "ui/views/widget/widget.h" |
| #if defined(OS_WIN) |
| @@ -178,6 +180,7 @@ LocationBarView::LocationBarView(Browser* browser, |
| selected_keyword_view_(NULL), |
| suggested_text_view_(NULL), |
| keyword_hint_view_(NULL), |
| + search_token_view_(NULL), |
| zoom_view_(NULL), |
| open_pdf_in_reader_view_(NULL), |
| script_bubble_icon_view_(NULL), |
| @@ -231,17 +234,17 @@ void LocationBarView::Init() { |
| font_ = font_.DeriveFont(-1); |
| location_icon_view_ = new LocationIconView(this); |
| - AddChildView(location_icon_view_); |
| location_icon_view_->SetVisible(true); |
| location_icon_view_->set_drag_controller(this); |
| + AddChildView(location_icon_view_); |
| ev_bubble_view_ = |
| new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
| GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), |
| this); |
| - AddChildView(ev_bubble_view_); |
| ev_bubble_view_->SetVisible(false); |
| ev_bubble_view_->set_drag_controller(this); |
| + AddChildView(ev_bubble_view_); |
| // URL edit field. |
| // View container for URL edit field. |
| @@ -256,14 +259,19 @@ void LocationBarView::Init() { |
| kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
| GetColor(ToolbarModel::NONE, TEXT), |
| profile_); |
| - AddChildView(selected_keyword_view_); |
| - selected_keyword_view_->SetFont(font_); |
| selected_keyword_view_->SetVisible(false); |
| + selected_keyword_view_->SetFont(font_); |
| + AddChildView(selected_keyword_view_); |
| keyword_hint_view_ = new KeywordHintView(profile_, this); |
| - AddChildView(keyword_hint_view_); |
| keyword_hint_view_->SetVisible(false); |
| keyword_hint_view_->SetFont(font_); |
| + AddChildView(keyword_hint_view_); |
| + |
| + search_token_view_ = new SearchTokenView(this); |
| + search_token_view_->SetVisible(false); |
| + search_token_view_->SetFont(font_); |
| + AddChildView(search_token_view_); |
| for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| ContentSettingImageView* content_blocked_view = |
| @@ -272,8 +280,8 @@ void LocationBarView::Init() { |
| font_, |
| GetColor(ToolbarModel::NONE, TEXT)); |
| content_setting_views_.push_back(content_blocked_view); |
| - AddChildView(content_blocked_view); |
| content_blocked_view->SetVisible(false); |
| + AddChildView(content_blocked_view); |
| } |
| zoom_view_ = new ZoomView(model_, delegate_); |
| @@ -289,24 +297,24 @@ void LocationBarView::Init() { |
| AddChildView(open_pdf_in_reader_view_); |
| script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); |
| - AddChildView(script_bubble_icon_view_); |
| script_bubble_icon_view_->SetVisible(false); |
| + AddChildView(script_bubble_icon_view_); |
| if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| // Note: condition above means that the star icon is hidden in popups and in |
| // the app launcher. |
| star_view_ = new StarView(command_updater_); |
| - AddChildView(star_view_); |
| star_view_->SetVisible(true); |
| + AddChildView(star_view_); |
| } |
| if (extensions::FeatureSwitch::action_box()->IsEnabled() && |
| mode_ == NORMAL && browser_) { |
| + if (star_view_) |
| + star_view_->SetVisible(false); |
| + |
| action_box_button_view_ = new ActionBoxButtonView(browser_, |
| gfx::Point(kNormalHorizontalEdgeThickness, kVerticalEdgeThickness)); |
| AddChildView(action_box_button_view_); |
| - |
| - if (star_view_) |
| - star_view_->SetVisible(false); |
| } |
| registrar_.Add(this, |
| @@ -425,6 +433,22 @@ void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
| if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) |
| star_view_->SetVisible(star_enabled); |
| + string16 search_provider; |
| + if (!model_->GetInputInProgress() && |
| + model_->WouldReplaceSearchURLWithSearchTerms()) { |
| + const TemplateURL* template_url = |
| + TemplateURLServiceFactory::GetForProfile(profile_)-> |
| + GetDefaultSearchProvider(); |
| + if (template_url) { |
| + search_provider = template_url->short_name(); |
| + search_token_view_->SetBackgroundColor(GetColor( |
| + model_->GetSecurityLevel(), LocationBarView::BACKGROUND)); |
| + search_token_view_->SetForegroundColor(GetColor( |
| + model_->GetSecurityLevel(), LocationBarView::DEEMPHASIZED_TEXT)); |
| + } |
| + } |
| + search_token_view_->SetSearchProvider(search_provider); |
| + |
| // Don't Update in app launcher mode so that the location entry does not show |
| // a URL or security background. |
| if (mode_ != APP_LAUNCHER) |
| @@ -673,6 +697,7 @@ void LocationBarView::Layout() { |
| location_icon_view_->SetVisible(false); |
| ev_bubble_view_->SetVisible(false); |
| keyword_hint_view_->SetVisible(false); |
| + search_token_view_->SetVisible(false); |
| const string16 keyword(location_entry_->model()->keyword()); |
| const bool is_keyword_hint(location_entry_->model()->is_keyword_hint()); |
| @@ -763,6 +788,13 @@ void LocationBarView::Layout() { |
| if (keyword_hint_view_->keyword() != keyword) |
| keyword_hint_view_->SetKeyword(keyword); |
| } |
| + if (search_token_view_->has_search_provider()) { |
|
beaudoin
2013/01/07 17:27:53
Add a comment to indicate this must absolutely be
kuan
2013/01/09 19:52:58
Done.
|
| + right_decorations.AddDecoration( |
| + kVerticalEdgeThickness, location_height, true, 0, GetEdgeItemPadding(), |
| + GetItemPadding(), 0, search_token_view_); |
|
beaudoin
2013/01/07 22:18:40
"true" means this component is auto-collapsible. A
kuan
2013/01/09 19:52:58
Done. yes, it is auto-collapsible.
|
| + right_decorations.set_item_edit_padding( |
| + views::kUnrelatedControlLargeHorizontalSpacing); |
| + } |
| // Perform layout. |
| int full_width = width() - 2 * kEdgeThickness; |