OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> | |
9 #include <vector> | 8 #include <vector> |
10 | 9 |
11 #include "base/string16.h" | 10 #include "base/string16.h" |
12 #include "chrome/common/instant_types.h" | 11 #include "chrome/common/instant_types.h" |
13 #include "content/public/renderer/render_view_observer.h" | 12 #include "content/public/renderer/render_view_observer.h" |
14 #include "content/public/renderer/render_view_observer_tracker.h" | 13 #include "content/public/renderer/render_view_observer_tracker.h" |
15 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
16 | 15 |
17 class SearchBox : public content::RenderViewObserver, | 16 class SearchBox : public content::RenderViewObserver, |
18 public content::RenderViewObserverTracker<SearchBox> { | 17 public content::RenderViewObserverTracker<SearchBox> { |
19 public: | 18 public: |
20 explicit SearchBox(content::RenderView* render_view); | 19 explicit SearchBox(content::RenderView* render_view); |
21 virtual ~SearchBox(); | 20 virtual ~SearchBox(); |
22 | 21 |
23 // Sends ViewHostMsg_SetSuggestions to the browser. | 22 // Sends ViewHostMsg_SetSuggestions to the browser. |
24 void SetSuggestions(const std::vector<std::string>& suggestions, | 23 void SetSuggestions(const std::vector<string16>& suggestions, |
25 InstantCompleteBehavior behavior); | 24 InstantCompleteBehavior behavior); |
26 | 25 |
27 const string16& value() const { return value_; } | 26 const string16& value() const { return value_; } |
28 bool verbatim() const { return verbatim_; } | 27 bool verbatim() const { return verbatim_; } |
29 uint32 selection_start() const { return selection_start_; } | 28 size_t selection_start() const { return selection_start_; } |
30 uint32 selection_end() const { return selection_end_; } | 29 size_t selection_end() const { return selection_end_; } |
31 gfx::Rect GetRect(); | 30 gfx::Rect GetRect(); |
32 | 31 |
33 private: | 32 private: |
34 // RenderViewObserver implementation. | 33 // RenderViewObserver implementation. |
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 34 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
36 | 35 |
37 void OnChange(const string16& value, | 36 void OnChange(const string16& value, |
38 bool verbatim, | 37 bool verbatim, |
39 int selection_start, | 38 size_t selection_start, |
40 int selection_end); | 39 size_t selection_end); |
41 void OnSubmit(const string16& value, bool verbatim); | 40 void OnSubmit(const string16& value); |
42 void OnCancel(); | 41 void OnCancel(const string16& value); |
43 void OnResize(const gfx::Rect& bounds); | 42 void OnResize(const gfx::Rect& bounds); |
44 void OnDetermineIfPageSupportsInstant(const string16& value, | 43 void OnDetermineIfPageSupportsInstant(); |
45 bool verbatim, | |
46 int selection_start, | |
47 int selection_end); | |
48 | 44 |
49 // Sets the searchbox values to their initial value. | 45 // Sets the searchbox values to their initial value. |
50 void Reset(); | 46 void Reset(); |
51 | 47 |
52 string16 value_; | 48 string16 value_; |
53 bool verbatim_; | 49 bool verbatim_; |
54 uint32 selection_start_; | 50 uint32 selection_start_; |
55 uint32 selection_end_; | 51 uint32 selection_end_; |
56 gfx::Rect rect_; | 52 gfx::Rect rect_; |
57 | 53 |
58 DISALLOW_COPY_AND_ASSIGN(SearchBox); | 54 DISALLOW_COPY_AND_ASSIGN(SearchBox); |
59 }; | 55 }; |
60 | 56 |
61 #endif // CHROME_RENDERER_SEARCHBOX_H_ | 57 #endif // CHROME_RENDERER_SEARCHBOX_H_ |
OLD | NEW |