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