Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
index 44a6e1ae928ea5d0d20920314ef45b40fde28138..9c953a03251df40f7520118b18bca068f07fd6b7 100644 |
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
@@ -439,14 +439,12 @@ OmniboxViewWin::OmniboxViewWin(OmniboxEditController* controller, |
bool popup_window_mode, |
views::View* location_bar, |
views::View* popup_parent_view) |
- : model_(new OmniboxEditModel(this, controller, parent_view->profile())), |
+ : OmniboxView(parent_view->profile(), controller, toolbar_model, |
+ command_updater), |
popup_view_(OmniboxPopupContentsView::Create( |
parent_view->font(), this, model_.get(), location_bar, |
popup_parent_view)), |
- controller_(controller), |
parent_view_(parent_view), |
- toolbar_model_(toolbar_model), |
- command_updater_(command_updater), |
popup_window_mode_(popup_window_mode), |
force_hidden_(false), |
tracking_click_(), |
@@ -628,15 +626,12 @@ void OmniboxViewWin::OpenMatch(const AutocompleteMatch& match, |
WindowOpenDisposition disposition, |
const GURL& alternate_nav_url, |
size_t selected_line) { |
- if (!match.destination_url.is_valid()) |
- return; |
- |
// When we navigate, we first revert to the unedited state, then if necessary |
// synchronously change the permanent text to the new URL. If we don't freeze |
// here, the user could potentially see a flicker of the current URL before |
// the new one reappears, which would look glitchy. |
ScopedFreeze freeze(this, GetTextObjectModel()); |
- model_->OpenMatch(match, disposition, alternate_nav_url, selected_line); |
+ OmniboxView::OpenMatch(match, display_text, alternate_nav_url, selection); |
} |
string16 OmniboxViewWin::GetText() const { |
@@ -647,28 +642,12 @@ string16 OmniboxViewWin::GetText() const { |
return str; |
} |
-bool OmniboxViewWin::IsEditingOrEmpty() const { |
- return model_->user_input_in_progress() || (GetTextLength() == 0); |
-} |
- |
-int OmniboxViewWin::GetIcon() const { |
- return IsEditingOrEmpty() ? |
- AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) : |
- toolbar_model_->GetIcon(); |
-} |
- |
-void OmniboxViewWin::SetUserText(const string16& text) { |
- SetUserText(text, text, true); |
-} |
- |
void OmniboxViewWin::SetUserText(const string16& text, |
const string16& display_text, |
bool update_popup) { |
ScopedFreeze freeze(this, GetTextObjectModel()); |
- model_->SetUserText(text); |
saved_selection_for_focus_change_.cpMin = -1; |
- SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, |
- true); |
+ OmniboxView::SetUserText(text, display_text, update_popup); |
} |
void OmniboxViewWin::SetWindowTextAndCaretPos(const string16& text, |
@@ -721,9 +700,8 @@ void OmniboxViewWin::SelectAll(bool reversed) { |
void OmniboxViewWin::RevertAll() { |
ScopedFreeze freeze(this, GetTextObjectModel()); |
- ClosePopup(); |
saved_selection_for_focus_change_.cpMin = -1; |
- model_->Revert(); |
+ OmniboxView::RevertAll(); |
} |
void OmniboxViewWin::UpdatePopup() { |
@@ -758,10 +736,6 @@ void OmniboxViewWin::UpdatePopup() { |
(sel.cpMax < GetTextLength()) || IsImeComposing()); |
} |
-void OmniboxViewWin::ClosePopup() { |
- model_->StopAutocomplete(); |
-} |
- |
void OmniboxViewWin::SetFocus() { |
::SetFocus(m_hWnd); |
} |
@@ -941,10 +915,6 @@ gfx::NativeView OmniboxViewWin::GetRelativeWindowForPopup() const { |
return GetRelativeWindowForNativeView(GetNativeView()); |
} |
-CommandUpdater* OmniboxViewWin::GetCommandUpdater() { |
- return command_updater_; |
-} |
- |
void OmniboxViewWin::SetInstantSuggestion(const string16& suggestion, |
bool animate_to_complete) { |
parent_view_->SetInstantSuggestion(suggestion, animate_to_complete); |
@@ -2261,6 +2231,10 @@ LONG OmniboxViewWin::ClipXCoordToVisibleText(LONG x, |
return is_triple_click ? (right_bound - 1) : right_bound; |
} |
+int OmniboxViewWin::GetOmniboxTextLength() { |
+ return static_cast<int>(GetTextLength()); |
+} |
+ |
void OmniboxViewWin::EmphasizeURLComponents() { |
ITextDocument* const text_object_model = GetTextObjectModel(); |
ScopedFreeze freeze(this, text_object_model); |
@@ -2457,8 +2431,7 @@ void OmniboxViewWin::DrawDropHighlight(HDC hdc, |
void OmniboxViewWin::TextChanged() { |
ScopedFreeze freeze(this, GetTextObjectModel()); |
- EmphasizeURLComponents(); |
- model_->OnChanged(); |
+ OmniboxView::TextChanged(); |
} |
ITextDocument* OmniboxViewWin::GetTextObjectModel() const { |
@@ -2666,10 +2639,3 @@ int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
// PosFromChar(i) might return 0 when i is greater than 1. |
return font_.GetStringWidth(text) + GetHorizontalMargin(); |
} |
- |
-bool OmniboxViewWin::IsCaretAtEnd() const { |
- long length = GetTextLength(); |
- CHARRANGE sel; |
- GetSelection(sel); |
- return sel.cpMin == sel.cpMax && sel.cpMin == length; |
-} |