OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // may be false when the user is composing a text with an IME. | 290 // may be false when the user is composing a text with an IME. |
291 bool OnAfterPossibleChange(const string16& old_text, | 291 bool OnAfterPossibleChange(const string16& old_text, |
292 const string16& new_text, | 292 const string16& new_text, |
293 size_t selection_start, | 293 size_t selection_start, |
294 size_t selection_end, | 294 size_t selection_end, |
295 bool selection_differs, | 295 bool selection_differs, |
296 bool text_differs, | 296 bool text_differs, |
297 bool just_deleted_text, | 297 bool just_deleted_text, |
298 bool allow_keyword_ui_change); | 298 bool allow_keyword_ui_change); |
299 | 299 |
300 // TODO(beaudoin): Mac code still calls this here. We should try to untangle | |
301 // this. | |
302 // Invoked when the popup has changed its bounds to |bounds|. |bounds| here | |
303 // is in screen coordinates. | |
304 void OnPopupBoundsChanged(const gfx::Rect& bounds) { | |
305 omnibox_controller_->OnPopupBoundsChanged(bounds); | |
306 } | |
307 | |
308 // Called when the current match has changed in the OmniboxController. | 300 // Called when the current match has changed in the OmniboxController. |
309 void OnCurrentMatchChanged(bool is_temporary_set_by_instant); | 301 void OnCurrentMatchChanged(); |
310 | |
311 // Callend when the gray text suggestion has changed in the OmniboxController. | |
312 void OnGrayTextChanged(); | |
313 | 302 |
314 // Access the current view text. | 303 // Access the current view text. |
315 string16 GetViewText() const; | 304 string16 GetViewText() const; |
316 | 305 |
317 string16 user_text() const { return user_text_; } | 306 string16 user_text() const { return user_text_; } |
318 | 307 |
319 // TODO(beaudoin): We need this to allow OmniboxController access the | 308 // TODO(beaudoin): We need this to allow OmniboxController access the |
320 // InstantController via OmniboxEditController, because the only valid pointer | 309 // InstantController via OmniboxEditController, because the only valid pointer |
321 // to InstantController is kept in Browser. We should try to get rid of this, | 310 // to InstantController is kept in Browser. We should try to get rid of this, |
322 // maybe by ensuring InstantController lives as long as Browser. | 311 // maybe by ensuring InstantController lives as long as Browser. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // and the popup is closed and "goog" is replaced by the permanent_text_, | 474 // and the popup is closed and "goog" is replaced by the permanent_text_, |
486 // which is the URL of the current page. | 475 // which is the URL of the current page. |
487 // | 476 // |
488 // original_url_ is only valid when there is temporary text, and is used as | 477 // original_url_ is only valid when there is temporary text, and is used as |
489 // the unique identifier of the originally selected item. Thus, if the user | 478 // the unique identifier of the originally selected item. Thus, if the user |
490 // arrows to a different item with the same text, we can still distinguish | 479 // arrows to a different item with the same text, we can still distinguish |
491 // them and not revert all the way to the permanent_text_. | 480 // them and not revert all the way to the permanent_text_. |
492 bool has_temporary_text_; | 481 bool has_temporary_text_; |
493 GURL original_url_; | 482 GURL original_url_; |
494 | 483 |
495 // True if Instant set the current temporary text, as opposed to it being set | |
496 // due to the user arrowing up/down through the popup. This can only be true | |
497 // if |has_temporary_text_| is true. | |
498 // TODO(sreeram): This is a temporary hack. Remove it once the omnibox edit | |
499 // model/view code is decoupled from Instant (among other things). | |
500 bool is_temporary_text_set_by_instant_; | |
501 | |
502 // The index of the selected AutocompleteMatch in AutocompleteResult. This is | |
503 // needed to get the metadata details of the temporary text set by instant on | |
504 // the Local NTP. If the Instant extended is disabled or an Instant NTP is | |
505 // used, this is set to OmniboxPopupModel::kNoMatch. | |
506 size_t selected_instant_autocomplete_match_index_; | |
507 | |
508 // True if the current temporary text set by Instant is a search query; false | |
509 // if it is a URL that can be directly navigated to. This is only valid if | |
510 // |is_temporary_text_set_by_instant_| is true. This field is needed because | |
511 // Instant's temporary text doesn't come from the popup model, so we can't | |
512 // lookup its type from the current match. | |
513 bool is_instant_temporary_text_a_search_query_; | |
514 | |
515 // When the user's last action was to paste, we disallow inline autocomplete | 484 // When the user's last action was to paste, we disallow inline autocomplete |
516 // (on the theory that the user is trying to paste in a new URL or part of | 485 // (on the theory that the user is trying to paste in a new URL or part of |
517 // one, and in either case inline autocomplete would get in the way). | 486 // one, and in either case inline autocomplete would get in the way). |
518 PasteState paste_state_; | 487 PasteState paste_state_; |
519 | 488 |
520 // Whether the control key is depressed. We track this to avoid calling | 489 // Whether the control key is depressed. We track this to avoid calling |
521 // UpdatePopup() repeatedly if the user holds down the key, and to know | 490 // UpdatePopup() repeatedly if the user holds down the key, and to know |
522 // whether to trigger "ctrl-enter" behavior. | 491 // whether to trigger "ctrl-enter" behavior. |
523 ControlKeyState control_key_state_; | 492 ControlKeyState control_key_state_; |
524 | 493 |
(...skipping 20 matching lines...) Expand all Loading... |
545 // 'foo', thus TextChanged() will be called, leading to DoInstant(), but | 514 // 'foo', thus TextChanged() will be called, leading to DoInstant(), but |
546 // please don't change what you are showing. I'll commit the real match | 515 // please don't change what you are showing. I'll commit the real match |
547 // ("bar") immediately after the revert." | 516 // ("bar") immediately after the revert." |
548 // | 517 // |
549 // Without in_revert_, Instant would erroneously change its search results to | 518 // Without in_revert_, Instant would erroneously change its search results to |
550 // "foo". Because of the way the code is structured (specifically, DoInstant() | 519 // "foo". Because of the way the code is structured (specifically, DoInstant() |
551 // is NOT called for "bar" again), this leaves Instant showing results for | 520 // is NOT called for "bar" again), this leaves Instant showing results for |
552 // "foo", which is wrong. | 521 // "foo", which is wrong. |
553 bool in_revert_; | 522 bool in_revert_; |
554 | 523 |
555 // InstantController needs this in extended mode to distinguish the case in | |
556 // which it should instruct a committed search results page to revert to | |
557 // showing results for the original query. | |
558 bool in_escape_handler_; | |
559 | |
560 // Indicates if the upcoming autocomplete search is allowed to be treated as | 524 // Indicates if the upcoming autocomplete search is allowed to be treated as |
561 // an exact keyword match. If this is true then keyword mode will be | 525 // an exact keyword match. If this is true then keyword mode will be |
562 // triggered automatically if the input is "<keyword> <search string>". We | 526 // triggered automatically if the input is "<keyword> <search string>". We |
563 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 527 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
564 // This has no effect if we're already in keyword mode. | 528 // This has no effect if we're already in keyword mode. |
565 bool allow_exact_keyword_match_; | 529 bool allow_exact_keyword_match_; |
566 | 530 |
567 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 531 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
568 }; | 532 }; |
569 | 533 |
570 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 534 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
OLD | NEW |