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