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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.h

Issue 10836031: Remove Instant v1 API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update history, title, favicon Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void RestoreState(const State& state); 75 void RestoreState(const State& state);
76 76
77 // Returns the match for the current text. If the user has not edited the text 77 // Returns the match for the current text. If the user has not edited the text
78 // this is the match corresponding to the permanent text. 78 // this is the match corresponding to the permanent text.
79 AutocompleteMatch CurrentMatch(); 79 AutocompleteMatch CurrentMatch();
80 80
81 // Called when the user wants to export the entire current text as a URL. 81 // Called when the user wants to export the entire current text as a URL.
82 // Sets the url, and if known, the title and favicon. 82 // Sets the url, and if known, the title and favicon.
83 void GetDataForURLExport(GURL* url, string16* title, SkBitmap* favicon); 83 void GetDataForURLExport(GURL* url, string16* title, SkBitmap* favicon);
84 84
85 // Returns true if a verbatim query should be used for instant. A verbatim 85 // Returns true if a verbatim query should be used for Instant. A verbatim
86 // query is forced in certain situations, such as pressing delete at the end 86 // query is forced in certain situations, such as pressing delete at the end
87 // of the edit. 87 // of the edit.
88 bool UseVerbatimInstant(); 88 bool UseVerbatimInstant();
89 89
90 // If the user presses ctrl-enter, it means "add .com to the the end". The 90 // If the user presses ctrl-enter, it means "add .com to the the end". The
91 // desired TLD is the TLD the user desires to add to the end of the current 91 // desired TLD is the TLD the user desires to add to the end of the current
92 // input, if any, based on their control key state and any other actions 92 // input, if any, based on their control key state and any other actions
93 // they've taken. 93 // they've taken.
94 string16 GetDesiredTLD() const; 94 string16 GetDesiredTLD() const;
95 95
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void SetUserText(const string16& text); 130 void SetUserText(const string16& text);
131 131
132 // Calls through to SearchProvider::FinalizeInstantQuery. 132 // Calls through to SearchProvider::FinalizeInstantQuery.
133 // If |skip_inline_autocomplete| is true then the |suggest_text| will be 133 // If |skip_inline_autocomplete| is true then the |suggest_text| will be
134 // turned into final text instead of inline autocomplete suggest. 134 // turned into final text instead of inline autocomplete suggest.
135 void FinalizeInstantQuery(const string16& input_text, 135 void FinalizeInstantQuery(const string16& input_text,
136 const string16& suggest_text, 136 const string16& suggest_text,
137 bool skip_inline_autocomplete); 137 bool skip_inline_autocomplete);
138 138
139 // Sets the suggestion text. 139 // Sets the suggestion text.
140 void SetSuggestedText(const string16& text, 140 void SetSuggestedText(const string16& text, InstantCompleteBehavior behavior);
141 InstantCompleteBehavior behavior);
142 141
143 // Commits the suggested text. If |skip_inline_autocomplete| is true then the 142 // Commits the suggested text. If |skip_inline_autocomplete| is true then the
144 // suggested text will be committed as final text as if it's inputted by the 143 // suggested text will be committed as final text as if it's inputted by the
145 // user, rather than as inline autocomplete suggest. 144 // user, rather than as inline autocomplete suggest.
146 // Returns true if the text was committed. 145 // Returns true if the text was committed.
147 // TODO: can the return type be void? 146 // TODO: can the return type be void?
148 bool CommitSuggestedText(bool skip_inline_autocomplete); 147 bool CommitSuggestedText(bool skip_inline_autocomplete);
149 148
150 // Accepts the currently showing instant preview, if any, and returns true. 149 // Accepts the currently showing Instant preview, if any, and returns true.
151 // Returns false if there is no instant preview showing. 150 // Returns false if there is no Instant preview showing.
152 bool AcceptCurrentInstantPreview(); 151 bool AcceptCurrentInstantPreview();
153 152
154 // Invoked any time the text may have changed in the edit. Updates instant and 153 // Invoked any time the text may have changed in the edit. Updates Instant and
155 // notifies the controller. 154 // notifies the controller.
156 void OnChanged(); 155 void OnChanged();
157 156
158 // Reverts the edit model back to its unedited state (permanent text showing, 157 // Reverts the edit model back to its unedited state (permanent text showing,
159 // no user input in progress). 158 // no user input in progress).
160 void Revert(); 159 void Revert();
161 160
162 // Directs the popup to start autocomplete. 161 // Directs the popup to start autocomplete.
163 void StartAutocomplete(bool has_selected_text, 162 void StartAutocomplete(bool has_selected_text,
164 bool prevent_inline_autocomplete) const; 163 bool prevent_inline_autocomplete) const;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 size_t selection_start, 269 size_t selection_start,
271 size_t selection_end, 270 size_t selection_end,
272 bool selection_differs, 271 bool selection_differs,
273 bool text_differs, 272 bool text_differs,
274 bool just_deleted_text, 273 bool just_deleted_text,
275 bool allow_keyword_ui_change); 274 bool allow_keyword_ui_change);
276 275
277 // Invoked when the popup is going to change its bounds to |bounds|. 276 // Invoked when the popup is going to change its bounds to |bounds|.
278 void PopupBoundsChangedTo(const gfx::Rect& bounds); 277 void PopupBoundsChangedTo(const gfx::Rect& bounds);
279 278
280 #if defined(UNIT_TEST)
281 InstantCompleteBehavior instant_complete_behavior() const {
282 return instant_complete_behavior_;
283 }
284 #endif
285
286 private: 279 private:
287 enum PasteState { 280 enum PasteState {
288 NONE, // Most recent edit was not a paste. 281 NONE, // Most recent edit was not a paste.
289 PASTING, // In the middle of doing a paste. We need this intermediate 282 PASTING, // In the middle of doing a paste. We need this intermediate
290 // state because OnPaste() does the actual detection of 283 // state because OnPaste() does the actual detection of
291 // paste, but OnAfterPossibleChange() has to update the 284 // paste, but OnAfterPossibleChange() has to update the
292 // paste state for every edit. If OnPaste() set the state 285 // paste state for every edit. If OnPaste() set the state
293 // directly to PASTED, OnAfterPossibleChange() wouldn't know 286 // directly to PASTED, OnAfterPossibleChange() wouldn't know
294 // whether that represented the current edit or a past one. 287 // whether that represented the current edit or a past one.
295 PASTED, // Most recent edit was a paste. 288 PASTED, // Most recent edit was a paste.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Checks whether the user inserted a space into |old_text| and by doing so 359 // Checks whether the user inserted a space into |old_text| and by doing so
367 // created a |new_text| that looks like "<keyword> <search phrase>". 360 // created a |new_text| that looks like "<keyword> <search phrase>".
368 bool CreatedKeywordSearchByInsertingSpaceInMiddle( 361 bool CreatedKeywordSearchByInsertingSpaceInMiddle(
369 const string16& old_text, 362 const string16& old_text,
370 const string16& new_text, 363 const string16& new_text,
371 size_t caret_position) const; 364 size_t caret_position) const;
372 365
373 // Notifies the SearchTabHelper that autocomplete state has changed. 366 // Notifies the SearchTabHelper that autocomplete state has changed.
374 void NotifySearchTabHelper(); 367 void NotifySearchTabHelper();
375 368
376 // Tries to start an instant preview for |match|. Returns true if instant 369 // Tries to start an Instant preview for |match|. Returns true if Instant
377 // processed the match. 370 // processed the match. |suggested_text| should initially contain the current
378 bool DoInstant(const AutocompleteMatch& match, string16* suggested_text); 371 // inline autocomplete text. Instant will replace it with new suggested text
372 // and set |complete_behavior| accordingly.
373 bool DoInstant(const AutocompleteMatch& match,
374 string16* suggested_text,
375 InstantCompleteBehavior* complete_behavior);
379 376
380 // Starts a prerender for the given |match|. 377 // Starts a prerender for the given |match|.
381 void DoPrerender(const AutocompleteMatch& match); 378 void DoPrerender(const AutocompleteMatch& match);
382 379
383 // Starts a DNS prefetch for the given |match|. 380 // Starts a DNS prefetch for the given |match|.
384 void DoPreconnect(const AutocompleteMatch& match); 381 void DoPreconnect(const AutocompleteMatch& match);
385 382
386 // Checks if a given character is a valid space character for accepting 383 // Checks if a given character is a valid space character for accepting
387 // keyword. 384 // keyword.
388 static bool IsSpaceCharForAcceptingKeyword(wchar_t c); 385 static bool IsSpaceCharForAcceptingKeyword(wchar_t c);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 string16 keyword_; 487 string16 keyword_;
491 488
492 // True if the keyword associated with this match is merely a hint, i.e. the 489 // True if the keyword associated with this match is merely a hint, i.e. the
493 // user hasn't actually selected a keyword yet. When this is true, we can use 490 // user hasn't actually selected a keyword yet. When this is true, we can use
494 // keyword_ to show a "Press <tab> to search" sort of hint. 491 // keyword_ to show a "Press <tab> to search" sort of hint.
495 bool is_keyword_hint_; 492 bool is_keyword_hint_;
496 493
497 Profile* profile_; 494 Profile* profile_;
498 495
499 // This is needed as prior to accepting the current text the model is 496 // This is needed as prior to accepting the current text the model is
500 // reverted, which triggers resetting instant. We don't want to update instant 497 // reverted, which triggers resetting Instant. We don't want to update Instant
501 // in this case, so we use the flag to determine if this is happening. 498 // in this case, so we use the flag to determine if this is happening.
502 bool in_revert_; 499 bool in_revert_;
503 500
504 // Indicates if the upcoming autocomplete search is allowed to be treated as 501 // Indicates if the upcoming autocomplete search is allowed to be treated as
505 // an exact keyword match. If this is true then keyword mode will be 502 // an exact keyword match. If this is true then keyword mode will be
506 // triggered automatically if the input is "<keyword> <search string>". We 503 // triggered automatically if the input is "<keyword> <search string>". We
507 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. 504 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true.
508 // This has no effect if we're already in keyword mode. 505 // This has no effect if we're already in keyword mode.
509 bool allow_exact_keyword_match_; 506 bool allow_exact_keyword_match_;
510 507
511 // Last value of InstantCompleteBehavior supplied to |SetSuggestedText|.
512 InstantCompleteBehavior instant_complete_behavior_;
513
514 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); 508 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel);
515 }; 509 };
516 510
517 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ 511 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698