| OLD | NEW |
| 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/string16.h" | 9 #include "base/string16.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 virtual void OnAutocompleteWillAccept() = 0; | 49 virtual void OnAutocompleteWillAccept() = 0; |
| 50 | 50 |
| 51 // Commits the suggested text. |typed_text| is the current text showing in the | 51 // Commits the suggested text. |typed_text| is the current text showing in the |
| 52 // autocomplete. Returns true if the text was committed. | 52 // autocomplete. Returns true if the text was committed. |
| 53 virtual bool OnCommitSuggestedText(const std::wstring& typed_text) = 0; | 53 virtual bool OnCommitSuggestedText(const std::wstring& typed_text) = 0; |
| 54 | 54 |
| 55 // Accepts the currently showing instant preview, if any, and returns true. | 55 // Accepts the currently showing instant preview, if any, and returns true. |
| 56 // Returns false if there is no instant preview showing. | 56 // Returns false if there is no instant preview showing. |
| 57 virtual bool AcceptCurrentInstantPreview() = 0; | 57 virtual bool AcceptCurrentInstantPreview() = 0; |
| 58 | 58 |
| 59 // Sets the suggested search text to |suggested_text|. | |
| 60 virtual void OnSetSuggestedSearchText(const string16& suggested_text) = 0; | |
| 61 | |
| 62 // Invoked when the popup is going to change its bounds to |bounds|. | 59 // Invoked when the popup is going to change its bounds to |bounds|. |
| 63 virtual void OnPopupBoundsChanged(const gfx::Rect& bounds) = 0; | 60 virtual void OnPopupBoundsChanged(const gfx::Rect& bounds) = 0; |
| 64 | 61 |
| 65 // When the user presses enter or selects a line with the mouse, this | 62 // When the user presses enter or selects a line with the mouse, this |
| 66 // function will get called synchronously with the url to open and | 63 // function will get called synchronously with the url to open and |
| 67 // disposition and transition to use when opening it. | 64 // disposition and transition to use when opening it. |
| 68 // | 65 // |
| 69 // |alternate_nav_url|, if non-empty, contains the alternate navigation URL | 66 // |alternate_nav_url|, if non-empty, contains the alternate navigation URL |
| 70 // for |url|, which the controller can check for existence. See comments on | 67 // for |url|, which the controller can check for existence. See comments on |
| 71 // AutocompleteResult::GetAlternateNavURL(). | 68 // AutocompleteResult::GetAlternateNavURL(). |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // 2) The user is composing a text with an IME | 329 // 2) The user is composing a text with an IME |
| 333 bool OnAfterPossibleChange(const std::wstring& new_text, | 330 bool OnAfterPossibleChange(const std::wstring& new_text, |
| 334 bool selection_differs, | 331 bool selection_differs, |
| 335 bool text_differs, | 332 bool text_differs, |
| 336 bool just_deleted_text, | 333 bool just_deleted_text, |
| 337 bool allow_keyword_ui_change); | 334 bool allow_keyword_ui_change); |
| 338 | 335 |
| 339 // Invoked when the popup is going to change its bounds to |bounds|. | 336 // Invoked when the popup is going to change its bounds to |bounds|. |
| 340 void PopupBoundsChangedTo(const gfx::Rect& bounds); | 337 void PopupBoundsChangedTo(const gfx::Rect& bounds); |
| 341 | 338 |
| 342 // Invoked when the autocomplete results may have changed in some way. | |
| 343 void ResultsUpdated(); | |
| 344 | |
| 345 private: | 339 private: |
| 346 enum PasteState { | 340 enum PasteState { |
| 347 NONE, // Most recent edit was not a paste that replaced all text. | 341 NONE, // Most recent edit was not a paste that replaced all text. |
| 348 REPLACED_ALL, // Most recent edit was a paste that replaced all text. | 342 REPLACED_ALL, // Most recent edit was a paste that replaced all text. |
| 349 REPLACING_ALL, // In the middle of doing a paste that replaces all | 343 REPLACING_ALL, // In the middle of doing a paste that replaces all |
| 350 // text. We need this intermediate state because OnPaste() | 344 // text. We need this intermediate state because OnPaste() |
| 351 // does the actual detection of such pastes, but | 345 // does the actual detection of such pastes, but |
| 352 // OnAfterPossibleChange() has to update the paste state | 346 // OnAfterPossibleChange() has to update the paste state |
| 353 // for every edit. If OnPaste() set the state directly to | 347 // for every edit. If OnPaste() set the state directly to |
| 354 // REPLACED_ALL, OnAfterPossibleChange() wouldn't know | 348 // REPLACED_ALL, OnAfterPossibleChange() wouldn't know |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 GURL* alternate_nav_url) const; | 386 GURL* alternate_nav_url) const; |
| 393 | 387 |
| 394 // Returns true if |text| (which is display text in the current context) | 388 // Returns true if |text| (which is display text in the current context) |
| 395 // parses as a URL, and in that case sets |url| to the calculated URL. | 389 // parses as a URL, and in that case sets |url| to the calculated URL. |
| 396 // Subtle note: This ignores the desired_tld_ (unlike GetDataForURLExport() | 390 // Subtle note: This ignores the desired_tld_ (unlike GetDataForURLExport() |
| 397 // and CurrentTextIsURL()). The view needs this because it calls this | 391 // and CurrentTextIsURL()). The view needs this because it calls this |
| 398 // function during copy handling, when the control key is down to trigger the | 392 // function during copy handling, when the control key is down to trigger the |
| 399 // copy. | 393 // copy. |
| 400 bool GetURLForText(const std::wstring& text, GURL* url) const; | 394 bool GetURLForText(const std::wstring& text, GURL* url) const; |
| 401 | 395 |
| 402 // Determines the suggested search text and invokes OnSetSuggestedSearchText | |
| 403 // on the controller. | |
| 404 void UpdateSuggestedSearchText(); | |
| 405 | |
| 406 AutocompleteEditView* view_; | 396 AutocompleteEditView* view_; |
| 407 | 397 |
| 408 AutocompletePopupModel* popup_; | 398 AutocompletePopupModel* popup_; |
| 409 | 399 |
| 410 AutocompleteEditController* controller_; | 400 AutocompleteEditController* controller_; |
| 411 | 401 |
| 412 NotificationRegistrar registrar_; | 402 NotificationRegistrar registrar_; |
| 413 | 403 |
| 414 // Whether the edit has focus. | 404 // Whether the edit has focus. |
| 415 bool has_focus_; | 405 bool has_focus_; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 mutable GURL paste_and_go_url_; | 492 mutable GURL paste_and_go_url_; |
| 503 mutable PageTransition::Type paste_and_go_transition_; | 493 mutable PageTransition::Type paste_and_go_transition_; |
| 504 mutable GURL paste_and_go_alternate_nav_url_; | 494 mutable GURL paste_and_go_alternate_nav_url_; |
| 505 | 495 |
| 506 Profile* profile_; | 496 Profile* profile_; |
| 507 | 497 |
| 508 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditModel); | 498 DISALLOW_COPY_AND_ASSIGN(AutocompleteEditModel); |
| 509 }; | 499 }; |
| 510 | 500 |
| 511 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ | 501 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_ |
| OLD | NEW |