Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| index 4d6ef9a8762de2c9025fd145846c667615418288..f9ade81a31e79f57691f098c0e9fb8c26ae62173 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm |
| @@ -40,7 +40,9 @@ |
| #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/plus_decoration.h" |
| +#import "chrome/browser/ui/cocoa/location_bar/search_token_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" |
| +#import "chrome/browser/ui/cocoa/location_bar/separator_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h" |
| #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
| @@ -94,8 +96,10 @@ LocationBarViewMac::LocationBarViewMac( |
| field_(field), |
| disposition_(CURRENT_TAB), |
| location_icon_decoration_(new LocationIconDecoration(this)), |
| + search_token_decoration_(new SearchTokenDecoration()), |
| selected_keyword_decoration_( |
| new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())), |
| + separator_decoration_(new SeparatorDecoration()), |
| ev_bubble_decoration_( |
| new EVBubbleDecoration(location_icon_decoration_.get(), |
| OmniboxViewMac::GetFieldFont())), |
| @@ -702,12 +706,16 @@ void LocationBarViewMac::Layout() { |
| [cell addRightDecoration:keyword_hint_decoration_.get()]; |
| [cell addRightDecoration:web_intents_button_decoration_.get()]; |
| + [cell addRightDecoration:separator_decoration_.get()]; |
| + [cell addRightDecoration:search_token_decoration_.get()]; |
| // By default only the location icon is visible. |
| location_icon_decoration_->SetVisible(true); |
| selected_keyword_decoration_->SetVisible(false); |
| ev_bubble_decoration_->SetVisible(false); |
| keyword_hint_decoration_->SetVisible(false); |
| + separator_decoration_->SetVisible(false); |
| + search_token_decoration_->SetVisible(false); |
| // Get the keyword to use for keyword-search and hinting. |
| const string16 keyword = omnibox_view_->model()->keyword(); |
| @@ -717,10 +725,11 @@ void LocationBarViewMac::Layout() { |
| short_name = TemplateURLServiceFactory::GetForProfile(profile_)-> |
| GetKeywordShortName(keyword, &is_extension_keyword); |
| } |
| + bool show_search_token = !GetSearchProviderName().empty(); |
|
Scott Hess - ex-Googler
2013/01/29 23:28:37
If you captured the GetSearchProviderName() result
sail
2013/01/30 01:40:56
Done.
Changed to use a local variable.
|
| const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint(); |
| - if (!keyword.empty() && !is_keyword_hint) { |
| + if (!keyword.empty() && !is_keyword_hint && !show_search_token) { |
| // Switch from location icon to keyword mode. |
| location_icon_decoration_->SetVisible(false); |
| selected_keyword_decoration_->SetVisible(true); |
| @@ -733,12 +742,18 @@ void LocationBarViewMac::Layout() { |
| string16 label(toolbar_model_->GetEVCertName()); |
| ev_bubble_decoration_->SetFullLabel(base::SysUTF16ToNSString(label)); |
| - } else if (!keyword.empty() && is_keyword_hint) { |
| + } else if (!keyword.empty() && is_keyword_hint && !show_search_token) { |
| keyword_hint_decoration_->SetKeyword(short_name, |
| is_extension_keyword); |
| keyword_hint_decoration_->SetVisible(true); |
| } |
| + if (show_search_token) { |
| + separator_decoration_->SetVisible(true); |
| + search_token_decoration_->set_search_provider_name(GetSearchProviderName()); |
| + search_token_decoration_->SetVisible(true); |
| + } |
| + |
| // These need to change anytime the layout changes. |
| // TODO(shess): Anytime the field editor might have changed, the |
| // cursor rects almost certainly should have changed. The tooltips |
| @@ -784,3 +799,15 @@ void LocationBarViewMac::UpdatePlusDecorationVisibility() { |
| plus_decoration_->SetVisible(!toolbar_model_->GetInputInProgress()); |
| } |
| } |
| + |
| +string16 LocationBarViewMac::GetSearchProviderName() const { |
| + if (!toolbar_model_->GetInputInProgress() && |
| + toolbar_model_->WouldReplaceSearchURLWithSearchTerms()) { |
| + const TemplateURL* template_url = |
| + TemplateURLServiceFactory::GetForProfile(profile_)-> |
| + GetDefaultSearchProvider(); |
| + if (template_url) |
| + return template_url->short_name(); |
| + } |
| + return string16(); |
| +} |