Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 10810062: Moving common code into OmniboxView from OmniboxView* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More win fixes Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
index 5f0d868809d7325c442a074d2572ab8f1f54a75e..82563d65bd97a824b47d0ad0576c868830930fed 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
@@ -160,7 +160,9 @@ OmniboxViewGtk::OmniboxViewGtk(OmniboxEditController* controller,
CommandUpdater* command_updater,
bool popup_window_mode,
GtkWidget* location_bar)
- : browser_(browser),
+ : OmniboxView(browser->profile(), controller, toolbar_model,
+ command_updater),
+ browser_(browser),
text_view_(NULL),
tag_table_(NULL),
text_buffer_(NULL),
@@ -171,10 +173,6 @@ OmniboxViewGtk::OmniboxViewGtk(OmniboxEditController* controller,
instant_anchor_tag_(NULL),
instant_view_(NULL),
instant_mark_(NULL),
- model_(new OmniboxEditModel(this, controller, browser->profile())),
- controller_(controller),
- toolbar_model_(toolbar_model),
- command_updater_(command_updater),
popup_window_mode_(popup_window_mode),
security_level_(ToolbarModel::NONE),
mark_set_handler_id_(0),
@@ -422,14 +420,6 @@ int OmniboxViewGtk::WidthOfTextAfterCursor() {
return -1;
}
-OmniboxEditModel* OmniboxViewGtk::model() {
- return model_.get();
-}
-
-const OmniboxEditModel* OmniboxViewGtk::model() const {
- return model_.get();
-}
-
void OmniboxViewGtk::SaveStateToTab(WebContents* tab) {
DCHECK(tab);
// If any text has been selected, register it as the PRIMARY selection so it
@@ -475,16 +465,6 @@ void OmniboxViewGtk::Update(const WebContents* contents) {
}
}
-void OmniboxViewGtk::OpenMatch(const AutocompleteMatch& match,
- WindowOpenDisposition disposition,
- const GURL& alternate_nav_url,
- size_t selected_line) {
- if (!match.destination_url.is_valid())
- return;
-
- model_->OpenMatch(match, disposition, alternate_nav_url, selected_line);
-}
-
string16 OmniboxViewGtk::GetText() const {
GtkTextIter start, end;
GetTextBufferBounds(&start, &end);
@@ -505,29 +485,6 @@ string16 OmniboxViewGtk::GetText() const {
return out;
}
-bool OmniboxViewGtk::IsEditingOrEmpty() const {
- return model_->user_input_in_progress() || (GetTextLength() == 0);
-}
-
-int OmniboxViewGtk::GetIcon() const {
- return IsEditingOrEmpty() ?
- AutocompleteMatch::TypeToIcon(model_->CurrentTextType()) :
- toolbar_model_->GetIcon();
-}
-
-void OmniboxViewGtk::SetUserText(const string16& text) {
- SetUserText(text, text, true);
-}
-
-void OmniboxViewGtk::SetUserText(const string16& text,
- const string16& display_text,
- bool update_popup) {
- model_->SetUserText(text);
- // TODO(deanm): something about selection / focus change here.
- SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
- true);
-}
-
void OmniboxViewGtk::SetWindowTextAndCaretPos(const string16& text,
size_t caret_pos,
bool update_popup,
@@ -584,12 +541,6 @@ void OmniboxViewGtk::SelectAll(bool reversed) {
SelectAllInternal(reversed, false);
}
-void OmniboxViewGtk::RevertAll() {
- ClosePopup();
- model_->Revert();
- TextChanged();
-}
-
void OmniboxViewGtk::UpdatePopup() {
model_->SetInputInProgress(true);
if (!update_popup_without_focus_ && !model_->has_focus())
@@ -599,14 +550,11 @@ void OmniboxViewGtk::UpdatePopup() {
// the text, or in the middle of composition.
CharRange sel = GetSelection();
bool no_inline_autocomplete =
- std::max(sel.cp_max, sel.cp_min) < GetTextLength() || IsImeComposing();
+ std::max(sel.cp_max, sel.cp_min) < GetOmniboxTextLength() ||
+ IsImeComposing();
model_->StartAutocomplete(sel.cp_min != sel.cp_max, no_inline_autocomplete);
}
-void OmniboxViewGtk::ClosePopup() {
- model_->StopAutocomplete();
-}
-
void OmniboxViewGtk::OnTemporaryTextMaybeChanged(
const string16& display_text,
bool save_original_selection) {
@@ -682,7 +630,7 @@ bool OmniboxViewGtk::OnAfterPossibleChange() {
}
const CharRange new_sel = GetSelection();
- const int length = GetTextLength();
+ const int length = GetOmniboxTextLength();
const bool selection_differs =
((new_sel.cp_min != new_sel.cp_max) ||
(sel_before_change_.cp_min != sel_before_change_.cp_max)) &&
@@ -743,10 +691,6 @@ gfx::NativeView OmniboxViewGtk::GetRelativeWindowForPopup() const {
return toplevel;
}
-CommandUpdater* OmniboxViewGtk::GetCommandUpdater() {
- return command_updater_;
-}
-
void OmniboxViewGtk::SetInstantSuggestion(const string16& suggestion,
bool animate_to_complete) {
std::string suggestion_utf8 = UTF16ToUTF8(suggestion);
@@ -1883,7 +1827,7 @@ void OmniboxViewGtk::ItersFromCharRange(const CharRange& range,
gtk_text_buffer_get_iter_at_offset(text_buffer_, iter_max, range.cp_max);
}
-int OmniboxViewGtk::GetTextLength() const {
+int OmniboxViewGtk::GetOmniboxTextLength() const {
GtkTextIter end;
gtk_text_buffer_get_iter_at_mark(text_buffer_, &end, instant_mark_);
if (supports_pre_edit_) {
@@ -1894,16 +1838,10 @@ int OmniboxViewGtk::GetTextLength() const {
return gtk_text_iter_get_offset(&end);
}
-void OmniboxViewGtk::PlaceCaretAt(int pos) {
- GtkTextIter cursor;
- gtk_text_buffer_get_iter_at_offset(text_buffer_, &cursor, pos);
- gtk_text_buffer_place_cursor(text_buffer_, &cursor);
-}
-
bool OmniboxViewGtk::IsCaretAtEnd() const {
const CharRange selection = GetSelection();
return selection.cp_min == selection.cp_max &&
- selection.cp_min == GetTextLength();
+ selection.cp_min == GetOmniboxTextLength();
}
void OmniboxViewGtk::EmphasizeURLComponents() {
@@ -1981,11 +1919,6 @@ void OmniboxViewGtk::StopAnimation() {
UpdateInstantViewColors();
}
-void OmniboxViewGtk::TextChanged() {
- EmphasizeURLComponents();
- model_->OnChanged();
-}
-
void OmniboxViewGtk::SavePrimarySelection(const std::string& selected_text) {
DCHECK(text_view_);

Powered by Google App Engine
This is Rietveld 408576698