| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "app/drag_drop_types.h" | 11 #include "app/drag_drop_types.h" |
| 12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
| 14 #include "app/theme_provider.h" | 14 #include "app/theme_provider.h" |
| 15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/app/chrome_command_ids.h" | 17 #include "chrome/app/chrome_command_ids.h" |
| 18 #include "chrome/browser/alternate_nav_url_fetcher.h" | 18 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 19 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 20 #include "chrome/browser/defaults.h" | 20 #include "chrome/browser/defaults.h" |
| 21 #include "chrome/browser/extensions/extension_browser_event_router.h" | 21 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 22 #include "chrome/browser/extensions/extensions_service.h" | 22 #include "chrome/browser/extensions/extensions_service.h" |
| 23 #include "chrome/browser/instant/instant_controller.h" | 23 #include "chrome/browser/instant/instant_controller.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 25 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 26 #include "chrome/browser/search_engines/template_url.h" | 26 #include "chrome/browser/search_engines/template_url.h" |
| 27 #include "chrome/browser/search_engines/template_url_model.h" | 27 #include "chrome/browser/search_engines/template_url_model.h" |
| 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 29 #include "chrome/browser/ui/view_ids.h" | 29 #include "chrome/browser/ui/view_ids.h" |
| 30 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" | |
| 31 #include "chrome/browser/ui/views/browser_dialogs.h" | 30 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 32 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 31 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 33 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 32 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 34 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 33 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 35 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 34 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 36 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 35 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 37 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 36 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 38 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 37 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| 39 #include "chrome/browser/ui/views/location_bar/star_view.h" | 38 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 40 #include "gfx/canvas_skia.h" | 39 #include "gfx/canvas_skia.h" |
| 41 #include "gfx/color_utils.h" | 40 #include "gfx/color_utils.h" |
| 42 #include "gfx/skia_util.h" | 41 #include "gfx/skia_util.h" |
| 43 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
| 44 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
| 45 #include "views/controls/label.h" | 44 #include "views/controls/label.h" |
| 46 #include "views/drag_utils.h" | 45 #include "views/drag_utils.h" |
| 47 | 46 |
| 48 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 48 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" |
| 49 #include "chrome/browser/views/first_run_bubble.h" | 49 #include "chrome/browser/views/first_run_bubble.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 using views::View; | 52 using views::View; |
| 53 | 53 |
| 54 namespace { | 54 namespace { |
| 55 TabContents* GetTabContentsFromDelegate(LocationBarView::Delegate* delegate) { | 55 TabContents* GetTabContentsFromDelegate(LocationBarView::Delegate* delegate) { |
| 56 const TabContentsWrapper* wrapper = delegate->GetTabContentsWrapper(); | 56 const TabContentsWrapper* wrapper = delegate->GetTabContentsWrapper(); |
| 57 return wrapper ? wrapper->tab_contents() : NULL; | 57 return wrapper ? wrapper->tab_contents() : NULL; |
| 58 } | 58 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 : profile_(profile), | 96 : profile_(profile), |
| 97 command_updater_(command_updater), | 97 command_updater_(command_updater), |
| 98 model_(model), | 98 model_(model), |
| 99 delegate_(delegate), | 99 delegate_(delegate), |
| 100 disposition_(CURRENT_TAB), | 100 disposition_(CURRENT_TAB), |
| 101 transition_(PageTransition::LINK), | 101 transition_(PageTransition::LINK), |
| 102 location_icon_view_(NULL), | 102 location_icon_view_(NULL), |
| 103 ev_bubble_view_(NULL), | 103 ev_bubble_view_(NULL), |
| 104 location_entry_view_(NULL), | 104 location_entry_view_(NULL), |
| 105 selected_keyword_view_(NULL), | 105 selected_keyword_view_(NULL), |
| 106 #if defined(OS_WIN) |
| 106 suggested_text_view_(NULL), | 107 suggested_text_view_(NULL), |
| 108 #endif |
| 107 keyword_hint_view_(NULL), | 109 keyword_hint_view_(NULL), |
| 108 star_view_(NULL), | 110 star_view_(NULL), |
| 109 mode_(mode), | 111 mode_(mode), |
| 110 show_focus_rect_(false), | 112 show_focus_rect_(false), |
| 111 bubble_type_(FirstRun::MINIMAL_BUBBLE), | 113 bubble_type_(FirstRun::MINIMAL_BUBBLE), |
| 112 template_url_model_(NULL), | 114 template_url_model_(NULL), |
| 113 update_instant_(true) { | 115 update_instant_(true) { |
| 114 DCHECK(profile_); | 116 DCHECK(profile_); |
| 115 SetID(VIEW_ID_LOCATION_BAR); | 117 SetID(VIEW_ID_LOCATION_BAR); |
| 116 SetFocusable(true); | 118 SetFocusable(true); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 gfx::Point origin(location_entry_view_->bounds().origin()); | 403 gfx::Point origin(location_entry_view_->bounds().origin()); |
| 402 // If the UI layout is RTL, the coordinate system is not transformed and | 404 // If the UI layout is RTL, the coordinate system is not transformed and |
| 403 // therefore we need to adjust the X coordinate so that bubble appears on the | 405 // therefore we need to adjust the X coordinate so that bubble appears on the |
| 404 // right hand side of the location bar. | 406 // right hand side of the location bar. |
| 405 if (base::i18n::IsRTL()) | 407 if (base::i18n::IsRTL()) |
| 406 origin.set_x(width() - origin.x()); | 408 origin.set_x(width() - origin.x()); |
| 407 views::View::ConvertPointToScreen(this, &origin); | 409 views::View::ConvertPointToScreen(this, &origin); |
| 408 return origin; | 410 return origin; |
| 409 } | 411 } |
| 410 | 412 |
| 413 #if defined(OS_WIN) |
| 411 void LocationBarView::OnCommitSuggestedText() { | 414 void LocationBarView::OnCommitSuggestedText() { |
| 412 InstantController* instant = delegate_->GetInstant(); | 415 InstantController* instant = delegate_->GetInstant(); |
| 413 DCHECK(instant); | 416 DCHECK(instant); |
| 414 DCHECK(suggested_text_view_); | 417 DCHECK(suggested_text_view_); |
| 415 OnCommitSuggestedText(location_entry_->GetText()); | 418 OnCommitSuggestedText(location_entry_->GetText()); |
| 416 } | 419 } |
| 420 #endif |
| 417 | 421 |
| 418 gfx::Size LocationBarView::GetPreferredSize() { | 422 gfx::Size LocationBarView::GetPreferredSize() { |
| 419 return gfx::Size(0, GetThemeProvider()->GetBitmapNamed(mode_ == POPUP ? | 423 return gfx::Size(0, GetThemeProvider()->GetBitmapNamed(mode_ == POPUP ? |
| 420 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); | 424 IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); |
| 421 } | 425 } |
| 422 | 426 |
| 423 void LocationBarView::Layout() { | 427 void LocationBarView::Layout() { |
| 424 if (!location_entry_.get()) | 428 if (!location_entry_.get()) |
| 425 return; | 429 return; |
| 426 | 430 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 // the added view. | 610 // the added view. |
| 607 location_bounds.Inset(0, 0, kEditInternalSpace, 0); | 611 location_bounds.Inset(0, 0, kEditInternalSpace, 0); |
| 608 LayoutView(keyword_hint_view_, kItemEditPadding, available_width, false, | 612 LayoutView(keyword_hint_view_, kItemEditPadding, available_width, false, |
| 609 &location_bounds); | 613 &location_bounds); |
| 610 if (!keyword_hint_view_->IsVisible()) { | 614 if (!keyword_hint_view_->IsVisible()) { |
| 611 // Put back the enlargement that we undid above. | 615 // Put back the enlargement that we undid above. |
| 612 location_bounds.Inset(0, 0, -kEditInternalSpace, 0); | 616 location_bounds.Inset(0, 0, -kEditInternalSpace, 0); |
| 613 } | 617 } |
| 614 } | 618 } |
| 615 | 619 |
| 620 #if defined(OS_WIN) |
| 616 // Layout out the suggested text view right aligned to the location | 621 // Layout out the suggested text view right aligned to the location |
| 617 // entry. Only show the suggested text if we can fit the text from one | 622 // entry. Only show the suggested text if we can fit the text from one |
| 618 // character before the end of the selection to the end of the text and the | 623 // character before the end of the selection to the end of the text and the |
| 619 // suggested text. If we can't it means either the suggested text is too big, | 624 // suggested text. If we can't it means either the suggested text is too big, |
| 620 // or the user has scrolled. | 625 // or the user has scrolled. |
| 621 | 626 |
| 622 // TODO(sky): We could potentially combine this with the previous step to | 627 // TODO(sky): We could potentially combine this with the previous step to |
| 623 // force using minimum size if necessary, but currently the chance of showing | 628 // force using minimum size if necessary, but currently the chance of showing |
| 624 // keyword hints and suggested text is minimal and we're not confident this | 629 // keyword hints and suggested text is minimal and we're not confident this |
| 625 // is the right approach for suggested text. | 630 // is the right approach for suggested text. |
| 626 if (suggested_text_view_) { | 631 if (suggested_text_view_) { |
| 627 // TODO(sky): need to layout when the user changes caret position. | 632 // TODO(sky): need to layout when the user changes caret position. |
| 628 int suggested_text_width = suggested_text_view_->GetPreferredSize().width(); | 633 int suggested_text_width = suggested_text_view_->GetPreferredSize().width(); |
| 629 int vis_text_width = location_entry_->WidthOfTextAfterCursor(); | 634 int vis_text_width = location_entry_->WidthOfTextAfterCursor(); |
| 630 if (vis_text_width + suggested_text_width > entry_width) { | 635 if (vis_text_width + suggested_text_width > entry_width) { |
| 631 // Hide the suggested text if the user has scrolled or we can't fit all | 636 // Hide the suggested text if the user has scrolled or we can't fit all |
| 632 // the suggested text. | 637 // the suggested text. |
| 633 suggested_text_view_->SetBounds(0, 0, 0, 0); | 638 suggested_text_view_->SetBounds(0, 0, 0, 0); |
| 634 } else { | 639 } else { |
| 635 int location_needed_width = location_entry_->TextWidth(); | 640 int location_needed_width = location_entry_->TextWidth(); |
| 636 location_bounds.set_width(std::min(location_needed_width, | 641 location_bounds.set_width(std::min(location_needed_width, |
| 637 entry_width - suggested_text_width)); | 642 entry_width - suggested_text_width)); |
| 638 // TODO(sky): figure out why this needs the -1. | 643 // TODO(sky): figure out why this needs the -1. |
| 639 suggested_text_view_->SetBounds(location_bounds.right() - 1, | 644 suggested_text_view_->SetBounds(location_bounds.right() - 1, |
| 640 location_bounds.y(), | 645 location_bounds.y(), |
| 641 suggested_text_width, | 646 suggested_text_width, |
| 642 location_bounds.height()); | 647 location_bounds.height()); |
| 643 } | 648 } |
| 644 } | 649 } |
| 650 #endif |
| 645 | 651 |
| 646 location_entry_view_->SetBounds(location_bounds); | 652 location_entry_view_->SetBounds(location_bounds); |
| 647 } | 653 } |
| 648 | 654 |
| 649 void LocationBarView::Paint(gfx::Canvas* canvas) { | 655 void LocationBarView::Paint(gfx::Canvas* canvas) { |
| 650 View::Paint(canvas); | 656 View::Paint(canvas); |
| 651 | 657 |
| 652 if (painter_.get()) { | 658 if (painter_.get()) { |
| 653 painter_->Paint(width(), height(), canvas); | 659 painter_->Paint(width(), height(), canvas); |
| 654 } else if (mode_ == POPUP) { | 660 } else if (mode_ == POPUP) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 if (instant) | 774 if (instant) |
| 769 instant->OnAutocompleteLostFocus(view_gaining_focus); | 775 instant->OnAutocompleteLostFocus(view_gaining_focus); |
| 770 } | 776 } |
| 771 | 777 |
| 772 void LocationBarView::OnAutocompleteWillAccept() { | 778 void LocationBarView::OnAutocompleteWillAccept() { |
| 773 update_instant_ = false; | 779 update_instant_ = false; |
| 774 } | 780 } |
| 775 | 781 |
| 776 bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) { | 782 bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) { |
| 777 InstantController* instant = delegate_->GetInstant(); | 783 InstantController* instant = delegate_->GetInstant(); |
| 778 if (!instant || !HasValidSuggestText()) { | 784 if (!instant) |
| 779 return false; | 785 return false; |
| 780 } | 786 |
| 787 #if defined(OS_WIN) |
| 788 if(!HasValidSuggestText()) |
| 789 return false; |
| 781 location_entry_->model()->FinalizeInstantQuery( | 790 location_entry_->model()->FinalizeInstantQuery( |
| 782 typed_text, | 791 typed_text, |
| 783 suggested_text_view_->GetText()); | 792 suggested_text_view_->GetText()); |
| 784 return true; | 793 return true; |
| 794 #else |
| 795 return location_entry_->CommitInstantSuggestion(); |
| 796 #endif |
| 785 } | 797 } |
| 786 | 798 |
| 787 void LocationBarView::OnSetSuggestedSearchText(const string16& suggested_text) { | 799 void LocationBarView::OnSetSuggestedSearchText(const string16& suggested_text) { |
| 788 SetSuggestedText(suggested_text); | 800 SetSuggestedText(suggested_text); |
| 789 } | 801 } |
| 790 | 802 |
| 791 void LocationBarView::OnPopupBoundsChanged(const gfx::Rect& bounds) { | 803 void LocationBarView::OnPopupBoundsChanged(const gfx::Rect& bounds) { |
| 792 InstantController* instant = delegate_->GetInstant(); | 804 InstantController* instant = delegate_->GetInstant(); |
| 793 if (instant) | 805 if (instant) |
| 794 instant->SetOmniboxBounds(bounds); | 806 instant->SetOmniboxBounds(bounds); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 instant->DestroyPreviewContents(); | 873 instant->DestroyPreviewContents(); |
| 862 location_entry_->model()->FinalizeInstantQuery(std::wstring(), | 874 location_entry_->model()->FinalizeInstantQuery(std::wstring(), |
| 863 std::wstring()); | 875 std::wstring()); |
| 864 } | 876 } |
| 865 } | 877 } |
| 866 | 878 |
| 867 SetSuggestedText(suggested_text); | 879 SetSuggestedText(suggested_text); |
| 868 } | 880 } |
| 869 | 881 |
| 870 void LocationBarView::OnSelectionBoundsChanged() { | 882 void LocationBarView::OnSelectionBoundsChanged() { |
| 883 #if defined(OS_WIN) |
| 871 if (suggested_text_view_) | 884 if (suggested_text_view_) |
| 872 suggested_text_view_->StopAnimation(); | 885 suggested_text_view_->StopAnimation(); |
| 886 #else |
| 887 NOTREACHED(); |
| 888 #endif |
| 873 } | 889 } |
| 874 | 890 |
| 875 void LocationBarView::OnInputInProgress(bool in_progress) { | 891 void LocationBarView::OnInputInProgress(bool in_progress) { |
| 876 delegate_->OnInputInProgress(in_progress); | 892 delegate_->OnInputInProgress(in_progress); |
| 877 } | 893 } |
| 878 | 894 |
| 879 void LocationBarView::OnKillFocus() { | 895 void LocationBarView::OnKillFocus() { |
| 880 } | 896 } |
| 881 | 897 |
| 882 void LocationBarView::OnSetFocus() { | 898 void LocationBarView::OnSetFocus() { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 BubbleBorder::TOP_LEFT, bubble_type); | 1055 BubbleBorder::TOP_LEFT, bubble_type); |
| 1040 #endif | 1056 #endif |
| 1041 } | 1057 } |
| 1042 | 1058 |
| 1043 std::string LocationBarView::GetClassName() const { | 1059 std::string LocationBarView::GetClassName() const { |
| 1044 return kViewClassName; | 1060 return kViewClassName; |
| 1045 } | 1061 } |
| 1046 | 1062 |
| 1047 bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { | 1063 bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { |
| 1048 if (views::FocusManager::IsTabTraversalKeyEvent(e)) { | 1064 if (views::FocusManager::IsTabTraversalKeyEvent(e)) { |
| 1065 #if defined(OS_WIN) |
| 1049 if (HasValidSuggestText()) { | 1066 if (HasValidSuggestText()) { |
| 1050 // Return true so that the edit sees the tab and commits the suggestion. | 1067 // Return true so that the edit sees the tab and commits the suggestion. |
| 1051 return true; | 1068 return true; |
| 1052 } | 1069 } |
| 1070 #endif |
| 1053 InstantController* instant = delegate_->GetInstant(); | 1071 InstantController* instant = delegate_->GetInstant(); |
| 1054 if (instant && instant->IsCurrent()) { | 1072 if (instant && instant->IsCurrent()) { |
| 1055 // Tab while showing instant commits instant immediately. | 1073 // Tab while showing instant commits instant immediately. |
| 1056 instant->CommitCurrentPreview(INSTANT_COMMIT_PRESSED_ENTER); | 1074 instant->CommitCurrentPreview(INSTANT_COMMIT_PRESSED_ENTER); |
| 1057 // Return true so that focus traversal isn't attempted. The edit ends | 1075 // Return true so that focus traversal isn't attempted. The edit ends |
| 1058 // up doing nothing in this case. | 1076 // up doing nothing in this case. |
| 1059 return true; | 1077 return true; |
| 1060 } | 1078 } |
| 1061 if (keyword_hint_view_->IsVisible() && !e.IsShiftDown()) { | 1079 if (keyword_hint_view_->IsVisible() && !e.IsShiftDown()) { |
| 1062 // Return true so the edit gets the tab event and enters keyword mode. | 1080 // Return true so the edit gets the tab event and enters keyword mode. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 bubble_type_ = bubble_type; | 1138 bubble_type_ = bubble_type; |
| 1121 template_url_model_ = profile_->GetTemplateURLModel(); | 1139 template_url_model_ = profile_->GetTemplateURLModel(); |
| 1122 template_url_model_->AddObserver(this); | 1140 template_url_model_->AddObserver(this); |
| 1123 template_url_model_->Load(); | 1141 template_url_model_->Load(); |
| 1124 return; | 1142 return; |
| 1125 } | 1143 } |
| 1126 ShowFirstRunBubbleInternal(bubble_type); | 1144 ShowFirstRunBubbleInternal(bubble_type); |
| 1127 } | 1145 } |
| 1128 | 1146 |
| 1129 void LocationBarView::SetSuggestedText(const string16& input) { | 1147 void LocationBarView::SetSuggestedText(const string16& input) { |
| 1148 #if defined(OS_WIN) |
| 1130 // Don't show the suggested text if inline autocomplete is prevented. | 1149 // Don't show the suggested text if inline autocomplete is prevented. |
| 1131 string16 text = location_entry_->model()->UseVerbatimInstant() ? | 1150 string16 text = location_entry_->model()->UseVerbatimInstant() ? |
| 1132 string16() : input; | 1151 string16() : input; |
| 1133 if (!text.empty()) { | 1152 if (!text.empty()) { |
| 1134 if (!suggested_text_view_) { | 1153 if (!suggested_text_view_) { |
| 1135 suggested_text_view_ = new SuggestedTextView(this); | 1154 suggested_text_view_ = new SuggestedTextView(this); |
| 1136 suggested_text_view_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 1155 suggested_text_view_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 1137 suggested_text_view_->SetColor( | 1156 suggested_text_view_->SetColor( |
| 1138 GetColor(ToolbarModel::NONE, | 1157 GetColor(ToolbarModel::NONE, |
| 1139 LocationBarView::DEEMPHASIZED_TEXT)); | 1158 LocationBarView::DEEMPHASIZED_TEXT)); |
| 1140 suggested_text_view_->SetText(UTF16ToWide(text)); | 1159 suggested_text_view_->SetText(UTF16ToWide(text)); |
| 1141 suggested_text_view_->SetFont(location_entry_->GetFont()); | 1160 suggested_text_view_->SetFont(location_entry_->GetFont()); |
| 1142 AddChildView(suggested_text_view_); | 1161 AddChildView(suggested_text_view_); |
| 1143 } else if (suggested_text_view_->GetText() != UTF16ToWide(text)) { | 1162 } else if (suggested_text_view_->GetText() != UTF16ToWide(text)) { |
| 1144 suggested_text_view_->SetText(UTF16ToWide(text)); | 1163 suggested_text_view_->SetText(UTF16ToWide(text)); |
| 1145 } | 1164 } |
| 1146 suggested_text_view_->StartAnimation(); | 1165 suggested_text_view_->StartAnimation(); |
| 1147 } else if (suggested_text_view_) { | 1166 } else if (suggested_text_view_) { |
| 1148 delete suggested_text_view_; | 1167 delete suggested_text_view_; |
| 1149 suggested_text_view_ = NULL; | 1168 suggested_text_view_ = NULL; |
| 1150 } else { | 1169 } else { |
| 1151 return; | 1170 return; |
| 1152 } | 1171 } |
| 1153 | 1172 |
| 1154 Layout(); | 1173 Layout(); |
| 1155 SchedulePaint(); | 1174 SchedulePaint(); |
| 1175 #else |
| 1176 location_entry_->SetInstantSuggestion(UTF16ToUTF8(input)); |
| 1177 #endif |
| 1156 } | 1178 } |
| 1157 | 1179 |
| 1158 std::wstring LocationBarView::GetInputString() const { | 1180 std::wstring LocationBarView::GetInputString() const { |
| 1159 return location_input_; | 1181 return location_input_; |
| 1160 } | 1182 } |
| 1161 | 1183 |
| 1162 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { | 1184 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { |
| 1163 return disposition_; | 1185 return disposition_; |
| 1164 } | 1186 } |
| 1165 | 1187 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 1260 |
| 1239 NOTREACHED(); | 1261 NOTREACHED(); |
| 1240 } | 1262 } |
| 1241 | 1263 |
| 1242 void LocationBarView::OnTemplateURLModelChanged() { | 1264 void LocationBarView::OnTemplateURLModelChanged() { |
| 1243 template_url_model_->RemoveObserver(this); | 1265 template_url_model_->RemoveObserver(this); |
| 1244 template_url_model_ = NULL; | 1266 template_url_model_ = NULL; |
| 1245 ShowFirstRunBubble(bubble_type_); | 1267 ShowFirstRunBubble(bubble_type_); |
| 1246 } | 1268 } |
| 1247 | 1269 |
| 1270 #if defined(OS_WIN) |
| 1248 bool LocationBarView::HasValidSuggestText() { | 1271 bool LocationBarView::HasValidSuggestText() { |
| 1249 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1272 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1250 !suggested_text_view_->GetText().empty(); | 1273 !suggested_text_view_->GetText().empty(); |
| 1251 } | 1274 } |
| 1275 #endif |
| OLD | NEW |