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 26 matching lines...) Expand all Loading... |
37 // These numeric values are used in UMA logs; do not change them. | 37 // These numeric values are used in UMA logs; do not change them. |
38 enum EnteredKeywordModeMethod { | 38 enum EnteredKeywordModeMethod { |
39 ENTERED_KEYWORD_MODE_VIA_TAB = 0, | 39 ENTERED_KEYWORD_MODE_VIA_TAB = 0, |
40 ENTERED_KEYWORD_MODE_VIA_SPACE_AT_END = 1, | 40 ENTERED_KEYWORD_MODE_VIA_SPACE_AT_END = 1, |
41 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE = 2, | 41 ENTERED_KEYWORD_MODE_VIA_SPACE_IN_MIDDLE = 2, |
42 ENTERED_KEYWORD_MODE_NUM_ITEMS | 42 ENTERED_KEYWORD_MODE_NUM_ITEMS |
43 }; | 43 }; |
44 | 44 |
45 class OmniboxEditModel { | 45 class OmniboxEditModel { |
46 public: | 46 public: |
47 // Did the Omnibox focus originate via the user clicking on the Omnibox or on | 47 // Did the Omnibox focus originate via the user clicking on the Omnibox, on |
48 // the Fakebox? | 48 // the Fakebox or on the location icon? |
49 enum FocusSource { | 49 enum FocusSource { |
50 INVALID = 0, | 50 INVALID = 0, |
51 OMNIBOX = 1, | 51 OMNIBOX = 1, |
52 FAKEBOX = 2 | 52 FAKEBOX = 2, |
| 53 LOCATION_ICON = 3 |
53 }; | 54 }; |
54 | 55 |
55 struct State { | 56 struct State { |
56 State(bool user_input_in_progress, | 57 State(bool user_input_in_progress, |
57 const base::string16& user_text, | 58 const base::string16& user_text, |
58 const base::string16& gray_text, | 59 const base::string16& gray_text, |
59 const base::string16& keyword, | 60 const base::string16& keyword, |
60 bool is_keyword_hint, | 61 bool is_keyword_hint, |
61 bool url_replacement_enabled, | 62 bool url_replacement_enabled, |
62 OmniboxFocusState focus_state, | 63 OmniboxFocusState focus_state, |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 bool text_differs, | 326 bool text_differs, |
326 bool just_deleted_text, | 327 bool just_deleted_text, |
327 bool allow_keyword_ui_change); | 328 bool allow_keyword_ui_change); |
328 | 329 |
329 // Called when the current match has changed in the OmniboxController. | 330 // Called when the current match has changed in the OmniboxController. |
330 void OnCurrentMatchChanged(); | 331 void OnCurrentMatchChanged(); |
331 | 332 |
332 // Sends the current SearchProvider suggestion to the Instant page if any. | 333 // Sends the current SearchProvider suggestion to the Instant page if any. |
333 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); | 334 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); |
334 | 335 |
| 336 void set_focused_via_location_icon() { focus_source_ = LOCATION_ICON; } |
| 337 bool focused_via_location_icon() const { |
| 338 return focus_source_ == LOCATION_ICON; |
| 339 } |
| 340 |
335 // Name of the histogram tracking cut or copy omnibox commands. | 341 // Name of the histogram tracking cut or copy omnibox commands. |
336 static const char kCutOrCopyAllTextHistogram[]; | 342 static const char kCutOrCopyAllTextHistogram[]; |
337 | 343 |
338 private: | 344 private: |
339 friend class OmniboxControllerTest; | 345 friend class OmniboxControllerTest; |
340 | 346 |
341 enum PasteState { | 347 enum PasteState { |
342 NONE, // Most recent edit was not a paste. | 348 NONE, // Most recent edit was not a paste. |
343 PASTING, // In the middle of doing a paste. We need this intermediate | 349 PASTING, // In the middle of doing a paste. We need this intermediate |
344 // state because OnPaste() does the actual detection of | 350 // state because OnPaste() does the actual detection of |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 // an exact keyword match. If this is true then keyword mode will be | 554 // an exact keyword match. If this is true then keyword mode will be |
549 // triggered automatically if the input is "<keyword> <search string>". We | 555 // triggered automatically if the input is "<keyword> <search string>". We |
550 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 556 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
551 // This has no effect if we're already in keyword mode. | 557 // This has no effect if we're already in keyword mode. |
552 bool allow_exact_keyword_match_; | 558 bool allow_exact_keyword_match_; |
553 | 559 |
554 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 560 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
555 }; | 561 }; |
556 | 562 |
557 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 563 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
OLD | NEW |