| 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 22 matching lines...) Expand all Loading... |
| 44 void StartCapturingKeyStrokes(); | 45 void StartCapturingKeyStrokes(); |
| 45 | 46 |
| 46 // Sends ChromeViewHostMsg_StopCapturingKeyStrokes to the browser. | 47 // Sends ChromeViewHostMsg_StopCapturingKeyStrokes to the browser. |
| 47 void StopCapturingKeyStrokes(); | 48 void StopCapturingKeyStrokes(); |
| 48 | 49 |
| 49 // Sends ChromeViewHostMsg_SearchBoxNavigate to the browser. | 50 // Sends ChromeViewHostMsg_SearchBoxNavigate to the browser. |
| 50 void NavigateToURL(const GURL& url, | 51 void NavigateToURL(const GURL& url, |
| 51 content::PageTransition transition, | 52 content::PageTransition transition, |
| 52 WindowOpenDisposition disposition); | 53 WindowOpenDisposition disposition); |
| 53 | 54 |
| 54 // Sends ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem to the browser. | |
| 55 void DeleteMostVisitedItem(uint64 most_visited_item_id); | |
| 56 | |
| 57 // Sends ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion to the browser. | |
| 58 void UndoMostVisitedDeletion(uint64 most_visited_item_id); | |
| 59 | |
| 60 // Sends ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions to the | |
| 61 // browser. | |
| 62 void UndoAllMostVisitedDeletions(); | |
| 63 | |
| 64 // Shows any attached bars. | 55 // Shows any attached bars. |
| 65 void ShowBars(); | 56 void ShowBars(); |
| 66 | 57 |
| 67 // Hides any attached bars. When the bars are hidden, the "onbarshidden" | 58 // Hides any attached bars. When the bars are hidden, the "onbarshidden" |
| 68 // event is fired to notify the page. | 59 // event is fired to notify the page. |
| 69 void HideBars(); | 60 void HideBars(); |
| 70 | 61 |
| 71 const string16& query() const { return query_; } | 62 const string16& query() const { return query_; } |
| 72 bool verbatim() const { return verbatim_; } | 63 bool verbatim() const { return verbatim_; } |
| 73 size_t selection_start() const { return selection_start_; } | 64 size_t selection_start() const { return selection_start_; } |
| 74 size_t selection_end() const { return selection_end_; } | 65 size_t selection_end() const { return selection_end_; } |
| 75 int results_base() const { return results_base_; } | |
| 76 bool is_key_capture_enabled() const { return is_key_capture_enabled_; } | 66 bool is_key_capture_enabled() const { return is_key_capture_enabled_; } |
| 77 bool display_instant_results() const { return display_instant_results_; } | 67 bool display_instant_results() const { return display_instant_results_; } |
| 78 const string16& omnibox_font() const { return omnibox_font_; } | 68 const string16& omnibox_font() const { return omnibox_font_; } |
| 79 size_t omnibox_font_size() const { return omnibox_font_size_; } | 69 size_t omnibox_font_size() const { return omnibox_font_size_; } |
| 80 | 70 |
| 81 // In extended Instant, returns the start-edge margin of the location bar in | 71 // In extended Instant, returns the start-edge margin of the location bar in |
| 82 // screen pixels. | 72 // screen pixels. |
| 83 int GetStartMargin() const; | 73 int GetStartMargin() const; |
| 84 | 74 |
| 85 // Returns the bounds of the omnibox popup in screen coordinates. | 75 // Returns the bounds of the omnibox popup in screen coordinates. |
| 86 gfx::Rect GetPopupBounds() const; | 76 gfx::Rect GetPopupBounds() const; |
| 87 | 77 |
| 88 const std::vector<InstantAutocompleteResult>& GetAutocompleteResults(); | |
| 89 // Searchbox retains ownership of this object. | |
| 90 const InstantAutocompleteResult* | |
| 91 GetAutocompleteResultWithId(size_t autocomplete_result_id) const; | |
| 92 const ThemeBackgroundInfo& GetThemeBackgroundInfo(); | 78 const ThemeBackgroundInfo& GetThemeBackgroundInfo(); |
| 93 | 79 |
| 94 // Most Visited items. | 80 // --- Autocomplete result APIs. |
| 95 const std::vector<InstantMostVisitedItem>& GetMostVisitedItems() const; | 81 |
| 82 // Returns the most recent InstantAutocompleteResults sent by the browser. |
| 83 void GetAutocompleteResults( |
| 84 std::vector<InstantAutocompleteResultIDPair>* results) const; |
| 85 |
| 86 // If the |autocomplete_result_id| is found in the cache, sets |item| to it |
| 87 // and returns true. |
| 88 bool GetAutocompleteResultWithID(InstantRestrictedID autocomplete_result_id, |
| 89 InstantAutocompleteResult* result) const; |
| 90 |
| 91 // --- Most Visited items APIs. |
| 92 |
| 93 // Returns the latest most visited items sent by the browser. |
| 94 void GetMostVisitedItems( |
| 95 std::vector<InstantMostVisitedItemIDPair>* items) const; |
| 96 |
| 97 // If the |most_visited_item_id| is found in the cache, sets |item| to it |
| 98 // and returns true. |
| 99 bool GetMostVisitedItemWithID(InstantRestrictedID most_visited_item_id, |
| 100 InstantMostVisitedItem* item) const; |
| 101 |
| 102 // Sends ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem to the browser. |
| 103 void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id); |
| 104 |
| 105 // Sends ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion to the browser. |
| 106 void UndoMostVisitedDeletion(InstantRestrictedID most_visited_item_id); |
| 107 |
| 108 // Sends ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions to the |
| 109 // browser. |
| 110 void UndoAllMostVisitedDeletions(); |
| 96 | 111 |
| 97 private: | 112 private: |
| 98 // Overridden from content::RenderViewObserver: | 113 // Overridden from content::RenderViewObserver: |
| 99 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 114 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 100 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 115 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
| 101 | 116 |
| 102 void OnChange(const string16& query, | 117 void OnChange(const string16& query, |
| 103 bool verbatim, | 118 bool verbatim, |
| 104 size_t selection_start, | 119 size_t selection_start, |
| 105 size_t selection_end); | 120 size_t selection_end); |
| 106 void OnSubmit(const string16& query); | 121 void OnSubmit(const string16& query); |
| 107 void OnCancel(const string16& query); | 122 void OnCancel(const string16& query); |
| 108 void OnPopupResize(const gfx::Rect& bounds); | 123 void OnPopupResize(const gfx::Rect& bounds); |
| 109 void OnMarginChange(int margin, int width); | 124 void OnMarginChange(int margin, int width); |
| 110 void OnBarsHidden(); | 125 void OnBarsHidden(); |
| 111 void OnDetermineIfPageSupportsInstant(); | 126 void OnDetermineIfPageSupportsInstant(); |
| 112 void OnAutocompleteResults( | 127 void OnAutocompleteResults( |
| 113 const std::vector<InstantAutocompleteResult>& results); | 128 const std::vector<InstantAutocompleteResult>& results); |
| 114 void OnUpOrDownKeyPressed(int count); | 129 void OnUpOrDownKeyPressed(int count); |
| 115 void OnCancelSelection(const string16& query); | 130 void OnCancelSelection(const string16& query); |
| 116 void OnKeyCaptureChange(bool is_key_capture_enabled); | 131 void OnKeyCaptureChange(bool is_key_capture_enabled); |
| 117 void OnSetDisplayInstantResults(bool display_instant_results); | 132 void OnSetDisplayInstantResults(bool display_instant_results); |
| 118 void OnThemeChanged(const ThemeBackgroundInfo& theme_info); | 133 void OnThemeChanged(const ThemeBackgroundInfo& theme_info); |
| 119 void OnThemeAreaHeightChanged(int height); | 134 void OnThemeAreaHeightChanged(int height); |
| 120 void OnFontInformationReceived(const string16& omnibox_font, | 135 void OnFontInformationReceived(const string16& omnibox_font, |
| 121 size_t omnibox_font_size); | 136 size_t omnibox_font_size); |
| 122 void OnGrantChromeSearchAccessFromOrigin(const GURL& origin_url); | 137 void OnGrantChromeSearchAccessFromOrigin(const GURL& origin_url); |
| 123 void OnMostVisitedChanged(const std::vector<InstantMostVisitedItem>& items); | 138 void OnMostVisitedChanged( |
| 139 const std::vector<InstantMostVisitedItemIDPair>& items); |
| 124 | 140 |
| 125 // Returns the current zoom factor of the render view or 1 on failure. | 141 // Returns the current zoom factor of the render view or 1 on failure. |
| 126 double GetZoom() const; | 142 double GetZoom() const; |
| 127 | 143 |
| 128 // Sets the searchbox values to their initial value. | 144 // Sets the searchbox values to their initial value. |
| 129 void Reset(); | 145 void Reset(); |
| 130 | 146 |
| 131 string16 query_; | 147 string16 query_; |
| 132 bool verbatim_; | 148 bool verbatim_; |
| 133 size_t selection_start_; | 149 size_t selection_start_; |
| 134 size_t selection_end_; | 150 size_t selection_end_; |
| 135 size_t results_base_; | |
| 136 int start_margin_; | 151 int start_margin_; |
| 137 gfx::Rect popup_bounds_; | 152 gfx::Rect popup_bounds_; |
| 138 std::vector<InstantAutocompleteResult> autocomplete_results_; | |
| 139 size_t last_results_base_; | |
| 140 std::vector<InstantAutocompleteResult> last_autocomplete_results_; | |
| 141 bool is_key_capture_enabled_; | 153 bool is_key_capture_enabled_; |
| 142 ThemeBackgroundInfo theme_info_; | 154 ThemeBackgroundInfo theme_info_; |
| 143 bool display_instant_results_; | 155 bool display_instant_results_; |
| 144 string16 omnibox_font_; | 156 string16 omnibox_font_; |
| 145 size_t omnibox_font_size_; | 157 size_t omnibox_font_size_; |
| 146 std::vector<InstantMostVisitedItem> most_visited_items_; | 158 InstantRestrictedIDCache<InstantAutocompleteResult> |
| 159 autocomplete_results_cache_; |
| 160 InstantRestrictedIDCache<InstantMostVisitedItem> most_visited_items_cache_; |
| 147 | 161 |
| 148 DISALLOW_COPY_AND_ASSIGN(SearchBox); | 162 DISALLOW_COPY_AND_ASSIGN(SearchBox); |
| 149 }; | 163 }; |
| 150 | 164 |
| 151 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ | 165 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_ |
| OLD | NEW |