OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_RENDERER_SEARCHBOX_H_ | 5 #ifndef CHROME_RENDERER_SEARCHBOX_H_ |
6 #define CHROME_RENDERER_SEARCHBOX_H_ | 6 #define CHROME_RENDERER_SEARCHBOX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/common/instant_types.h" | 12 #include "chrome/common/instant_types.h" |
13 #include "content/public/renderer/render_view_observer.h" | 13 #include "content/public/renderer/render_view_observer.h" |
14 #include "content/public/renderer/render_view_observer_tracker.h" | 14 #include "content/public/renderer/render_view_observer_tracker.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 | 16 |
17 class SearchBox : public content::RenderViewObserver, | 17 class SearchBox : public content::RenderViewObserver, |
18 public content::RenderViewObserverTracker<SearchBox> { | 18 public content::RenderViewObserverTracker<SearchBox> { |
19 public: | 19 public: |
20 explicit SearchBox(content::RenderView* render_view); | 20 explicit SearchBox(content::RenderView* render_view); |
21 virtual ~SearchBox(); | 21 virtual ~SearchBox(); |
22 | 22 |
23 // Sends ViewHostMsg_SetSuggestions to the browser. | 23 // Sends ViewHostMsg_SetSuggestions to the browser. |
24 void SetSuggestions(const std::vector<std::string>& suggestions, | 24 void SetSuggestions(const std::vector<InstantSuggestion>& suggestions); |
25 InstantCompleteBehavior behavior); | 25 // Sends ViewHostMsg_SetInstantPreviewHeight to the browser. |
| 26 void SetInstantPreviewHeight(int height, InstantSizeUnits units); |
26 | 27 |
27 const string16& value() const { return value_; } | 28 const string16& value() const { return value_; } |
28 bool verbatim() const { return verbatim_; } | 29 bool verbatim() const { return verbatim_; } |
29 uint32 selection_start() const { return selection_start_; } | 30 uint32 selection_start() const { return selection_start_; } |
30 uint32 selection_end() const { return selection_end_; } | 31 uint32 selection_end() const { return selection_end_; } |
| 32 int rid_base() const { return rid_base_; } |
31 gfx::Rect GetRect(); | 33 gfx::Rect GetRect(); |
| 34 const std::vector<InstantNativeSuggestionsParts>& native_suggestions() const { |
| 35 return native_suggestions_; |
| 36 } |
| 37 int key_code() const { return key_code_; } |
| 38 const std::string& last_query() const { return last_query_; } |
| 39 const std::string& current_url() const { return current_url_; } |
| 40 bool is_focused() const { return is_focused_; } |
32 | 41 |
33 private: | 42 private: |
34 // RenderViewObserver implementation. | 43 // RenderViewObserver implementation. |
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 44 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
36 | 45 |
37 void OnChange(const string16& value, | 46 void OnChange(const string16& value, |
38 bool verbatim, | 47 bool verbatim, |
39 int selection_start, | 48 int selection_start, |
40 int selection_end); | 49 int selection_end); |
41 void OnSubmit(const string16& value, bool verbatim); | 50 void OnSubmit(const string16& value, bool verbatim); |
42 void OnCancel(); | 51 void OnCancel(); |
43 void OnResize(const gfx::Rect& bounds); | 52 void OnResize(const gfx::Rect& bounds); |
44 void OnDetermineIfPageSupportsInstant(const string16& value, | 53 void OnDetermineIfPageSupportsInstant(const string16& value, |
45 bool verbatim, | 54 bool verbatim, |
46 int selection_start, | 55 int selection_start, |
47 int selection_end); | 56 int selection_end); |
| 57 void OnNativeSuggestions( |
| 58 const std::vector<InstantNativeSuggestionsParts>& native_suggestions); |
| 59 void OnKeyPress(int key_code); |
| 60 void OnLastQuery(const std::string& last_query); |
| 61 void OnCurrentURL(const std::string& current_url); |
| 62 void OnFocused(); |
| 63 void OnBlurred(); |
48 | 64 |
49 // Sets the searchbox values to their initial value. | 65 // Sets the searchbox values to their initial value. |
50 void Reset(); | 66 void Reset(); |
51 | 67 |
52 string16 value_; | 68 string16 value_; |
53 bool verbatim_; | 69 bool verbatim_; |
54 uint32 selection_start_; | 70 uint32 selection_start_; |
55 uint32 selection_end_; | 71 uint32 selection_end_; |
| 72 int rid_base_; |
56 gfx::Rect rect_; | 73 gfx::Rect rect_; |
| 74 std::vector<InstantNativeSuggestionsParts> native_suggestions_; |
| 75 int key_code_; |
| 76 std::string last_query_; |
| 77 std::string current_url_; |
| 78 bool is_focused_; |
57 | 79 |
58 DISALLOW_COPY_AND_ASSIGN(SearchBox); | 80 DISALLOW_COPY_AND_ASSIGN(SearchBox); |
59 }; | 81 }; |
60 | 82 |
61 #endif // CHROME_RENDERER_SEARCHBOX_H_ | 83 #endif // CHROME_RENDERER_SEARCHBOX_H_ |
OLD | NEW |