OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_SEARCHBOX_H_ | 5 #ifndef CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
6 #define CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 6 #define CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 const string16& query() const { return query_; } | 42 const string16& query() const { return query_; } |
43 bool verbatim() const { return verbatim_; } | 43 bool verbatim() const { return verbatim_; } |
44 size_t selection_start() const { return selection_start_; } | 44 size_t selection_start() const { return selection_start_; } |
45 size_t selection_end() const { return selection_end_; } | 45 size_t selection_end() const { return selection_end_; } |
46 int results_base() const { return results_base_; } | 46 int results_base() const { return results_base_; } |
47 const chrome::search::Mode& mode() const { return mode_; } | 47 const chrome::search::Mode& mode() const { return mode_; } |
48 bool is_key_capture_enabled() const { return is_key_capture_enabled_; } | 48 bool is_key_capture_enabled() const { return is_key_capture_enabled_; } |
49 bool display_instant_results() const { return display_instant_results_; } | 49 bool display_instant_results() const { return display_instant_results_; } |
50 | 50 |
51 gfx::Rect GetRect(); | 51 // These functions return the start/end margins of the page text area, |
| 52 // adjusted for the page zoom. |
| 53 int GetStartMargin() const; |
| 54 int GetEndMargin() const; |
| 55 |
| 56 // Returns the bounds of the omnibox popup in screen coordinates. |
| 57 gfx::Rect GetPopupBounds() const; |
| 58 |
52 const std::vector<InstantAutocompleteResult>& GetAutocompleteResults(); | 59 const std::vector<InstantAutocompleteResult>& GetAutocompleteResults(); |
53 // Searchbox retains ownership of this object. | 60 // Searchbox retains ownership of this object. |
54 const InstantAutocompleteResult* | 61 const InstantAutocompleteResult* |
55 GetAutocompleteResultWithId(size_t restricted_id) const; | 62 GetAutocompleteResultWithId(size_t restricted_id) const; |
56 const ThemeBackgroundInfo& GetThemeBackgroundInfo(); | 63 const ThemeBackgroundInfo& GetThemeBackgroundInfo(); |
57 int GetThemeAreaHeight(); | 64 int GetThemeAreaHeight(); |
58 | 65 |
59 private: | 66 private: |
60 // Overridden from content::RenderViewObserver: | 67 // Overridden from content::RenderViewObserver: |
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
62 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 69 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
63 | 70 |
64 void OnChange(const string16& query, | 71 void OnChange(const string16& query, |
65 bool verbatim, | 72 bool verbatim, |
66 size_t selection_start, | 73 size_t selection_start, |
67 size_t selection_end); | 74 size_t selection_end); |
68 void OnSubmit(const string16& query); | 75 void OnSubmit(const string16& query); |
69 void OnCancel(const string16& query); | 76 void OnCancel(const string16& query); |
70 void OnResize(const gfx::Rect& bounds); | 77 void OnPopupResize(const gfx::Rect& bounds); |
| 78 void OnMarginChange(int start, int end); |
71 void OnDetermineIfPageSupportsInstant(); | 79 void OnDetermineIfPageSupportsInstant(); |
72 void OnAutocompleteResults( | 80 void OnAutocompleteResults( |
73 const std::vector<InstantAutocompleteResult>& results); | 81 const std::vector<InstantAutocompleteResult>& results); |
74 void OnUpOrDownKeyPressed(int count); | 82 void OnUpOrDownKeyPressed(int count); |
75 void OnKeyCaptureChange(bool is_key_capture_enabled); | 83 void OnKeyCaptureChange(bool is_key_capture_enabled); |
76 void OnModeChanged(const chrome::search::Mode& mode); | 84 void OnModeChanged(const chrome::search::Mode& mode); |
77 void OnSetDisplayInstantResults(bool display_instant_results); | 85 void OnSetDisplayInstantResults(bool display_instant_results); |
78 void OnThemeChanged(const ThemeBackgroundInfo& theme_info); | 86 void OnThemeChanged(const ThemeBackgroundInfo& theme_info); |
79 void OnThemeAreaHeightChanged(int height); | 87 void OnThemeAreaHeightChanged(int height); |
80 | 88 |
| 89 // Returns the current zoom factor of the render view or 1 on failure. |
| 90 double GetZoom() const; |
| 91 |
81 // Sets the searchbox values to their initial value. | 92 // Sets the searchbox values to their initial value. |
82 void Reset(); | 93 void Reset(); |
83 | 94 |
84 string16 query_; | 95 string16 query_; |
85 bool verbatim_; | 96 bool verbatim_; |
86 size_t selection_start_; | 97 size_t selection_start_; |
87 size_t selection_end_; | 98 size_t selection_end_; |
88 size_t results_base_; | 99 size_t results_base_; |
89 gfx::Rect rect_; | 100 int start_margin_; |
| 101 int end_margin_; |
| 102 gfx::Rect popup_bounds_; |
90 std::vector<InstantAutocompleteResult> autocomplete_results_; | 103 std::vector<InstantAutocompleteResult> autocomplete_results_; |
91 size_t last_results_base_; | 104 size_t last_results_base_; |
92 std::vector<InstantAutocompleteResult> last_autocomplete_results_; | 105 std::vector<InstantAutocompleteResult> last_autocomplete_results_; |
93 bool is_key_capture_enabled_; | 106 bool is_key_capture_enabled_; |
94 chrome::search::Mode mode_; | 107 chrome::search::Mode mode_; |
95 ThemeBackgroundInfo theme_info_; | 108 ThemeBackgroundInfo theme_info_; |
96 int theme_area_height_; | 109 int theme_area_height_; |
97 bool display_instant_results_; | 110 bool display_instant_results_; |
98 | 111 |
99 DISALLOW_COPY_AND_ASSIGN(SearchBox); | 112 DISALLOW_COPY_AND_ASSIGN(SearchBox); |
100 }; | 113 }; |
101 | 114 |
102 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 115 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
OLD | NEW |