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" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 13 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
15 #include "chrome/common/instant_types.h" | |
15 #include "chrome/common/metrics/proto/omnibox_event.pb.h" | 16 #include "chrome/common/metrics/proto/omnibox_event.pb.h" |
16 #include "content/public/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
19 #include "webkit/glue/window_open_disposition.h" | 20 #include "webkit/glue/window_open_disposition.h" |
20 | 21 |
21 class AutocompleteController; | 22 class AutocompleteController; |
22 class AutocompleteResult; | 23 class AutocompleteResult; |
23 struct InstantSuggestion; | 24 struct InstantSuggestion; |
24 class OmniboxEditController; | 25 class OmniboxEditController; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 // Returns the current autocomplete result. This logic should in the future | 211 // Returns the current autocomplete result. This logic should in the future |
211 // live in AutocompleteController but resides here for now. This method is | 212 // live in AutocompleteController but resides here for now. This method is |
212 // used by AutomationProvider::AutocompleteEditGetMatches. | 213 // used by AutomationProvider::AutocompleteEditGetMatches. |
213 const AutocompleteResult& result() const; | 214 const AutocompleteResult& result() const; |
214 | 215 |
215 // Called when the view is gaining focus. |control_down| is whether the | 216 // Called when the view is gaining focus. |control_down| is whether the |
216 // control key is down (at the time we're gaining focus). | 217 // control key is down (at the time we're gaining focus). |
217 void OnSetFocus(bool control_down); | 218 void OnSetFocus(bool control_down); |
218 | 219 |
219 // Sets the visibility of the caret in the omnibox, if it has focus. The | 220 // Sets the visibility of the caret in the omnibox, if it has focus. The |
220 // visibility of the caret is reset to visible if any of the following | 221 // visibility of the caret is reset to visible if either |
221 // happens: | 222 // - The user starts typing, or |
222 // - User starts typing in the omnibox | 223 // - We explicitly focus the omnibox again. |
223 // - User clicks in the omnibox | 224 // The latter case must be handled in three separate places--OnSetFocus(), |
224 // - Omnibox loses and then regains focus | 225 // OmniboxView::SetFocus(), and the mouse handlers in OmniboxView. See |
225 // - SetFocus() is explicitly called again | 226 // accompanying comments for why each of these is necessary. |
227 // | |
226 // Caret visibility is tracked per-tab and updates automatically upon | 228 // Caret visibility is tracked per-tab and updates automatically upon |
227 // switching tabs. | 229 // switching tabs. |
228 void SetCaretVisibility(bool visible); | 230 void SetCaretVisibility(bool visible); |
229 | 231 |
230 // Sent before |OnKillFocus| and before the popup is closed. | 232 // Sent before |OnKillFocus| and before the popup is closed. |
231 void OnWillKillFocus(gfx::NativeView view_gaining_focus); | 233 void OnWillKillFocus(gfx::NativeView view_gaining_focus); |
232 | 234 |
233 // Called when the view is losing focus. Resets some state. | 235 // Called when the view is losing focus. Resets some state. |
234 void OnKillFocus(); | 236 void OnKillFocus(); |
235 | 237 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 // current page is the user's home page. | 402 // current page is the user's home page. |
401 metrics::OmniboxEventProto::PageClassification ClassifyPage( | 403 metrics::OmniboxEventProto::PageClassification ClassifyPage( |
402 const GURL& gurl) const; | 404 const GURL& gurl) const; |
403 | 405 |
404 // Sets |match| and |alternate_nav_url| based on classifying |text|. | 406 // Sets |match| and |alternate_nav_url| based on classifying |text|. |
405 // |alternate_nav_url| may be NULL. | 407 // |alternate_nav_url| may be NULL. |
406 void ClassifyStringForPasteAndGo(const string16& text, | 408 void ClassifyStringForPasteAndGo(const string16& text, |
407 AutocompleteMatch* match, | 409 AutocompleteMatch* match, |
408 GURL* alternate_nav_url) const; | 410 GURL* alternate_nav_url) const; |
409 | 411 |
412 // Helper for SetCaretVisibility. |reason| is the reason for change that is | |
413 // passed down to InstantController when we notify it of focus state changes. | |
Peter Kasting
2012/12/07 23:22:03
Nit: How about:
Actually changes the current care
samarth
2012/12/08 00:55:47
Done.
| |
414 void SetCaretVisibilityInternal(bool visible, | |
415 OmniboxFocusChangeReason reason); | |
416 | |
410 scoped_ptr<AutocompleteController> autocomplete_controller_; | 417 scoped_ptr<AutocompleteController> autocomplete_controller_; |
411 | 418 |
412 OmniboxView* view_; | 419 OmniboxView* view_; |
413 | 420 |
414 OmniboxPopupModel* popup_; | 421 OmniboxPopupModel* popup_; |
415 | 422 |
416 OmniboxEditController* controller_; | 423 OmniboxEditController* controller_; |
417 | 424 |
418 // Whether the edit has focus. | 425 // Whether the edit has focus. |
419 bool has_focus_; | 426 bool has_focus_; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 // an exact keyword match. If this is true then keyword mode will be | 528 // an exact keyword match. If this is true then keyword mode will be |
522 // triggered automatically if the input is "<keyword> <search string>". We | 529 // triggered automatically if the input is "<keyword> <search string>". We |
523 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. | 530 // allow this when CreatedKeywordSearchByInsertingSpaceInMiddle() is true. |
524 // This has no effect if we're already in keyword mode. | 531 // This has no effect if we're already in keyword mode. |
525 bool allow_exact_keyword_match_; | 532 bool allow_exact_keyword_match_; |
526 | 533 |
527 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); | 534 DISALLOW_COPY_AND_ASSIGN(OmniboxEditModel); |
528 }; | 535 }; |
529 | 536 |
530 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ | 537 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_EDIT_MODEL_H_ |
OLD | NEW |