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 25 matching lines...) Expand all Loading... |
36 // These numeric values are used in UMA logs; do not change them. | 36 // These numeric values are used in UMA logs; do not change them. |
37 enum EnteredKeywordModeMethod { | 37 enum EnteredKeywordModeMethod { |
38 ENTERED_KEYWORD_MODE_VIA_TAB = 0, | 38 ENTERED_KEYWORD_MODE_VIA_TAB = 0, |
39 ENTERED_KEYWORD_MODE_VIA_SPACE_AT_END = 1, | 39 ENTERED_KEYWORD_MODE_VIA_SPACE_AT_END = 1, |
40 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE = 2, | 40 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE = 2, |
41 ENTERED_KEYWORD_MODE_NUM_ITEMS | 41 ENTERED_KEYWORD_MODE_NUM_ITEMS |
42 }; | 42 }; |
43 | 43 |
44 class OmniboxEditModel { | 44 class OmniboxEditModel { |
45 public: | 45 public: |
| 46 // Did the Omnibox focus originate via the user clicking on the Omnibox or on |
| 47 // the Fakebox? |
| 48 enum FocusSource { |
| 49 INVALID = 0, |
| 50 OMNIBOX = 1, |
| 51 FAKEBOX = 2 |
| 52 }; |
| 53 |
46 struct State { | 54 struct State { |
47 State(bool user_input_in_progress, | 55 State(bool user_input_in_progress, |
48 const string16& user_text, | 56 const string16& user_text, |
49 const string16& gray_text, | 57 const string16& gray_text, |
50 const string16& keyword, | 58 const string16& keyword, |
51 bool is_keyword_hint, | 59 bool is_keyword_hint, |
52 OmniboxFocusState focus_state); | 60 OmniboxFocusState focus_state, |
| 61 FocusSource focus_source); |
53 ~State(); | 62 ~State(); |
54 | 63 |
55 bool user_input_in_progress; | 64 bool user_input_in_progress; |
56 const string16 user_text; | 65 const string16 user_text; |
57 const string16 gray_text; | 66 const string16 gray_text; |
58 const string16 keyword; | 67 const string16 keyword; |
59 const bool is_keyword_hint; | 68 const bool is_keyword_hint; |
60 OmniboxFocusState focus_state; | 69 OmniboxFocusState focus_state; |
| 70 FocusSource focus_source; |
61 }; | 71 }; |
62 | 72 |
63 OmniboxEditModel(OmniboxView* view, | 73 OmniboxEditModel(OmniboxView* view, |
64 OmniboxEditController* controller, | 74 OmniboxEditController* controller, |
65 Profile* profile); | 75 Profile* profile); |
66 virtual ~OmniboxEditModel(); | 76 virtual ~OmniboxEditModel(); |
67 | 77 |
68 // TODO(beaudoin): Remove this accessor when the AutocompleteController has | 78 // TODO(beaudoin): Remove this accessor when the AutocompleteController has |
69 // completely moved to OmniboxController. | 79 // completely moved to OmniboxController. |
70 AutocompleteController* autocomplete_controller() const { | 80 AutocompleteController* autocomplete_controller() const { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 scoped_ptr<OmniboxController> omnibox_controller_; | 413 scoped_ptr<OmniboxController> omnibox_controller_; |
404 | 414 |
405 OmniboxView* view_; | 415 OmniboxView* view_; |
406 | 416 |
407 OmniboxEditController* controller_; | 417 OmniboxEditController* controller_; |
408 | 418 |
409 scoped_ptr<OmniboxCurrentPageDelegate> delegate_; | 419 scoped_ptr<OmniboxCurrentPageDelegate> delegate_; |
410 | 420 |
411 OmniboxFocusState focus_state_; | 421 OmniboxFocusState focus_state_; |
412 | 422 |
| 423 // Used to keep track whether the input currently in progress originated by |
| 424 // focusing in the Omnibox or in the Fakebox. This will be INVALID if no input |
| 425 // is in progress or the Omnibox is not focused. |
| 426 FocusSource focus_source_; |
| 427 |
413 // The URL of the currently displayed page. | 428 // The URL of the currently displayed page. |
414 string16 permanent_text_; | 429 string16 permanent_text_; |
415 | 430 |
416 // This flag is true when the user has modified the contents of the edit, but | 431 // This flag is true when the user has modified the contents of the edit, but |
417 // not yet accepted them. We use this to determine when we need to save | 432 // not yet accepted them. We use this to determine when we need to save |
418 // state (on switching tabs) and whether changes to the page URL should be | 433 // state (on switching tabs) and whether changes to the page URL should be |
419 // immediately displayed. | 434 // immediately displayed. |
420 // This flag will be true in a superset of the cases where the popup is open. | 435 // This flag will be true in a superset of the cases where the popup is open. |
421 bool user_input_in_progress_; | 436 bool user_input_in_progress_; |
422 | 437 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // an exact keyword match. If this is true then keyword mode will be | 522 // an exact keyword match. If this is true then keyword mode will be |
508 // triggered automatically if the input is "<keyword> <search string>". We | 523 // triggered automatically if the input is "<keyword> <search string>". We |
509 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 524 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
510 // This has no effect if we're already in keyword mode. | 525 // This has no effect if we're already in keyword mode. |
511 bool allow_exact_keyword_match_; | 526 bool allow_exact_keyword_match_; |
512 | 527 |
513 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 528 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
514 }; | 529 }; |
515 | 530 |
516 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 531 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
OLD | NEW |