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

Unified Diff: chrome/browser/autocomplete/autocomplete_edit_view_gtk.h

Issue 151006: Make Linux restore Omnibox contents on tab switch. (Closed)
Patch Set: free string returned by gtk Created 11 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index 70e32f3e68d540ad4751750ddeb385221185ec72..97708d046c9d66d2cb93f53bd860591a164a4ee9 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -26,6 +26,18 @@ class TabContents;
class AutocompleteEditViewGtk : public AutocompleteEditView {
public:
+ // Modeled like the Windows CHARRANGE. Represent a pair of cursor position
+ // offsets. Since GtkTextIters are invalid after the buffer is changed, we
+ // work in character offsets (not bytes).
+ struct CharRange {
+ CharRange() : cp_min(0), cp_max(0) { }
+ CharRange(int n, int x) : cp_min(n), cp_max(x) { }
+
+ // Work in integers to match the gint GTK APIs.
+ int cp_min; // For a selection: Represents the start.
+ int cp_max; // For a selection: Represents the end (insert position).
+ };
+
AutocompleteEditViewGtk(AutocompleteEditController* controller,
ToolbarModel* toolbar_model,
Profile* profile,
@@ -86,18 +98,6 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
virtual bool OnAfterPossibleChange();
private:
- // Modeled like the Windows CHARRANGE. Represent a pair of cursor position
- // offsets. Since GtkTextIters are invalid after the buffer is changed, we
- // work in character offsets (not bytes).
- struct CharRange {
- CharRange() : cp_min(0), cp_max(0) { }
- CharRange(int n, int x) : cp_min(n), cp_max(x) { }
-
- // Work in integers to match the gint GTK APIs.
- int cp_min; // For a selection: Represents the start.
- int cp_max; // For a selection: Represents the end (insert position).
- };
-
// TODO(deanm): Would be nice to insulate the thunkers better, etc.
static void HandleBeginUserActionThunk(GtkTextBuffer* unused, gpointer self) {
reinterpret_cast<AutocompleteEditViewGtk*>(self)->HandleBeginUserAction();
@@ -201,6 +201,17 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
}
void HandlePasteAndGoReceivedText(const std::wstring& text);
+ static void HandleMarkSetThunk(GtkTextBuffer* buffer,
+ GtkTextIter* location,
+ GtkTextMark* mark,
+ gpointer self) {
+ reinterpret_cast<AutocompleteEditViewGtk*>(self)->
+ HandleMarkSet(buffer, location, mark);
+ }
+ void HandleMarkSet(GtkTextBuffer* buffer,
+ GtkTextIter* location,
+ GtkTextMark* mark);
+
// Get the character indices of the current selection. This honors
// direction, cp_max is the insertion point, and cp_min is the bound.
CharRange GetSelection();
@@ -219,6 +230,9 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
// Internally invoked whenever the text changes in some way.
void TextChanged();
+ // Save 'selected_text' as the PRIMARY X selection.
+ void SavePrimarySelection(const std::string& selected_text);
+
// The widget we expose, used for vertically centering the real text edit,
// since the height will change based on the font / font size, etc.
OwnedWidgetGtk alignment_;
@@ -233,11 +247,6 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
GtkTextTag* insecure_scheme_tag_;
GtkTextTag* black_text_tag_;
- // The primary selection clipboard for our text view widget. This is used
- // for working around some clipboard manager (klipper / glipper) bugs by
- // removing and adding back the clipboard around inline autocomplete.
- GtkClipboard* primary_clipboard_;
-
scoped_ptr<AutocompleteEditModel> model_;
scoped_ptr<AutocompletePopupViewGtk> popup_view_;
AutocompleteEditController* controller_;
@@ -258,6 +267,17 @@ class AutocompleteEditViewGtk : public AutocompleteEditView {
std::wstring text_before_change_;
CharRange sel_before_change_;
+ // The most-recently-selected text from the entry. This is updated on-the-fly
+ // as the user selects text. It is used in cases where we need to make the
+ // PRIMARY selection persist even after the user has unhighlighted the text in
+ // the view (e.g. when they highlight some text and then click to unhighlight
+ // it, we pass this string to SavePrimarySelection()).
+ std::string selected_text_;
+
+ // Has the current value of 'selected_text_' been saved as the PRIMARY
+ // selection?
+ bool selection_saved_;
+
DISALLOW_COPY_AND_ASSIGN(AutocompleteEditViewGtk);
};
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698