OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_IPC_SENDER_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_IPC_SENDER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/common/instant_types.h" |
| 12 #include "chrome/common/omnibox_focus_state.h" |
| 13 #include "content/public/browser/web_contents_observer.h" |
| 14 |
| 15 namespace gfx { |
| 16 class Rect; |
| 17 } |
| 18 |
| 19 namespace IPC { |
| 20 class Sender; |
| 21 } |
| 22 |
| 23 class InstantIPCSender : public content::WebContentsObserver { |
| 24 public: |
| 25 // Creates a new instance of InstantIPCSender. If |is_incognito| is true, |
| 26 // the instance will only send appropriate IPCs for incognito profiles. |
| 27 static scoped_ptr<InstantIPCSender> Create(bool is_incognito); |
| 28 |
| 29 virtual ~InstantIPCSender() {} |
| 30 |
| 31 // Sets |web_contents| as the receiver of IPCs. |
| 32 void SetContents(content::WebContents* web_contents); |
| 33 |
| 34 // Tells the page that the user typed |text| into the omnibox. If |verbatim| |
| 35 // is false, the page predicts the query the user means to type and fetches |
| 36 // results for the prediction. If |verbatim| is true, |text| is taken as the |
| 37 // exact query (no prediction is made). |selection_start| and |selection_end| |
| 38 // mark the inline autocompleted portion (i.e., blue highlighted text). The |
| 39 // omnibox caret (cursor) is at |selection_end|. |
| 40 virtual void Update(const string16& text, |
| 41 size_t selection_start, |
| 42 size_t selection_end, |
| 43 bool verbatim) {} |
| 44 |
| 45 // Tells the page that the user pressed Enter in the omnibox. |
| 46 virtual void Submit(const string16& text) {} |
| 47 |
| 48 // Tells the page that the user clicked on it. Nothing is being cancelled; the |
| 49 // poor choice of name merely reflects the IPC of the same (poor) name. |
| 50 virtual void Cancel(const string16& text) {} |
| 51 |
| 52 // Tells the page the bounds of the omnibox dropdown (in screen coordinates). |
| 53 // This is used by the page to offset the results to avoid them being covered |
| 54 // by the omnibox dropdown. |
| 55 virtual void SetPopupBounds(const gfx::Rect& bounds) {} |
| 56 |
| 57 // Tells the page the bounds of the omnibox (in screen coordinates). This is |
| 58 // used by the page to align text or assets properly with the omnibox. |
| 59 virtual void SetOmniboxBounds(const gfx::Rect& bounds) {} |
| 60 |
| 61 // Tells the page about the font information. |
| 62 virtual void SetFontInformation(const string16& omnibox_font_name, |
| 63 size_t omnibox_font_size) {} |
| 64 |
| 65 // Tells the page about the available autocomplete results. |
| 66 virtual void SendAutocompleteResults( |
| 67 const std::vector<InstantAutocompleteResult>& results) {} |
| 68 |
| 69 // Tells the page that the user pressed Up or Down in the omnibox. |count| is |
| 70 // a repeat count, negative for moving up, positive for moving down. |
| 71 virtual void UpOrDownKeyPressed(int count) {} |
| 72 |
| 73 // Tells the page that the user pressed Esc key in the omnibox. |
| 74 virtual void EscKeyPressed() {} |
| 75 |
| 76 // Tells the page that the user pressed Esc in the omnibox after having |
| 77 // arrowed down in the suggestions. The page should reset the selection to |
| 78 // the first suggestion. Arguments are the same as those for Update(). |
| 79 virtual void CancelSelection(const string16& user_text, |
| 80 size_t selection_start, |
| 81 size_t selection_end, |
| 82 bool verbatim) {} |
| 83 |
| 84 // Tells the page about the current theme background. |
| 85 virtual void SendThemeBackgroundInfo( |
| 86 const ThemeBackgroundInfo& theme_info) {} |
| 87 |
| 88 // Tells the page whether it is allowed to display Instant results. |
| 89 virtual void SetDisplayInstantResults(bool display_instant_results) {} |
| 90 |
| 91 // Tells the page that the omnibox focus has changed. |
| 92 virtual void FocusChanged(OmniboxFocusState state, |
| 93 OmniboxFocusChangeReason reason) {} |
| 94 |
| 95 // Tells the page that user input started or stopped. |
| 96 virtual void SetInputInProgress(bool input_in_progress) {} |
| 97 |
| 98 // Tells the page about new Most Visited data. |
| 99 virtual void SendMostVisitedItems( |
| 100 const std::vector<InstantMostVisitedItem>& items) {} |
| 101 |
| 102 // Tells the page to toggle voice search. |
| 103 virtual void ToggleVoiceSearch() {} |
| 104 |
| 105 protected: |
| 106 InstantIPCSender() {} |
| 107 |
| 108 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(InstantIPCSender); |
| 110 }; |
| 111 |
| 112 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_IPC_SENDER_H_ |
OLD | NEW |