Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 34 #include "chrome/browser/ui/view_ids.h" | 34 #include "chrome/browser/ui/view_ids.h" |
| 35 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 35 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
| 36 #include "chrome/browser/ui/views/browser_dialogs.h" | 36 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 37 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 37 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 38 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" | 38 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" |
| 39 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 39 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 40 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 40 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 41 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 41 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 42 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 42 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
| 43 #include "chrome/browser/ui/views/location_bar/location_bar_separator_view.h" | |
| 43 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 44 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 44 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | 45 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
| 45 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 46 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 46 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 47 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 47 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" | 48 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" |
| 48 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 49 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| 49 #include "chrome/browser/ui/views/location_bar/star_view.h" | 50 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 50 #include "chrome/browser/ui/views/location_bar/web_intents_button_view.h" | 51 #include "chrome/browser/ui/views/location_bar/web_intents_button_view.h" |
| 51 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 52 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 52 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 53 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 69 #include "ui/base/resource/resource_bundle.h" | 70 #include "ui/base/resource/resource_bundle.h" |
| 70 #include "ui/base/theme_provider.h" | 71 #include "ui/base/theme_provider.h" |
| 71 #include "ui/gfx/canvas.h" | 72 #include "ui/gfx/canvas.h" |
| 72 #include "ui/gfx/color_utils.h" | 73 #include "ui/gfx/color_utils.h" |
| 73 #include "ui/gfx/image/image.h" | 74 #include "ui/gfx/image/image.h" |
| 74 #include "ui/gfx/image/image_skia_operations.h" | 75 #include "ui/gfx/image/image_skia_operations.h" |
| 75 #include "ui/gfx/skia_util.h" | 76 #include "ui/gfx/skia_util.h" |
| 76 #include "ui/views/border.h" | 77 #include "ui/views/border.h" |
| 77 #include "ui/views/button_drag_utils.h" | 78 #include "ui/views/button_drag_utils.h" |
| 78 #include "ui/views/controls/label.h" | 79 #include "ui/views/controls/label.h" |
| 80 #include "ui/views/layout/layout_constants.h" | |
| 79 #include "ui/views/widget/widget.h" | 81 #include "ui/views/widget/widget.h" |
| 80 | 82 |
| 81 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 82 #include "ui/native_theme/native_theme_win.h" | 84 #include "ui/native_theme/native_theme_win.h" |
| 83 #endif | 85 #endif |
| 84 | 86 |
| 85 #if defined(OS_WIN) && !defined(USE_AURA) | 87 #if defined(OS_WIN) && !defined(USE_AURA) |
| 86 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | 88 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 87 #endif | 89 #endif |
| 88 | 90 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 disposition_(CURRENT_TAB), | 173 disposition_(CURRENT_TAB), |
| 172 transition_(content::PageTransitionFromInt( | 174 transition_(content::PageTransitionFromInt( |
| 173 content::PAGE_TRANSITION_TYPED | | 175 content::PAGE_TRANSITION_TYPED | |
| 174 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 176 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
| 175 location_icon_view_(NULL), | 177 location_icon_view_(NULL), |
| 176 ev_bubble_view_(NULL), | 178 ev_bubble_view_(NULL), |
| 177 location_entry_view_(NULL), | 179 location_entry_view_(NULL), |
| 178 selected_keyword_view_(NULL), | 180 selected_keyword_view_(NULL), |
| 179 suggested_text_view_(NULL), | 181 suggested_text_view_(NULL), |
| 180 keyword_hint_view_(NULL), | 182 keyword_hint_view_(NULL), |
| 183 search_token_view_(NULL), | |
| 184 search_token_separator_view_(NULL), | |
| 181 zoom_view_(NULL), | 185 zoom_view_(NULL), |
| 182 open_pdf_in_reader_view_(NULL), | 186 open_pdf_in_reader_view_(NULL), |
| 183 script_bubble_icon_view_(NULL), | 187 script_bubble_icon_view_(NULL), |
| 184 star_view_(NULL), | 188 star_view_(NULL), |
| 185 web_intents_button_view_(NULL), | 189 web_intents_button_view_(NULL), |
| 186 action_box_button_view_(NULL), | 190 action_box_button_view_(NULL), |
| 187 mode_(mode), | 191 mode_(mode), |
| 188 show_focus_rect_(false), | 192 show_focus_rect_(false), |
| 189 template_url_service_(NULL), | 193 template_url_service_(NULL), |
| 190 animation_offset_(0) { | 194 animation_offset_(0) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 // Use a larger version of the system font. | 228 // Use a larger version of the system font. |
| 225 font_ = rb.GetFont(ui::ResourceBundle::MediumFont); | 229 font_ = rb.GetFont(ui::ResourceBundle::MediumFont); |
| 226 } | 230 } |
| 227 | 231 |
| 228 // If this makes the font too big, try to make it smaller so it will fit. | 232 // If this makes the font too big, try to make it smaller so it will fit. |
| 229 const int height = GetInternalHeight(true); | 233 const int height = GetInternalHeight(true); |
| 230 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) | 234 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) |
| 231 font_ = font_.DeriveFont(-1); | 235 font_ = font_.DeriveFont(-1); |
| 232 | 236 |
| 233 location_icon_view_ = new LocationIconView(this); | 237 location_icon_view_ = new LocationIconView(this); |
| 234 AddChildView(location_icon_view_); | |
| 235 location_icon_view_->SetVisible(true); | 238 location_icon_view_->SetVisible(true); |
| 236 location_icon_view_->set_drag_controller(this); | 239 location_icon_view_->set_drag_controller(this); |
| 240 AddChildView(location_icon_view_); | |
| 237 | 241 |
| 238 ev_bubble_view_ = | 242 ev_bubble_view_ = |
| 239 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 243 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
| 240 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), | 244 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), |
| 241 this); | 245 this); |
| 242 AddChildView(ev_bubble_view_); | |
| 243 ev_bubble_view_->SetVisible(false); | 246 ev_bubble_view_->SetVisible(false); |
|
Peter Kasting
2013/01/17 04:14:23
Nit: Are all these SetVisible(false) calls even ne
kuan
2013/01/17 17:57:43
Done.
| |
| 244 ev_bubble_view_->set_drag_controller(this); | 247 ev_bubble_view_->set_drag_controller(this); |
| 248 AddChildView(ev_bubble_view_); | |
| 245 | 249 |
| 246 // URL edit field. | 250 // URL edit field. |
| 247 // View container for URL edit field. | 251 // View container for URL edit field. |
| 248 location_entry_.reset(CreateOmniboxView(this, model_, profile_, | 252 location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
| 249 command_updater_, mode_ == POPUP, this)); | 253 command_updater_, mode_ == POPUP, this)); |
| 250 SetLocationEntryFocusable(true); | 254 SetLocationEntryFocusable(true); |
| 251 | 255 |
| 252 location_entry_view_ = location_entry_->AddToView(this); | 256 location_entry_view_ = location_entry_->AddToView(this); |
| 253 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | 257 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
| 254 | 258 |
| 255 selected_keyword_view_ = new SelectedKeywordView( | 259 selected_keyword_view_ = new SelectedKeywordView( |
| 256 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 260 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
| 257 GetColor(ToolbarModel::NONE, TEXT), | 261 GetColor(ToolbarModel::NONE, TEXT), |
| 258 profile_); | 262 profile_); |
| 263 selected_keyword_view_->SetVisible(false); | |
| 264 selected_keyword_view_->SetFont(font_); | |
| 259 AddChildView(selected_keyword_view_); | 265 AddChildView(selected_keyword_view_); |
| 260 selected_keyword_view_->SetFont(font_); | |
| 261 selected_keyword_view_->SetVisible(false); | |
| 262 | 266 |
| 263 keyword_hint_view_ = new KeywordHintView(profile_, this); | 267 keyword_hint_view_ = new KeywordHintView(profile_, this); |
| 264 AddChildView(keyword_hint_view_); | |
| 265 keyword_hint_view_->SetVisible(false); | 268 keyword_hint_view_->SetVisible(false); |
| 266 keyword_hint_view_->SetFont(font_); | 269 keyword_hint_view_->SetFont(font_); |
| 270 AddChildView(keyword_hint_view_); | |
| 271 | |
| 272 search_token_view_ = new views::Label(string16(), font_); | |
| 273 search_token_view_->SetAutoColorReadabilityEnabled(false); | |
| 274 search_token_view_->SetVisible(false); | |
| 275 AddChildView(search_token_view_); | |
| 276 search_token_separator_view_ = new LocationBarSeparatorView(); | |
| 277 search_token_separator_view_->SetVisible(false); | |
| 278 AddChildView(search_token_separator_view_); | |
| 267 | 279 |
| 268 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 280 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 269 ContentSettingImageView* content_blocked_view = | 281 ContentSettingImageView* content_blocked_view = |
| 270 new ContentSettingImageView(static_cast<ContentSettingsType>(i), | 282 new ContentSettingImageView(static_cast<ContentSettingsType>(i), |
| 271 kCSBubbleBackgroundImages, this, | 283 kCSBubbleBackgroundImages, this, |
| 272 font_, | 284 font_, |
| 273 GetColor(ToolbarModel::NONE, TEXT)); | 285 GetColor(ToolbarModel::NONE, TEXT)); |
| 274 content_setting_views_.push_back(content_blocked_view); | 286 content_setting_views_.push_back(content_blocked_view); |
| 287 content_blocked_view->SetVisible(false); | |
| 275 AddChildView(content_blocked_view); | 288 AddChildView(content_blocked_view); |
| 276 content_blocked_view->SetVisible(false); | |
| 277 } | 289 } |
| 278 | 290 |
| 279 zoom_view_ = new ZoomView(model_, delegate_); | 291 zoom_view_ = new ZoomView(model_, delegate_); |
| 280 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); | 292 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); |
| 281 AddChildView(zoom_view_); | 293 AddChildView(zoom_view_); |
| 282 | 294 |
| 283 web_intents_button_view_ = | 295 web_intents_button_view_ = |
| 284 new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_, | 296 new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_, |
| 285 GetColor(ToolbarModel::NONE, TEXT)); | 297 GetColor(ToolbarModel::NONE, TEXT)); |
| 286 AddChildView(web_intents_button_view_); | 298 AddChildView(web_intents_button_view_); |
| 287 | 299 |
| 288 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); | 300 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); |
| 289 AddChildView(open_pdf_in_reader_view_); | 301 AddChildView(open_pdf_in_reader_view_); |
| 290 | 302 |
| 291 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); | 303 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); |
| 304 script_bubble_icon_view_->SetVisible(false); | |
| 292 AddChildView(script_bubble_icon_view_); | 305 AddChildView(script_bubble_icon_view_); |
| 293 script_bubble_icon_view_->SetVisible(false); | |
| 294 | 306 |
| 295 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 307 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 296 // Note: condition above means that the star icon is hidden in popups and in | 308 // Note: condition above means that the star icon is hidden in popups and in |
| 297 // the app launcher. | 309 // the app launcher. |
| 298 star_view_ = new StarView(command_updater_); | 310 star_view_ = new StarView(command_updater_); |
| 311 star_view_->SetVisible(true); | |
| 299 AddChildView(star_view_); | 312 AddChildView(star_view_); |
| 300 star_view_->SetVisible(true); | |
| 301 } | 313 } |
| 302 if (extensions::FeatureSwitch::action_box()->IsEnabled() && | 314 if (extensions::FeatureSwitch::action_box()->IsEnabled() && |
| 303 mode_ == NORMAL && browser_) { | 315 mode_ == NORMAL && browser_) { |
| 316 if (star_view_) | |
| 317 star_view_->SetVisible(false); | |
| 318 | |
| 304 action_box_button_view_ = new ActionBoxButtonView(browser_, | 319 action_box_button_view_ = new ActionBoxButtonView(browser_, |
| 305 gfx::Point(kNormalHorizontalEdgeThickness, kVerticalEdgeThickness)); | 320 gfx::Point(kNormalHorizontalEdgeThickness, kVerticalEdgeThickness)); |
| 306 AddChildView(action_box_button_view_); | 321 AddChildView(action_box_button_view_); |
| 307 | |
| 308 if (star_view_) | |
| 309 star_view_->SetVisible(false); | |
| 310 } | 322 } |
| 311 | 323 |
| 312 registrar_.Add(this, | 324 registrar_.Add(this, |
| 313 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 325 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| 314 content::Source<Profile>(profile_)); | 326 content::Source<Profile>(profile_)); |
| 315 | 327 |
| 316 // Initialize the location entry. We do this to avoid a black flash which is | 328 // Initialize the location entry. We do this to avoid a black flash which is |
| 317 // visible when the location entry has just been initialized. | 329 // visible when the location entry has just been initialized. |
| 318 Update(NULL); | 330 Update(NULL); |
| 319 | 331 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 | 430 |
| 419 bool star_enabled = star_view_ && !model_->GetInputInProgress() && | 431 bool star_enabled = star_view_ && !model_->GetInputInProgress() && |
| 420 edit_bookmarks_enabled_.GetValue(); | 432 edit_bookmarks_enabled_.GetValue(); |
| 421 | 433 |
| 422 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 434 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 423 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, | 435 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, |
| 424 star_enabled); | 436 star_enabled); |
| 425 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) | 437 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) |
| 426 star_view_->SetVisible(star_enabled); | 438 star_view_->SetVisible(star_enabled); |
| 427 | 439 |
| 440 string16 search_provider; | |
| 441 if (!model_->GetInputInProgress() && | |
| 442 model_->WouldReplaceSearchURLWithSearchTerms()) { | |
| 443 const TemplateURL* template_url = | |
| 444 TemplateURLServiceFactory::GetForProfile(profile_)-> | |
| 445 GetDefaultSearchProvider(); | |
| 446 if (template_url && !template_url->short_name().empty()) { | |
| 447 search_provider = l10n_util::GetStringFUTF16( | |
| 448 IDS_OMNIBOX_SEARCH_TOKEN_TEXT, template_url->short_name()); | |
| 449 search_token_view_->SetBackgroundColor(GetColor( | |
| 450 model_->GetSecurityLevel(), LocationBarView::BACKGROUND)); | |
| 451 SkColor text_color = GetColor( | |
| 452 model_->GetSecurityLevel(), LocationBarView::DEEMPHASIZED_TEXT); | |
| 453 search_token_view_->SetEnabledColor(text_color); | |
| 454 search_token_separator_view_->set_separator_color( | |
| 455 SkColorSetA(text_color, 64)); // 25% alpha. | |
| 456 } | |
| 457 } | |
| 458 // If |search_provider| is empty, |search_token_view_| is hidden. | |
| 459 search_token_view_->SetText(search_provider); | |
| 460 | |
| 428 // Don't Update in app launcher mode so that the location entry does not show | 461 // Don't Update in app launcher mode so that the location entry does not show |
| 429 // a URL or security background. | 462 // a URL or security background. |
| 430 if (mode_ != APP_LAUNCHER) | 463 if (mode_ != APP_LAUNCHER) |
| 431 location_entry_->Update(tab_for_state_restoring); | 464 location_entry_->Update(tab_for_state_restoring); |
| 432 OnChanged(); | 465 OnChanged(); |
| 433 } | 466 } |
| 434 | 467 |
| 435 void LocationBarView::UpdateContentSettingsIcons() { | 468 void LocationBarView::UpdateContentSettingsIcons() { |
| 436 RefreshContentSettingViews(); | 469 RefreshContentSettingViews(); |
| 437 | 470 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 | 699 |
| 667 LocationBarLayout left_decorations(LocationBarLayout::LEFT_EDGE, | 700 LocationBarLayout left_decorations(LocationBarLayout::LEFT_EDGE, |
| 668 kItemEditPadding, kEdgeEditPadding); | 701 kItemEditPadding, kEdgeEditPadding); |
| 669 LocationBarLayout right_decorations(LocationBarLayout::RIGHT_EDGE, | 702 LocationBarLayout right_decorations(LocationBarLayout::RIGHT_EDGE, |
| 670 kItemEditPadding, kEdgeEditPadding); | 703 kItemEditPadding, kEdgeEditPadding); |
| 671 | 704 |
| 672 selected_keyword_view_->SetVisible(false); | 705 selected_keyword_view_->SetVisible(false); |
| 673 location_icon_view_->SetVisible(false); | 706 location_icon_view_->SetVisible(false); |
| 674 ev_bubble_view_->SetVisible(false); | 707 ev_bubble_view_->SetVisible(false); |
| 675 keyword_hint_view_->SetVisible(false); | 708 keyword_hint_view_->SetVisible(false); |
| 709 search_token_view_->SetVisible(false); | |
| 710 search_token_separator_view_->SetVisible(false); | |
| 676 | 711 |
| 677 const string16 keyword(location_entry_->model()->keyword()); | 712 const string16 keyword(location_entry_->model()->keyword()); |
| 678 const bool is_keyword_hint(location_entry_->model()->is_keyword_hint()); | 713 const bool is_keyword_hint(location_entry_->model()->is_keyword_hint()); |
| 679 const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint; | 714 const bool show_search_token = !search_token_view_->text().empty(); |
| 680 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; | 715 const bool show_selected_keyword = !keyword.empty() && !is_keyword_hint && |
| 716 !show_search_token; | |
| 717 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint && | |
| 718 !show_search_token; | |
| 681 if (show_selected_keyword) { | 719 if (show_selected_keyword) { |
| 682 left_decorations.AddDecoration( | 720 left_decorations.AddDecoration( |
| 683 kBubbleLocationY, 0, true, 0, kBubbleHorizontalPadding, | 721 kBubbleLocationY, 0, true, 0, kBubbleHorizontalPadding, |
| 684 GetItemPadding(), 0, selected_keyword_view_); | 722 GetItemPadding(), 0, selected_keyword_view_); |
| 685 if (selected_keyword_view_->keyword() != keyword) { | 723 if (selected_keyword_view_->keyword() != keyword) { |
| 686 selected_keyword_view_->SetKeyword(keyword); | 724 selected_keyword_view_->SetKeyword(keyword); |
| 687 const TemplateURL* template_url = | 725 const TemplateURL* template_url = |
| 688 TemplateURLServiceFactory::GetForProfile(profile_)-> | 726 TemplateURLServiceFactory::GetForProfile(profile_)-> |
| 689 GetTemplateURLForKeyword(keyword); | 727 GetTemplateURLForKeyword(keyword); |
| 690 if (template_url && template_url->IsExtensionKeyword()) { | 728 if (template_url && template_url->IsExtensionKeyword()) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 756 web_intents_button_view_->GetBuiltInHorizontalPadding(), | 794 web_intents_button_view_->GetBuiltInHorizontalPadding(), |
| 757 web_intents_button_view_); | 795 web_intents_button_view_); |
| 758 } | 796 } |
| 759 if (show_keyword_hint) { | 797 if (show_keyword_hint) { |
| 760 right_decorations.AddDecoration( | 798 right_decorations.AddDecoration( |
| 761 kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(), | 799 kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(), |
| 762 GetItemPadding(), 0, keyword_hint_view_); | 800 GetItemPadding(), 0, keyword_hint_view_); |
| 763 if (keyword_hint_view_->keyword() != keyword) | 801 if (keyword_hint_view_->keyword() != keyword) |
| 764 keyword_hint_view_->SetKeyword(keyword); | 802 keyword_hint_view_->SetKeyword(keyword); |
| 765 } | 803 } |
| 804 if (show_search_token) { | |
| 805 right_decorations.AddSeparator(kVerticalEdgeThickness, location_height, | |
| 806 GetItemPadding(), search_token_separator_view_); | |
| 807 // This must be the last item in the right decorations list, otherwise | |
| 808 // right_decorations.set_item_padding() makes no sense. | |
| 809 right_decorations.AddDecoration( | |
| 810 kVerticalEdgeThickness, location_height, true, 0, GetEdgeItemPadding(), | |
| 811 GetItemPadding() * 2, 0, search_token_view_); | |
| 812 right_decorations.set_item_edit_padding( | |
| 813 views::kUnrelatedControlLargeHorizontalSpacing); | |
| 814 } | |
| 766 | 815 |
| 767 // Perform layout. | 816 // Perform layout. |
| 768 int full_width = width() - 2 * kEdgeThickness; | 817 int full_width = width() - 2 * kEdgeThickness; |
| 769 int entry_width = full_width; | 818 int entry_width = full_width; |
| 770 left_decorations.LayoutPass1(&entry_width); | 819 left_decorations.LayoutPass1(&entry_width); |
| 771 right_decorations.LayoutPass1(&entry_width); | 820 right_decorations.LayoutPass1(&entry_width); |
| 772 left_decorations.LayoutPass2(&entry_width); | 821 left_decorations.LayoutPass2(&entry_width); |
| 773 right_decorations.LayoutPass2(&entry_width); | 822 right_decorations.LayoutPass2(&entry_width); |
| 774 | 823 |
| 775 int available_width = entry_width - location_entry_->TextWidth(); | 824 int available_width = entry_width - location_entry_->TextWidth(); |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1433 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1482 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1434 int total_height = | 1483 int total_height = |
| 1435 use_preferred_size ? GetPreferredSize().height() : height(); | 1484 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1436 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1485 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1437 } | 1486 } |
| 1438 | 1487 |
| 1439 bool LocationBarView::HasValidSuggestText() const { | 1488 bool LocationBarView::HasValidSuggestText() const { |
| 1440 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1489 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1441 !suggested_text_view_->text().empty(); | 1490 !suggested_text_view_->text().empty(); |
| 1442 } | 1491 } |
| OLD | NEW |