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