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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit.h

Issue 6685002: Wires up ability for page to specify instant auto complete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test and stray char Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" 11 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
12 #include "chrome/browser/autocomplete/autocomplete_match.h" 12 #include "chrome/browser/autocomplete/autocomplete_match.h"
13 #include "chrome/common/instant_types.h"
13 #include "chrome/common/page_transition_types.h" 14 #include "chrome/common/page_transition_types.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "ui/gfx/native_widget_types.h" 16 #include "ui/gfx/native_widget_types.h"
16 #include "webkit/glue/window_open_disposition.h" 17 #include "webkit/glue/window_open_disposition.h"
17 18
18 class AutocompleteController; 19 class AutocompleteController;
19 class AutocompleteEditController; 20 class AutocompleteEditController;
20 class AutocompleteEditModel; 21 class AutocompleteEditModel;
21 class AutocompleteEditView; 22 class AutocompleteEditView;
22 class AutocompletePopupModel; 23 class AutocompletePopupModel;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void SetUserText(const string16& text); 185 void SetUserText(const string16& text);
185 186
186 // Calls through to SearchProvider::FinalizeInstantQuery. 187 // Calls through to SearchProvider::FinalizeInstantQuery.
187 // If |skip_inline_autocomplete| is true then the |suggest_text| will be 188 // If |skip_inline_autocomplete| is true then the |suggest_text| will be
188 // turned into final text instead of inline autocomplete suggest. 189 // turned into final text instead of inline autocomplete suggest.
189 void FinalizeInstantQuery(const string16& input_text, 190 void FinalizeInstantQuery(const string16& input_text,
190 const string16& suggest_text, 191 const string16& suggest_text,
191 bool skip_inline_autocomplete); 192 bool skip_inline_autocomplete);
192 193
193 // Sets the suggestion text. 194 // Sets the suggestion text.
194 void SetSuggestedText(const string16& text); 195 void SetSuggestedText(const string16& text,
196 InstantCompleteBehavior behavior);
195 197
196 // Commits the suggested text. If |skip_inline_autocomplete| is true then the 198 // Commits the suggested text. If |skip_inline_autocomplete| is true then the
197 // suggested text will be committed as final text as if it's inputted by the 199 // suggested text will be committed as final text as if it's inputted by the
198 // user, rather than as inline autocomplete suggest. 200 // user, rather than as inline autocomplete suggest.
199 // Returns true if the text was committed. 201 // Returns true if the text was committed.
200 // TODO: can the return type be void? 202 // TODO: can the return type be void?
201 bool CommitSuggestedText(bool skip_inline_autocomplete); 203 bool CommitSuggestedText(bool skip_inline_autocomplete);
202 204
203 // Accepts the currently showing instant preview, if any, and returns true. 205 // Accepts the currently showing instant preview, if any, and returns true.
204 // Returns false if there is no instant preview showing. 206 // Returns false if there is no instant preview showing.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // 2) The user is composing a text with an IME 328 // 2) The user is composing a text with an IME
327 bool OnAfterPossibleChange(const string16& new_text, 329 bool OnAfterPossibleChange(const string16& new_text,
328 bool selection_differs, 330 bool selection_differs,
329 bool text_differs, 331 bool text_differs,
330 bool just_deleted_text, 332 bool just_deleted_text,
331 bool allow_keyword_ui_change); 333 bool allow_keyword_ui_change);
332 334
333 // Invoked when the popup is going to change its bounds to |bounds|. 335 // Invoked when the popup is going to change its bounds to |bounds|.
334 void PopupBoundsChangedTo(const gfx::Rect& bounds); 336 void PopupBoundsChangedTo(const gfx::Rect& bounds);
335 337
338 #if defined(UNIT_TEST)
339 InstantCompleteBehavior instant_complete_behavior() const {
340 return instant_complete_behavior_;
341 }
342 #endif
343
336 private: 344 private:
337 enum PasteState { 345 enum PasteState {
338 NONE, // Most recent edit was not a paste. 346 NONE, // Most recent edit was not a paste.
339 PASTING, // In the middle of doing a paste. We need this intermediate 347 PASTING, // In the middle of doing a paste. We need this intermediate
340 // state because OnPaste() does the actual detection of 348 // state because OnPaste() does the actual detection of
341 // paste, but OnAfterPossibleChange() has to update the 349 // paste, but OnAfterPossibleChange() has to update the
342 // paste state for every edit. If OnPaste() set the state 350 // paste state for every edit. If OnPaste() set the state
343 // directly to PASTED, OnAfterPossibleChange() wouldn't know 351 // directly to PASTED, OnAfterPossibleChange() wouldn't know
344 // whether that represented the current edit or a past one. 352 // whether that represented the current edit or a past one.
345 PASTED, // Most recent edit was a paste. 353 PASTED, // Most recent edit was a paste.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 mutable GURL paste_and_go_alternate_nav_url_; 524 mutable GURL paste_and_go_alternate_nav_url_;
517 525
518 Profile* profile_; 526 Profile* profile_;
519 527
520 // Should instant be updated? This is needed as prior to accepting the current 528 // Should instant be updated? This is needed as prior to accepting the current
521 // text the model is reverted, which triggers resetting instant. We don't want 529 // text the model is reverted, which triggers resetting instant. We don't want
522 // to update instant in this case, so we use the flag to determine if this is 530 // to update instant in this case, so we use the flag to determine if this is
523 // happening. 531 // happening.
524 bool update_instant_; 532 bool update_instant_;
525 533
534 // Last value of InstantCompleteBehavior supplied to |SetSuggestedText|.
535 InstantCompleteBehavior instant_complete_behavior_;
536
526 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditModel); 537 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditModel);
527 }; 538 };
528 539
529 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ 540 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit.cc » ('j') | chrome/browser/autocomplete/autocomplete_edit.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698