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