| 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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/ui/views/browser_dialogs.h" | 41 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 43 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 43 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 44 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" | 44 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" |
| 45 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 45 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 46 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 46 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
| 47 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 47 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 48 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | 48 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
| 49 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 49 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 50 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 50 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 51 #include "chrome/browser/ui/views/location_bar/search_button.h" | |
| 52 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 51 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| 53 #include "chrome/browser/ui/views/location_bar/star_view.h" | 52 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 54 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" | 53 #include "chrome/browser/ui/views/location_bar/translate_icon_view.h" |
| 55 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 54 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 56 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 55 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| 57 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 56 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| 58 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 57 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
| 59 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 58 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 60 #include "chrome/common/pref_names.h" | 59 #include "chrome/common/pref_names.h" |
| 61 #include "chrome/grit/generated_resources.h" | 60 #include "chrome/grit/generated_resources.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 94 |
| 96 #if !defined(OS_CHROMEOS) | 95 #if !defined(OS_CHROMEOS) |
| 97 #include "chrome/browser/ui/views/first_run_bubble.h" | 96 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 98 #endif | 97 #endif |
| 99 | 98 |
| 100 using content::WebContents; | 99 using content::WebContents; |
| 101 using views::View; | 100 using views::View; |
| 102 | 101 |
| 103 namespace { | 102 namespace { |
| 104 | 103 |
| 105 // The search button images are made to look as if they overlay the normal edge | |
| 106 // images, but to align things, the search button needs to be inset horizontally | |
| 107 // by 1 px. | |
| 108 const int kSearchButtonInset = 1; | |
| 109 | |
| 110 int GetEditLeadingInternalSpace() { | 104 int GetEditLeadingInternalSpace() { |
| 111 // The textfield has 1 px of whitespace before the text in the RTL case only. | 105 // The textfield has 1 px of whitespace before the text in the RTL case only. |
| 112 return base::i18n::IsRTL() ? 1 : 0; | 106 return base::i18n::IsRTL() ? 1 : 0; |
| 113 } | 107 } |
| 114 | 108 |
| 115 // Functor for moving BookmarkManagerPrivate page actions to the right via | 109 // Functor for moving BookmarkManagerPrivate page actions to the right via |
| 116 // stable_partition. | 110 // stable_partition. |
| 117 class IsPageActionViewRightAligned { | 111 class IsPageActionViewRightAligned { |
| 118 public: | 112 public: |
| 119 explicit IsPageActionViewRightAligned( | 113 explicit IsPageActionViewRightAligned( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 selected_keyword_view_(NULL), | 157 selected_keyword_view_(NULL), |
| 164 suggested_text_view_(NULL), | 158 suggested_text_view_(NULL), |
| 165 keyword_hint_view_(NULL), | 159 keyword_hint_view_(NULL), |
| 166 mic_search_view_(NULL), | 160 mic_search_view_(NULL), |
| 167 zoom_view_(NULL), | 161 zoom_view_(NULL), |
| 168 generated_credit_card_view_(NULL), | 162 generated_credit_card_view_(NULL), |
| 169 open_pdf_in_reader_view_(NULL), | 163 open_pdf_in_reader_view_(NULL), |
| 170 manage_passwords_icon_view_(NULL), | 164 manage_passwords_icon_view_(NULL), |
| 171 translate_icon_view_(NULL), | 165 translate_icon_view_(NULL), |
| 172 star_view_(NULL), | 166 star_view_(NULL), |
| 173 search_button_(NULL), | |
| 174 is_popup_mode_(is_popup_mode), | 167 is_popup_mode_(is_popup_mode), |
| 175 show_focus_rect_(false), | 168 show_focus_rect_(false), |
| 176 template_url_service_(NULL), | 169 template_url_service_(NULL), |
| 177 dropdown_animation_offset_(0), | 170 dropdown_animation_offset_(0), |
| 178 web_contents_null_at_last_refresh_(true) { | 171 web_contents_null_at_last_refresh_(true) { |
| 179 edit_bookmarks_enabled_.Init( | 172 edit_bookmarks_enabled_.Init( |
| 180 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 173 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 181 base::Bind(&LocationBarView::Update, base::Unretained(this), | 174 base::Bind(&LocationBarView::Update, base::Unretained(this), |
| 182 static_cast<content::WebContents*>(NULL))); | 175 static_cast<content::WebContents*>(NULL))); |
| 183 | 176 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 AddChildView(manage_passwords_icon_view_); | 316 AddChildView(manage_passwords_icon_view_); |
| 324 | 317 |
| 325 translate_icon_view_ = new TranslateIconView(command_updater()); | 318 translate_icon_view_ = new TranslateIconView(command_updater()); |
| 326 translate_icon_view_->SetVisible(false); | 319 translate_icon_view_->SetVisible(false); |
| 327 AddChildView(translate_icon_view_); | 320 AddChildView(translate_icon_view_); |
| 328 | 321 |
| 329 star_view_ = new StarView(command_updater(), browser_); | 322 star_view_ = new StarView(command_updater(), browser_); |
| 330 star_view_->SetVisible(false); | 323 star_view_->SetVisible(false); |
| 331 AddChildView(star_view_); | 324 AddChildView(star_view_); |
| 332 | 325 |
| 333 search_button_ = new SearchButton(this); | |
| 334 search_button_->SetVisible(false); | |
| 335 AddChildView(search_button_); | |
| 336 | |
| 337 // Initialize the location entry. We do this to avoid a black flash which is | 326 // Initialize the location entry. We do this to avoid a black flash which is |
| 338 // visible when the location entry has just been initialized. | 327 // visible when the location entry has just been initialized. |
| 339 Update(NULL); | 328 Update(NULL); |
| 340 } | 329 } |
| 341 | 330 |
| 342 bool LocationBarView::IsInitialized() const { | 331 bool LocationBarView::IsInitialized() const { |
| 343 return omnibox_view_ != NULL; | 332 return omnibox_view_ != NULL; |
| 344 } | 333 } |
| 345 | 334 |
| 346 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, | 335 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 541 |
| 553 void LocationBarView::GetAccessibleState(ui::AXViewState* state) { | 542 void LocationBarView::GetAccessibleState(ui::AXViewState* state) { |
| 554 state->role = ui::AX_ROLE_GROUP; | 543 state->role = ui::AX_ROLE_GROUP; |
| 555 } | 544 } |
| 556 | 545 |
| 557 gfx::Size LocationBarView::GetPreferredSize() const { | 546 gfx::Size LocationBarView::GetPreferredSize() const { |
| 558 // Compute minimum height. | 547 // Compute minimum height. |
| 559 gfx::Size min_size(border_painter_->GetMinimumSize()); | 548 gfx::Size min_size(border_painter_->GetMinimumSize()); |
| 560 if (!IsInitialized()) | 549 if (!IsInitialized()) |
| 561 return min_size; | 550 return min_size; |
| 562 gfx::Size search_button_min_size(search_button_->GetMinimumSize()); | |
| 563 min_size.SetToMax(search_button_min_size); | |
| 564 | 551 |
| 565 // Compute width of omnibox-leading content. | 552 // Compute width of omnibox-leading content. |
| 566 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); | 553 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
| 567 int leading_width = horizontal_edge_thickness; | 554 int leading_width = horizontal_edge_thickness; |
| 568 if (ShouldShowKeywordBubble()) { | 555 if (ShouldShowKeywordBubble()) { |
| 569 // The selected keyword view can collapse completely. | 556 // The selected keyword view can collapse completely. |
| 570 } else if (ShouldShowEVBubble()) { | 557 } else if (ShouldShowEVBubble()) { |
| 571 leading_width += kBubblePadding + | 558 leading_width += kBubblePadding + |
| 572 ev_bubble_view_->GetMinimumSizeForLabelText( | 559 ev_bubble_view_->GetMinimumSizeForLabelText( |
| 573 GetToolbarModel()->GetEVCertName()).width(); | 560 GetToolbarModel()->GetEVCertName()).width(); |
| 574 } else { | 561 } else { |
| 575 leading_width += | 562 leading_width += |
| 576 kItemPadding + location_icon_view_->GetMinimumSize().width(); | 563 kItemPadding + location_icon_view_->GetMinimumSize().width(); |
| 577 } | 564 } |
| 578 | 565 |
| 579 // Compute width of omnibox-trailing content. | 566 // Compute width of omnibox-trailing content. |
| 580 int trailing_width = search_button_->visible() ? | 567 int trailing_width = horizontal_edge_thickness; |
| 581 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : | |
| 582 horizontal_edge_thickness; | |
| 583 trailing_width += IncrementalMinimumWidth(star_view_) + | 568 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 584 IncrementalMinimumWidth(translate_icon_view_) + | 569 IncrementalMinimumWidth(translate_icon_view_) + |
| 585 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | 570 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| 586 IncrementalMinimumWidth(manage_passwords_icon_view_) + | 571 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| 587 IncrementalMinimumWidth(zoom_view_) + | 572 IncrementalMinimumWidth(zoom_view_) + |
| 588 IncrementalMinimumWidth(generated_credit_card_view_) + | 573 IncrementalMinimumWidth(generated_credit_card_view_) + |
| 589 IncrementalMinimumWidth(mic_search_view_); | 574 IncrementalMinimumWidth(mic_search_view_); |
| 590 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 575 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 591 i != page_action_views_.end(); ++i) | 576 i != page_action_views_.end(); ++i) |
| 592 trailing_width += IncrementalMinimumWidth((*i)); | 577 trailing_width += IncrementalMinimumWidth((*i)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 location_height, true, 0, kItemPadding, | 697 location_height, true, 0, kItemPadding, |
| 713 kItemPadding, keyword_hint_view_); | 698 kItemPadding, keyword_hint_view_); |
| 714 if (keyword_hint_view_->keyword() != keyword) | 699 if (keyword_hint_view_->keyword() != keyword) |
| 715 keyword_hint_view_->SetKeyword(keyword); | 700 keyword_hint_view_->SetKeyword(keyword); |
| 716 } | 701 } |
| 717 | 702 |
| 718 // Perform layout. | 703 // Perform layout. |
| 719 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); | 704 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
| 720 int full_width = width() - horizontal_edge_thickness; | 705 int full_width = width() - horizontal_edge_thickness; |
| 721 | 706 |
| 722 const gfx::Size search_button_size(search_button_->GetPreferredSize()); | 707 full_width -= horizontal_edge_thickness; |
| 723 const int search_button_reserved_width = | |
| 724 search_button_size.width() + kSearchButtonInset; | |
| 725 full_width -= search_button_->visible() ? | |
| 726 search_button_reserved_width : horizontal_edge_thickness; | |
| 727 int entry_width = full_width; | 708 int entry_width = full_width; |
| 728 leading_decorations.LayoutPass1(&entry_width); | 709 leading_decorations.LayoutPass1(&entry_width); |
| 729 trailing_decorations.LayoutPass1(&entry_width); | 710 trailing_decorations.LayoutPass1(&entry_width); |
| 730 leading_decorations.LayoutPass2(&entry_width); | 711 leading_decorations.LayoutPass2(&entry_width); |
| 731 trailing_decorations.LayoutPass2(&entry_width); | 712 trailing_decorations.LayoutPass2(&entry_width); |
| 732 | 713 |
| 733 int location_needed_width = omnibox_view_->GetTextWidth(); | 714 int location_needed_width = omnibox_view_->GetTextWidth(); |
| 734 int available_width = entry_width - location_needed_width; | 715 int available_width = entry_width - location_needed_width; |
| 735 // The bounds must be wide enough for all the decorations to fit. | 716 // The bounds must be wide enough for all the decorations to fit. |
| 736 gfx::Rect location_bounds( | 717 gfx::Rect location_bounds( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 x = 0; | 791 x = 0; |
| 811 else if (location_needed_width + width > entry_width) | 792 else if (location_needed_width + width > entry_width) |
| 812 x = entry_width - width; | 793 x = entry_width - width; |
| 813 location_bounds.set_width(x); | 794 location_bounds.set_width(x); |
| 814 ime_inline_autocomplete_view_->SetBounds( | 795 ime_inline_autocomplete_view_->SetBounds( |
| 815 location_bounds.right(), location_bounds.y(), | 796 location_bounds.right(), location_bounds.y(), |
| 816 std::min(width, entry_width), location_bounds.height()); | 797 std::min(width, entry_width), location_bounds.height()); |
| 817 } | 798 } |
| 818 | 799 |
| 819 omnibox_view_->SetBoundsRect(location_bounds); | 800 omnibox_view_->SetBoundsRect(location_bounds); |
| 820 | |
| 821 search_button_->SetBoundsRect(gfx::Rect( | |
| 822 gfx::Point(width() - search_button_reserved_width, 0), | |
| 823 search_button_size)); | |
| 824 } | 801 } |
| 825 | 802 |
| 826 //////////////////////////////////////////////////////////////////////////////// | 803 //////////////////////////////////////////////////////////////////////////////// |
| 827 // LocationBarView, public OmniboxEditController implementation: | 804 // LocationBarView, public OmniboxEditController implementation: |
| 828 | 805 |
| 829 void LocationBarView::Update(const WebContents* contents) { | 806 void LocationBarView::Update(const WebContents* contents) { |
| 830 mic_search_view_->SetVisible( | 807 mic_search_view_->SetVisible( |
| 831 !GetToolbarModel()->input_in_progress() && browser_ && | 808 !GetToolbarModel()->input_in_progress() && browser_ && |
| 832 browser_->search_model()->voice_search_supported()); | 809 browser_->search_model()->voice_search_supported()); |
| 833 RefreshContentSettingViews(); | 810 RefreshContentSettingViews(); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); | 1243 canvas->DrawRoundRect(bounds, kBorderCornerRadius, paint); |
| 1267 } | 1244 } |
| 1268 | 1245 |
| 1269 // The border itself will be drawn in PaintChildren() since it includes an | 1246 // The border itself will be drawn in PaintChildren() since it includes an |
| 1270 // inner shadow which should be drawn over the contents. | 1247 // inner shadow which should be drawn over the contents. |
| 1271 } | 1248 } |
| 1272 | 1249 |
| 1273 void LocationBarView::PaintChildren(gfx::Canvas* canvas, | 1250 void LocationBarView::PaintChildren(gfx::Canvas* canvas, |
| 1274 const views::CullSet& cull_set) { | 1251 const views::CullSet& cull_set) { |
| 1275 // Paint all the children except for the omnibox itself, which may need to be | 1252 // Paint all the children except for the omnibox itself, which may need to be |
| 1276 // clipped if it's animating in, and the search button, which will be painted | 1253 // clipped if it's animating in. |
| 1277 // after the border. | |
| 1278 for (int i = 0, count = child_count(); i < count; ++i) { | 1254 for (int i = 0, count = child_count(); i < count; ++i) { |
| 1279 views::View* child = child_at(i); | 1255 views::View* child = child_at(i); |
| 1280 if (!child->layer() && (child != omnibox_view_) && | 1256 if (!child->layer() && (child != omnibox_view_)) |
| 1281 (child != search_button_)) | |
| 1282 child->Paint(canvas, cull_set); | 1257 child->Paint(canvas, cull_set); |
| 1283 } | 1258 } |
| 1284 | 1259 |
| 1285 { | 1260 { |
| 1286 gfx::ScopedCanvas scoped_canvas(canvas); | 1261 gfx::ScopedCanvas scoped_canvas(canvas); |
| 1287 omnibox_view_->Paint(canvas, cull_set); | 1262 omnibox_view_->Paint(canvas, cull_set); |
| 1288 } | 1263 } |
| 1289 | 1264 |
| 1290 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need | 1265 // For non-InstantExtendedAPI cases, if necessary, show focus rect. As we need |
| 1291 // the focus rect to appear on top of children we paint here rather than | 1266 // the focus rect to appear on top of children we paint here rather than |
| 1292 // OnPaint(). | 1267 // OnPaint(). |
| 1293 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. | 1268 // Note: |Canvas::DrawFocusRect| paints a dashed rect with gray color. |
| 1294 if (show_focus_rect_ && HasFocus()) | 1269 if (show_focus_rect_ && HasFocus()) |
| 1295 canvas->DrawFocusRect(omnibox_view_->bounds()); | 1270 canvas->DrawFocusRect(omnibox_view_->bounds()); |
| 1296 | 1271 |
| 1297 // Maximized popup windows don't draw the horizontal edges. We implement this | 1272 // Maximized popup windows don't draw the horizontal edges. We implement this |
| 1298 // by simply expanding the paint area outside the view by the edge thickness. | 1273 // by simply expanding the paint area outside the view by the edge thickness. |
| 1299 gfx::Rect border_rect(GetContentsBounds()); | 1274 gfx::Rect border_rect(GetContentsBounds()); |
| 1300 if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) | 1275 if (is_popup_mode_ && (GetHorizontalEdgeThickness() == 0)) |
| 1301 border_rect.Inset(-kPopupEdgeThickness, 0); | 1276 border_rect.Inset(-kPopupEdgeThickness, 0); |
| 1302 views::Painter::PaintPainterAt(canvas, border_painter_.get(), border_rect); | 1277 views::Painter::PaintPainterAt(canvas, border_painter_.get(), border_rect); |
| 1303 | |
| 1304 // The search button must be painted after the border so that the border | |
| 1305 // shadow is not drawn over them. | |
| 1306 search_button_->Paint(canvas, cull_set); | |
| 1307 } | 1278 } |
| 1308 | 1279 |
| 1309 //////////////////////////////////////////////////////////////////////////////// | 1280 //////////////////////////////////////////////////////////////////////////////// |
| 1310 // LocationBarView, private views::ButtonListener implementation: | 1281 // LocationBarView, private views::ButtonListener implementation: |
| 1311 | 1282 |
| 1312 void LocationBarView::ButtonPressed(views::Button* sender, | 1283 void LocationBarView::ButtonPressed(views::Button* sender, |
| 1313 const ui::Event& event) { | 1284 const ui::Event& event) { |
| 1314 if (sender == mic_search_view_) { | 1285 DCHECK_EQ(mic_search_view_, sender); |
| 1315 command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); | 1286 command_updater()->ExecuteCommand(IDC_TOGGLE_SPEECH_INPUT); |
| 1316 return; | |
| 1317 } | |
| 1318 | |
| 1319 DCHECK_EQ(search_button_, sender); | |
| 1320 // TODO(pkasting): When macourteau adds UMA stats for this, wire them up here. | |
| 1321 omnibox_view_->model()->AcceptInput( | |
| 1322 ui::DispositionFromEventFlags(event.flags()), false); | |
| 1323 } | 1287 } |
| 1324 | 1288 |
| 1325 //////////////////////////////////////////////////////////////////////////////// | 1289 //////////////////////////////////////////////////////////////////////////////// |
| 1326 // LocationBarView, private views::DragController implementation: | 1290 // LocationBarView, private views::DragController implementation: |
| 1327 | 1291 |
| 1328 void LocationBarView::WriteDragDataForView(views::View* sender, | 1292 void LocationBarView::WriteDragDataForView(views::View* sender, |
| 1329 const gfx::Point& press_pt, | 1293 const gfx::Point& press_pt, |
| 1330 OSExchangeData* data) { | 1294 OSExchangeData* data) { |
| 1331 DCHECK_NE(GetDragOperationsForView(sender, press_pt), | 1295 DCHECK_NE(GetDragOperationsForView(sender, press_pt), |
| 1332 ui::DragDropTypes::DRAG_NONE); | 1296 ui::DragDropTypes::DRAG_NONE); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1360 } | 1324 } |
| 1361 | 1325 |
| 1362 //////////////////////////////////////////////////////////////////////////////// | 1326 //////////////////////////////////////////////////////////////////////////////// |
| 1363 // LocationBarView, private OmniboxEditController implementation: | 1327 // LocationBarView, private OmniboxEditController implementation: |
| 1364 | 1328 |
| 1365 void LocationBarView::OnChanged() { | 1329 void LocationBarView::OnChanged() { |
| 1366 int icon_id = omnibox_view_->GetIcon(); | 1330 int icon_id = omnibox_view_->GetIcon(); |
| 1367 location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); | 1331 location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); |
| 1368 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); | 1332 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); |
| 1369 | 1333 |
| 1370 ToolbarModel* toolbar_model = GetToolbarModel(); | |
| 1371 chrome::DisplaySearchButtonConditions conditions = | |
| 1372 chrome::GetDisplaySearchButtonConditions(); | |
| 1373 bool meets_conditions = | |
| 1374 (conditions == chrome::DISPLAY_SEARCH_BUTTON_ALWAYS) || | |
| 1375 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && | |
| 1376 (toolbar_model->WouldPerformSearchTermReplacement(true) || | |
| 1377 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && | |
| 1378 toolbar_model->input_in_progress()))); | |
| 1379 search_button_->SetVisible(!is_popup_mode_ && meets_conditions); | |
| 1380 search_button_->UpdateIcon(icon_id == IDR_OMNIBOX_SEARCH); | |
| 1381 | |
| 1382 Layout(); | 1334 Layout(); |
| 1383 SchedulePaint(); | 1335 SchedulePaint(); |
| 1384 } | 1336 } |
| 1385 | 1337 |
| 1386 void LocationBarView::OnSetFocus() { | 1338 void LocationBarView::OnSetFocus() { |
| 1387 GetFocusManager()->SetFocusedView(this); | 1339 GetFocusManager()->SetFocusedView(this); |
| 1388 } | 1340 } |
| 1389 | 1341 |
| 1390 InstantController* LocationBarView::GetInstant() { | 1342 InstantController* LocationBarView::GetInstant() { |
| 1391 return delegate_->GetInstant(); | 1343 return delegate_->GetInstant(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 | 1375 |
| 1424 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1376 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1425 const SearchModel::State& new_state) { | 1377 const SearchModel::State& new_state) { |
| 1426 const bool visible = !GetToolbarModel()->input_in_progress() && | 1378 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1427 new_state.voice_search_supported; | 1379 new_state.voice_search_supported; |
| 1428 if (mic_search_view_->visible() != visible) { | 1380 if (mic_search_view_->visible() != visible) { |
| 1429 mic_search_view_->SetVisible(visible); | 1381 mic_search_view_->SetVisible(visible); |
| 1430 Layout(); | 1382 Layout(); |
| 1431 } | 1383 } |
| 1432 } | 1384 } |
| OLD | NEW |