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..1587c21e5e13e1ff3e709aa7a6a43b9fcee1593f 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()]; |
|
Scott Hess - ex-Googler
2013/01/28 21:37:27
Is the separator truly independent from the search
sail
2013/01/29 22:31:08
Currently only the search token has a separator af
Scott Hess - ex-Googler
2013/01/29 23:28:36
Matching the views code is a good reason.
|
| // 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(); |
| 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,14 @@ void LocationBarViewMac::UpdatePlusDecorationVisibility() { |
| plus_decoration_->SetVisible(!toolbar_model_->GetInputInProgress()); |
| } |
| } |
| + |
| +string16 LocationBarViewMac::GetSearchProviderName() const { |
| + if (toolbar_model_->WouldReplaceSearchURLWithSearchTerms()) { |
|
kuan
2013/01/28 18:02:00
just heads up that in the bug rpt, pkasting@ is ad
sail
2013/01/29 22:31:08
Done.
Re-added the !GetInputInProgress() condition
|
| + const TemplateURL* template_url = |
| + TemplateURLServiceFactory::GetForProfile(profile_)-> |
| + GetDefaultSearchProvider(); |
| + if (template_url) |
| + return template_url->short_name(); |
| + } |
| + return string16(); |
| +} |