Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1320)

Side by Side Diff: chrome/renderer/searchbox/searchbox.h

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
11 #include "base/string16.h" 10 #include "base/string16.h"
12 #include "chrome/common/instant_types.h"
13 #include "chrome/common/search_types.h"
14 #include "content/public/common/page_transition_types.h"
15 #include "content/public/renderer/render_view_observer.h" 11 #include "content/public/renderer/render_view_observer.h"
16 #include "content/public/renderer/render_view_observer_tracker.h" 12 #include "content/public/renderer/render_view_observer_tracker.h"
17 #include "ui/base/window_open_disposition.h"
18 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
19 14
15 struct InstantSuggestion;
16
20 namespace content { 17 namespace content {
21 class RenderView; 18 class RenderView;
22 } 19 }
23 20
24 class SearchBox : public content::RenderViewObserver, 21 class SearchBox : public content::RenderViewObserver,
25 public content::RenderViewObserverTracker<SearchBox> { 22 public content::RenderViewObserverTracker<SearchBox> {
26 public: 23 public:
27 explicit SearchBox(content::RenderView* render_view); 24 explicit SearchBox(content::RenderView* render_view);
28 virtual ~SearchBox(); 25 virtual ~SearchBox();
29 26
30 // Sends ChromeViewHostMsg_SetSuggestions to the browser.
31 void SetSuggestions(const std::vector<InstantSuggestion>& suggestions);
32
33 // Sends ChromeViewHostMsg_ShowInstantOverlay to the browser.
34 void ShowInstantOverlay(InstantShownReason reason,
35 int height,
36 InstantSizeUnits units);
37
38 // Sends ChromeViewHostMsg_StartCapturingKeyStrokes to the browser.
39 void StartCapturingKeyStrokes();
40
41 // Sends ChromeViewHostMsg_StopCapturingKeyStrokes to the browser.
42 void StopCapturingKeyStrokes();
43
44 // Sends ChromeViewHostMsg_SearchBoxNavigate to the browser.
45 void NavigateToURL(const GURL& url,
46 content::PageTransition transition,
47 WindowOpenDisposition disposition);
48
49 // Sends ChromeViewHostMsg_InstantDeleteMostVisitedItem to the browser.
50 void DeleteMostVisitedItem(int restrict_id);
51
52 // Sends ChromeViewHostMsg_InstantUndoMostVisitedDeletion to the browser.
53 void UndoMostVisitedDeletion(int restrict_id);
54
55 // Sends ChromeViewHostMsg_InstantUndoAllMostVisitedDeletions to the browser.
56 void UndoAllMostVisitedDeletions();
57
58 const string16& query() const { return query_; } 27 const string16& query() const { return query_; }
59 bool verbatim() const { return verbatim_; } 28 bool verbatim() const { return verbatim_; }
60 size_t selection_start() const { return selection_start_; } 29 size_t selection_start() const { return selection_start_; }
61 size_t selection_end() const { return selection_end_; } 30 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_; }
64 bool display_instant_results() const { return display_instant_results_; }
65 const string16& omnibox_font() const { return omnibox_font_; }
66 size_t omnibox_font_size() const { return omnibox_font_size_; }
67 31
68 // In extended Instant, returns the start-edge margin of the location bar in 32 // Returns the bounds of the omnibox popup, adjusted for page zoom.
69 // screen pixels.
70 int GetStartMargin() const;
71
72 // Returns the bounds of the omnibox popup in screen coordinates.
73 gfx::Rect GetPopupBounds() const; 33 gfx::Rect GetPopupBounds() const;
74 34
75 const std::vector<InstantAutocompleteResult>& GetAutocompleteResults(); 35 void SetSuggestion(const InstantSuggestion& suggestion);
76 // Searchbox retains ownership of this object.
77 const InstantAutocompleteResult*
78 GetAutocompleteResultWithId(size_t restricted_id) const;
79 const ThemeBackgroundInfo& GetThemeBackgroundInfo();
80
81 // Most Visited items.
82 const std::vector<MostVisitedItem>& GetMostVisitedItems();
83
84 // Secure Urls.
85 int UrlToRestrictedId(const string16 url);
86 string16 RestrictedIdToURL(int id);
87 string16 GenerateThumbnailUrl(int id);
88 string16 GenerateFaviconUrl(int id);
89 36
90 private: 37 private:
91 // Overridden from content::RenderViewObserver: 38 // Overridden from content::RenderViewObserver:
92 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
93 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;
94 40
41 void OnDetermineInstantSupport();
95 void OnChange(const string16& query, 42 void OnChange(const string16& query,
96 bool verbatim, 43 bool verbatim,
97 size_t selection_start, 44 size_t selection_start,
98 size_t selection_end); 45 size_t selection_end);
99 void OnSubmit(const string16& query); 46 void OnSubmit(const string16& query);
100 void OnCancel(const string16& query); 47 void OnBlur(const string16& query);
101 void OnPopupResize(const gfx::Rect& bounds); 48 void OnPopupBounds(const gfx::Rect& bounds);
102 void OnMarginChange(int margin, int width);
103 void OnDetermineIfPageSupportsInstant();
104 void OnAutocompleteResults(
105 const std::vector<InstantAutocompleteResult>& results);
106 void OnUpOrDownKeyPressed(int count);
107 void OnCancelSelection(const string16& query);
108 void OnKeyCaptureChange(bool is_key_capture_enabled);
109 void OnSetDisplayInstantResults(bool display_instant_results);
110 void OnThemeChanged(const ThemeBackgroundInfo& theme_info);
111 void OnThemeAreaHeightChanged(int height);
112 void OnFontInformationReceived(const string16& omnibox_font,
113 size_t omnibox_font_size);
114 void OnMostVisitedChanged(const std::vector<MostVisitedItem>& items);
115 49
116 // Returns the current zoom factor of the render view or 1 on failure. 50 // Returns the current zoom factor of the render view or 1 on failure.
117 double GetZoom() const; 51 double GetZoom() const;
118 52
119 // Sets the searchbox values to their initial value.
120 void Reset();
121
122 string16 query_; 53 string16 query_;
123 bool verbatim_; 54 bool verbatim_;
124 size_t selection_start_; 55 size_t selection_start_;
125 size_t selection_end_; 56 size_t selection_end_;
126 size_t results_base_;
127 int start_margin_;
128 gfx::Rect popup_bounds_; 57 gfx::Rect popup_bounds_;
129 std::vector<InstantAutocompleteResult> autocomplete_results_;
130 size_t last_results_base_;
131 std::vector<InstantAutocompleteResult> last_autocomplete_results_;
132 bool is_key_capture_enabled_;
133 ThemeBackgroundInfo theme_info_;
134 bool display_instant_results_;
135 string16 omnibox_font_;
136 size_t omnibox_font_size_;
137 std::vector<MostVisitedItem> most_visited_items_;
138
139 // URL to Restricted Id mapping.
140 // TODO(dcblack): Unify this logic to work with both Most Visited and
141 // history suggestions. (crbug/175768)
142 std::map<string16, int> url_to_restricted_id_map_;
143 std::map<int, string16> restricted_id_to_url_map_;
144 int last_restricted_id_;
145 58
146 DISALLOW_COPY_AND_ASSIGN(SearchBox); 59 DISALLOW_COPY_AND_ASSIGN(SearchBox);
147 }; 60 };
148 61
149 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ 62 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698