| 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 ebdaa95c383d1ccb46cc15f5cb5bdce312949e99..f65401519b4a97697a89bd30d7e3d61318424128 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
|
| @@ -41,7 +41,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();
|
|
|
| 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();
|
| +}
|
|
|