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