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" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/common/instant_restricted_id_cache.h" |
12 #include "chrome/common/instant_types.h" | 13 #include "chrome/common/instant_types.h" |
13 #include "chrome/common/search_types.h" | 14 #include "chrome/common/search_types.h" |
14 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
15 #include "content/public/renderer/render_view_observer.h" | 16 #include "content/public/renderer/render_view_observer.h" |
16 #include "content/public/renderer/render_view_observer_tracker.h" | 17 #include "content/public/renderer/render_view_observer_tracker.h" |
17 #include "ui/base/window_open_disposition.h" | 18 #include "ui/base/window_open_disposition.h" |
18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class RenderView; | 22 class RenderView; |
(...skipping 30 matching lines...) Expand all Loading... |
52 // Sends ChromeViewHostMsg_InstantUndoMostVisitedDeletion to the browser. | 53 // Sends ChromeViewHostMsg_InstantUndoMostVisitedDeletion to the browser. |
53 void UndoMostVisitedDeletion(int restrict_id); | 54 void UndoMostVisitedDeletion(int restrict_id); |
54 | 55 |
55 // Sends ChromeViewHostMsg_InstantUndoAllMostVisitedDeletions to the browser. | 56 // Sends ChromeViewHostMsg_InstantUndoAllMostVisitedDeletions to the browser. |
56 void UndoAllMostVisitedDeletions(); | 57 void UndoAllMostVisitedDeletions(); |
57 | 58 |
58 const string16& query() const { return query_; } | 59 const string16& query() const { return query_; } |
59 bool verbatim() const { return verbatim_; } | 60 bool verbatim() const { return verbatim_; } |
60 size_t selection_start() const { return selection_start_; } | 61 size_t selection_start() const { return selection_start_; } |
61 size_t selection_end() const { return selection_end_; } | 62 size_t selection_end() const { return selection_end_; } |
62 int results_base() const { return results_base_; } | |
63 bool is_key_capture_enabled() const { return is_key_capture_enabled_; } | 63 bool is_key_capture_enabled() const { return is_key_capture_enabled_; } |
64 bool display_instant_results() const { return display_instant_results_; } | 64 bool display_instant_results() const { return display_instant_results_; } |
65 const string16& omnibox_font() const { return omnibox_font_; } | 65 const string16& omnibox_font() const { return omnibox_font_; } |
66 size_t omnibox_font_size() const { return omnibox_font_size_; } | 66 size_t omnibox_font_size() const { return omnibox_font_size_; } |
67 | 67 |
68 // In extended Instant, returns the start-edge margin of the location bar in | 68 // In extended Instant, returns the start-edge margin of the location bar in |
69 // screen pixels. | 69 // screen pixels. |
70 int GetStartMargin() const; | 70 int GetStartMargin() const; |
71 | 71 |
72 // Returns the bounds of the omnibox popup in screen coordinates. | 72 // Returns the bounds of the omnibox popup in screen coordinates. |
73 gfx::Rect GetPopupBounds() const; | 73 gfx::Rect GetPopupBounds() const; |
74 | 74 |
75 const std::vector<InstantAutocompleteResult>& GetAutocompleteResults(); | 75 // Returns the most recent InstantAutocompleteResults sent by the browser. |
76 // Searchbox retains ownership of this object. | 76 void GetAutocompleteResults( |
77 const InstantAutocompleteResult* | 77 std::vector<std::pair<size_t, InstantAutocompleteResult> >* |
78 GetAutocompleteResultWithId(size_t restricted_id) const; | 78 results) const; |
| 79 |
| 80 // Returns true if |restrict_id| is present in the cache and sets results to |
| 81 // a copy of the result. |
| 82 bool GetAutocompleteResultWithId(size_t restricted_id, |
| 83 InstantAutocompleteResult* result) const; |
| 84 |
79 const ThemeBackgroundInfo& GetThemeBackgroundInfo(); | 85 const ThemeBackgroundInfo& GetThemeBackgroundInfo(); |
80 | 86 |
81 // Most Visited items. | 87 // Most Visited items. |
82 const std::vector<MostVisitedItem>& GetMostVisitedItems(); | 88 const std::vector<MostVisitedItem>& GetMostVisitedItems(); |
83 | 89 |
84 // Secure Urls. | 90 // Secure Urls. |
85 int UrlToRestrictedId(const string16 url); | 91 int UrlToRestrictedId(const string16 url); |
86 string16 RestrictedIdToURL(int id); | 92 string16 RestrictedIdToURL(int id); |
87 string16 GenerateThumbnailUrl(int id); | 93 string16 GenerateThumbnailUrl(int id); |
88 string16 GenerateFaviconUrl(int id); | 94 string16 GenerateFaviconUrl(int id); |
(...skipping 27 matching lines...) Expand all Loading... |
116 // Returns the current zoom factor of the render view or 1 on failure. | 122 // Returns the current zoom factor of the render view or 1 on failure. |
117 double GetZoom() const; | 123 double GetZoom() const; |
118 | 124 |
119 // Sets the searchbox values to their initial value. | 125 // Sets the searchbox values to their initial value. |
120 void Reset(); | 126 void Reset(); |
121 | 127 |
122 string16 query_; | 128 string16 query_; |
123 bool verbatim_; | 129 bool verbatim_; |
124 size_t selection_start_; | 130 size_t selection_start_; |
125 size_t selection_end_; | 131 size_t selection_end_; |
126 size_t results_base_; | |
127 int start_margin_; | 132 int start_margin_; |
128 gfx::Rect popup_bounds_; | 133 gfx::Rect popup_bounds_; |
129 std::vector<InstantAutocompleteResult> autocomplete_results_; | 134 InstantRestrictedIdCache<InstantAutocompleteResult> |
130 size_t last_results_base_; | 135 autocomplete_results_cache_; |
131 std::vector<InstantAutocompleteResult> last_autocomplete_results_; | |
132 bool is_key_capture_enabled_; | 136 bool is_key_capture_enabled_; |
133 ThemeBackgroundInfo theme_info_; | 137 ThemeBackgroundInfo theme_info_; |
134 bool display_instant_results_; | 138 bool display_instant_results_; |
135 string16 omnibox_font_; | 139 string16 omnibox_font_; |
136 size_t omnibox_font_size_; | 140 size_t omnibox_font_size_; |
137 std::vector<MostVisitedItem> most_visited_items_; | 141 std::vector<MostVisitedItem> most_visited_items_; |
138 | 142 |
139 // URL to Restricted Id mapping. | 143 // URL to Restricted Id mapping. |
140 // TODO(dcblack): Unify this logic to work with both Most Visited and | 144 // TODO(dcblack): Unify this logic to work with both Most Visited and |
141 // history suggestions. (crbug/175768) | 145 // history suggestions. (crbug/175768) |
142 std::map<string16, int> url_to_restricted_id_map_; | 146 std::map<string16, int> url_to_restricted_id_map_; |
143 std::map<int, string16> restricted_id_to_url_map_; | 147 std::map<int, string16> restricted_id_to_url_map_; |
144 int last_restricted_id_; | 148 int last_restricted_id_; |
145 | 149 |
146 DISALLOW_COPY_AND_ASSIGN(SearchBox); | 150 DISALLOW_COPY_AND_ASSIGN(SearchBox); |
147 }; | 151 }; |
148 | 152 |
149 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 153 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
OLD | NEW |