Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / chrome / renderer / searchbox / searchbox.h
blobd0821ca5aedcb6fdca58af359f6b58e90d44c10d
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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_
6 #define CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "chrome/common/instant_types.h"
13 #include "chrome/common/ntp_logging_events.h"
14 #include "chrome/common/omnibox_focus_state.h"
15 #include "chrome/renderer/instant_restricted_id_cache.h"
16 #include "content/public/renderer/render_view_observer.h"
17 #include "content/public/renderer/render_view_observer_tracker.h"
18 #include "ui/base/window_open_disposition.h"
19 #include "url/gurl.h"
21 namespace content {
22 class RenderView;
25 class SearchBox : public content::RenderViewObserver,
26 public content::RenderViewObserverTracker<SearchBox> {
27 public:
28 explicit SearchBox(content::RenderView* render_view);
29 ~SearchBox() override;
31 // Sends ChromeViewHostMsg_LogEvent to the browser.
32 void LogEvent(NTPLoggingEventType event);
34 // Sends ChromeViewHostMsg_LogMostVisitedImpression to the browser.
35 void LogMostVisitedImpression(int position, const base::string16& provider);
37 // Sends ChromeViewHostMsg_LogMostVisitedNavigation to the browser.
38 void LogMostVisitedNavigation(int position, const base::string16& provider);
40 // Sends ChromeViewHostMsg_ChromeIdentityCheck to the browser.
41 void CheckIsUserSignedInToChromeAs(const base::string16& identity);
43 // Sends ChromeViewHostMsg_HistorySyncCheck to the browser.
44 void CheckIsUserSyncingHistory();
46 // Sends ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem to the browser.
47 void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id);
49 // Generates the favicon URL of the most visited item specified by the
50 // |transient_url|. If the |transient_url| is valid, returns true and fills in
51 // |url|. If the |transient_url| is invalid, returns true and |url| is set to
52 // "chrome-search://favicon/" in order to prevent the invalid URL to be
53 // requested.
55 // Valid forms of |transient_url|:
56 // chrome-search://favicon/<view_id>/<restricted_id>
57 // chrome-search://favicon/<favicon_parameters>/<view_id>/<restricted_id>
58 bool GenerateFaviconURLFromTransientURL(const GURL& transient_url,
59 GURL* url) const;
61 // Generates the thumbnail URL of the most visited item specified by the
62 // |transient_url|. If the |transient_url| is valid, returns true and fills in
63 // |url|. If the |transient_url| is invalid, returns false and |url| is not
64 // set.
66 // Valid form of |transient_url|:
67 // chrome-search://thumb/<render_view_id>/<most_visited_item_id>
68 bool GenerateThumbnailURLFromTransientURL(const GURL& transient_url,
69 GURL* url) const;
71 // Returns the latest most visited items sent by the browser.
72 void GetMostVisitedItems(
73 std::vector<InstantMostVisitedItemIDPair>* items) const;
75 // If the |most_visited_item_id| is found in the cache, sets |item| to it
76 // and returns true.
77 bool GetMostVisitedItemWithID(InstantRestrictedID most_visited_item_id,
78 InstantMostVisitedItem* item) const;
80 // Sends ChromeViewHostMsg_FocusOmnibox to the browser.
81 void Focus();
83 // Sends ChromeViewHostMsg_SearchBoxNavigate to the browser.
84 void NavigateToURL(const GURL& url,
85 WindowOpenDisposition disposition,
86 bool is_most_visited_item_url);
88 // Sends ChromeViewHostMsg_SearchBoxPaste to the browser.
89 void Paste(const base::string16& text);
91 const ThemeBackgroundInfo& GetThemeBackgroundInfo();
92 const EmbeddedSearchRequestParams& GetEmbeddedSearchRequestParams();
94 // Sends ChromeViewHostMsg_SetVoiceSearchSupported to the browser.
95 void SetVoiceSearchSupported(bool supported);
97 // Sends ChromeViewHostMsg_StartCapturingKeyStrokes to the browser.
98 void StartCapturingKeyStrokes();
100 // Sends ChromeViewHostMsg_StopCapturingKeyStrokes to the browser.
101 void StopCapturingKeyStrokes();
103 // Sends ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions to the
104 // browser.
105 void UndoAllMostVisitedDeletions();
107 // Sends ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion to the browser.
108 void UndoMostVisitedDeletion(InstantRestrictedID most_visited_item_id);
110 bool app_launcher_enabled() const { return app_launcher_enabled_; }
111 bool is_focused() const { return is_focused_; }
112 bool is_input_in_progress() const { return is_input_in_progress_; }
113 bool is_key_capture_enabled() const { return is_key_capture_enabled_; }
114 bool display_instant_results() const { return display_instant_results_; }
115 const base::string16& query() const { return query_; }
116 int start_margin() const { return start_margin_; }
117 const InstantSuggestion& suggestion() const { return suggestion_; }
119 private:
120 // Overridden from content::RenderViewObserver:
121 bool OnMessageReceived(const IPC::Message& message) override;
123 void OnSetPageSequenceNumber(int page_seq_no);
124 void OnChromeIdentityCheckResult(const base::string16& identity,
125 bool identity_match);
126 void OnDetermineIfPageSupportsInstant();
127 void OnFocusChanged(OmniboxFocusState new_focus_state,
128 OmniboxFocusChangeReason reason);
129 void OnHistorySyncCheckResult(bool sync_history);
130 void OnMarginChange(int margin);
131 void OnMostVisitedChanged(
132 const std::vector<InstantMostVisitedItem>& items);
133 void OnPromoInformationReceived(bool is_app_launcher_enabled);
134 void OnSetDisplayInstantResults(bool display_instant_results);
135 void OnSetInputInProgress(bool input_in_progress);
136 void OnSetSuggestionToPrefetch(const InstantSuggestion& suggestion);
137 void OnSubmit(const base::string16& query,
138 const EmbeddedSearchRequestParams& params);
139 void OnThemeChanged(const ThemeBackgroundInfo& theme_info);
140 void OnToggleVoiceSearch();
142 // Returns the current zoom factor of the render view or 1 on failure.
143 double GetZoom() const;
145 // Sets the searchbox values to their initial value.
146 void Reset();
148 // Returns the URL of the Most Visited item specified by the |item_id|.
149 GURL GetURLForMostVisitedItem(InstantRestrictedID item_id) const;
151 int page_seq_no_;
152 bool app_launcher_enabled_;
153 bool is_focused_;
154 bool is_input_in_progress_;
155 bool is_key_capture_enabled_;
156 bool display_instant_results_;
157 InstantRestrictedIDCache<InstantMostVisitedItem> most_visited_items_cache_;
158 ThemeBackgroundInfo theme_info_;
159 base::string16 query_;
160 EmbeddedSearchRequestParams embedded_search_request_params_;
161 int start_margin_;
162 InstantSuggestion suggestion_;
164 DISALLOW_COPY_AND_ASSIGN(SearchBox);
167 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_