Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| index 791591665fdae7d0b9a0129b5018752ddbd1b455..3a38ff5049531344ab1bc56a2bf5ffe1b41acf13 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| @@ -162,28 +162,14 @@ void LocationBarView::Init() { |
| GetWidget()->GetNativeView(), profile_, command_updater_, |
| mode_ == POPUP, this)); |
| #else |
| - location_entry_.reset(new AutocompleteEditViewGtk(this, model_, profile_, |
| - command_updater_, mode_ == POPUP, this)); |
| - location_entry_->Init(); |
| - // Make all the children of the widget visible. NOTE: this won't display |
| - // anything, it just toggles the visible flag. |
| - gtk_widget_show_all(location_entry_->GetNativeView()); |
| - // Hide the widget. NativeViewHostGtk will make it visible again as |
| - // necessary. |
| - gtk_widget_hide(location_entry_->GetNativeView()); |
| - |
| - // Associate an accessible name with the location entry. |
| - accessible_widget_helper_.reset(new AccessibleWidgetHelper( |
| - location_entry_->text_view(), profile_)); |
| - accessible_widget_helper_->SetWidgetName( |
| - location_entry_->text_view(), |
| - l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION)); |
| + location_entry_.reset( |
| + AutocompleteEditViewGtk::Create( |
| + this, model_, profile_, |
| + command_updater_, mode_ == POPUP, this)); |
| #endif |
| - location_entry_view_ = new views::NativeViewHost; |
| + |
| + location_entry_view_ = location_entry_->AddToView(this); |
| location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE); |
| - AddChildView(location_entry_view_); |
| - location_entry_view_->set_focus_view(this); |
| - location_entry_view_->Attach(location_entry_->GetNativeView()); |
| location_entry_view_->SetAccessibleName( |
| l10n_util::GetString(IDS_ACCNAME_LOCATION)); |
| @@ -782,19 +768,14 @@ void LocationBarView::OnAutocompleteWillAccept() { |
| bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) { |
| InstantController* instant = delegate_->GetInstant(); |
| - if (!instant) |
| + if (!instant || !HasValidSuggestText()) |
| return false; |
| - |
| #if defined(OS_WIN) |
|
Peter Kasting
2011/01/06 02:06:48
Nit: While I like const locals, most Chrome code a
oshima
2011/01/06 19:43:35
Done.
|
| - if (!HasValidSuggestText()) |
| - return false; |
| - location_entry_->model()->FinalizeInstantQuery( |
| - typed_text, |
| - suggested_text_view_->GetText()); |
| - return true; |
| + const std::wstring suggestion = suggested_text_view_->GetText(); |
| #else |
| - return location_entry_->CommitInstantSuggestion(); |
| + const std::wstring suggestion; |
| #endif |
| + return location_entry_->CommitInstantSuggestion(typed_text, suggestion); |
| } |
| bool LocationBarView::AcceptCurrentInstantPreview() { |
| @@ -1169,7 +1150,7 @@ void LocationBarView::SetSuggestedText(const string16& input) { |
| Layout(); |
| SchedulePaint(); |
| #else |
| - location_entry_->SetInstantSuggestion(UTF16ToUTF8(input)); |
| + location_entry_->SetInstantSuggestion(input); |
| #endif |
| } |
| @@ -1263,9 +1244,11 @@ void LocationBarView::OnTemplateURLModelChanged() { |
| ShowFirstRunBubble(bubble_type_); |
| } |
| -#if defined(OS_WIN) |
| bool LocationBarView::HasValidSuggestText() { |
| +#if defined(OS_WIN) |
| return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| !suggested_text_view_->GetText().empty(); |
| -} |
| +#else |
| + return true; |
|
Peter Kasting
2011/01/06 02:06:48
Nit: Wouldn't it be better to call the Autocomplet
oshima
2011/01/06 19:43:35
Thank you for suggestion. Yes, i'm planning to ref
|
| #endif |
| +} |