summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view.h9
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc13
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc10
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h2
6 files changed, 37 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view.h b/chrome/browser/autocomplete/autocomplete_edit_view.h
index 27c28e7..b8b438f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view.h
@@ -69,6 +69,15 @@ class AutocompleteEditView {
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos) = 0;
+ // Sets the edit to forced query mode. Practically speaking, this means that
+ // if the edit is not in forced query mode, its text is set to "?" with the
+ // cursor at the end, and if the edit is in forced query mode (its first
+ // character is '?'), the text after the '?' is selected.
+ //
+ // In the future we should display the search engine UI for the default engine
+ // rather than '?'.
+ virtual void SetForcedQuery() = 0;
+
// Returns true if all text is selected.
virtual bool IsSelectAll() = 0;
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 272e5ab..25e647f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -226,6 +226,19 @@ void AutocompleteEditViewGtk::SetWindowTextAndCaretPos(const std::wstring& text,
gtk_text_buffer_place_cursor(text_buffer_, &cur_pos);
}
+void AutocompleteEditViewGtk::SetForcedQuery() {
+ const std::wstring current_text(GetText());
+ if (current_text.empty() || (current_text[0] != '?')) {
+ SetUserText(L"?");
+ } else {
+ GtkTextIter start, end;
+ gtk_text_buffer_get_bounds(text_buffer_, &start, &end);
+ gtk_text_buffer_get_iter_at_offset(text_buffer_, &start, 1);
+ gtk_text_buffer_place_cursor(text_buffer_, &start);
+ gtk_text_buffer_select_range(text_buffer_, &start, &end);
+ }
+}
+
bool AutocompleteEditViewGtk::IsSelectAll() {
NOTIMPLEMENTED();
return false;
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index 7ac02d9..65dcad9 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -67,6 +67,8 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos);
+ virtual void SetForcedQuery();
+
virtual bool IsSelectAll();
virtual void SelectAll(bool reversed);
virtual void RevertAll();
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
index 8f70070..5ec2d0f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
@@ -63,6 +63,8 @@ class AutocompleteEditViewMac : public AutocompleteEditView {
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos);
+ virtual void SetForcedQuery() { NOTIMPLEMENTED(); }
+
virtual bool IsSelectAll() {
NOTIMPLEMENTED();
return false;
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 67f7245..2a58b66 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -666,6 +666,14 @@ void AutocompleteEditViewWin::SetWindowTextAndCaretPos(const std::wstring& text,
PlaceCaretAt(caret_pos);
}
+void AutocompleteEditViewWin::SetForcedQuery() {
+ const std::wstring current_text(GetText());
+ if (current_text.empty() || (current_text[0] != '?'))
+ SetUserText(L"?");
+ else
+ SetSelection(current_text.length(), 1);
+}
+
bool AutocompleteEditViewWin::IsSelectAll() {
CHARRANGE selection;
GetSel(selection);
@@ -888,7 +896,7 @@ void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) {
}
bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing(
- const views::KeyEvent& e) {
+ const views::KeyEvent& e) {
int c = e.GetCharacter();
// We don't process ALT + numpad digit as accelerators, they are used for
// entering special characters. We do translate alt-home.
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index 9e677f6..822ebea 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -100,6 +100,8 @@ class AutocompleteEditViewWin
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos);
+ virtual void SetForcedQuery();
+
virtual bool IsSelectAll();
virtual void SelectAll(bool reversed);
virtual void RevertAll();