Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / chrome / renderer / searchbox / searchbox.h
blob4b32c81ba1a69cbc1cabb96cd06aa5a0b2152dcd
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_SearchBoxDeleteMostVisitedItem to the browser.
44 void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id);
46 // Generates the favicon URL of the most visited item specified by the
47 // |transient_url|. If the |transient_url| is valid, returns true and fills in
48 // |url|. If the |transient_url| is invalid, returns true and |url| is set to
49 // "chrome-search://favicon/" in order to prevent the invalid URL to be
50 // requested.
52 // Valid forms of |transient_url|:
53 // chrome-search://favicon/<view_id>/<restricted_id>
54 // chrome-search://favicon/<favicon_parameters>/<view_id>/<restricted_id>
55 bool GenerateFaviconURLFromTransientURL(const GURL& transient_url,
56 GURL* url) const;
58 // Generates the thumbnail URL of the most visited item specified by the
59 // |transient_url|. If the |transient_url| is valid, returns true and fills in
60 // |url|. If the |transient_url| is invalid, returns false and |url| is not
61 // set.
63 // Valid form of |transient_url|:
64 // chrome-search://thumb/<render_view_id>/<most_visited_item_id>
65 bool GenerateThumbnailURLFromTransientURL(const GURL& transient_url,
66 GURL* url) const;
68 // Returns the latest most visited items sent by the browser.
69 void GetMostVisitedItems(
70 std::vector<InstantMostVisitedItemIDPair>* items) const;
72 // If the |most_visited_item_id| is found in the cache, sets |item| to it
73 // and returns true.
74 bool GetMostVisitedItemWithID(InstantRestrictedID most_visited_item_id,
75 InstantMostVisitedItem* item) const;
77 // Sends ChromeViewHostMsg_FocusOmnibox to the browser.
78 void Focus();
80 // Sends ChromeViewHostMsg_SearchBoxNavigate to the browser.
81 void NavigateToURL(const GURL& url,
82 WindowOpenDisposition disposition,
83 bool is_most_visited_item_url);
85 // Sends ChromeViewHostMsg_SearchBoxPaste to the browser.
86 void Paste(const base::string16& text);
88 const ThemeBackgroundInfo& GetThemeBackgroundInfo();
89 const EmbeddedSearchRequestParams& GetEmbeddedSearchRequestParams();
91 // Sends ChromeViewHostMsg_SetVoiceSearchSupported to the browser.
92 void SetVoiceSearchSupported(bool supported);
94 // Sends ChromeViewHostMsg_StartCapturingKeyStrokes to the browser.
95 void StartCapturingKeyStrokes();
97 // Sends ChromeViewHostMsg_StopCapturingKeyStrokes to the browser.
98 void StopCapturingKeyStrokes();
100 // Sends ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions to the
101 // browser.
102 void UndoAllMostVisitedDeletions();
104 // Sends ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion to the browser.
105 void UndoMostVisitedDeletion(InstantRestrictedID most_visited_item_id);
107 bool app_launcher_enabled() const { return app_launcher_enabled_; }
108 bool is_focused() const { return is_focused_; }
109 bool is_input_in_progress() const { return is_input_in_progress_; }
110 bool is_key_capture_enabled() const { return is_key_capture_enabled_; }
111 bool display_instant_results() const { return display_instant_results_; }
112 const base::string16& query() const { return query_; }
113 int start_margin() const { return start_margin_; }
114 const InstantSuggestion& suggestion() const { return suggestion_; }
116 private:
117 // Overridden from content::RenderViewObserver:
118 bool OnMessageReceived(const IPC::Message& message) override;
120 void OnSetPageSequenceNumber(int page_seq_no);
121 void OnChromeIdentityCheckResult(const base::string16& identity,
122 bool identity_match);
123 void OnDetermineIfPageSupportsInstant();
124 void OnFocusChanged(OmniboxFocusState new_focus_state,
125 OmniboxFocusChangeReason reason);
126 void OnMarginChange(int margin);
127 void OnMostVisitedChanged(
128 const std::vector<InstantMostVisitedItem>& items);
129 void OnPromoInformationReceived(bool is_app_launcher_enabled);
130 void OnSetDisplayInstantResults(bool display_instant_results);
131 void OnSetInputInProgress(bool input_in_progress);
132 void OnSetSuggestionToPrefetch(const InstantSuggestion& suggestion);
133 void OnSubmit(const base::string16& query,
134 const EmbeddedSearchRequestParams& params);
135 void OnThemeChanged(const ThemeBackgroundInfo& theme_info);
136 void OnToggleVoiceSearch();
138 // Returns the current zoom factor of the render view or 1 on failure.
139 double GetZoom() const;
141 // Sets the searchbox values to their initial value.
142 void Reset();
144 // Returns the URL of the Most Visited item specified by the |item_id|.
145 GURL GetURLForMostVisitedItem(InstantRestrictedID item_id) const;
147 int page_seq_no_;
148 bool app_launcher_enabled_;
149 bool is_focused_;
150 bool is_input_in_progress_;
151 bool is_key_capture_enabled_;
152 bool display_instant_results_;
153 InstantRestrictedIDCache<InstantMostVisitedItem> most_visited_items_cache_;
154 ThemeBackgroundInfo theme_info_;
155 base::string16 query_;
156 EmbeddedSearchRequestParams embedded_search_request_params_;
157 int start_margin_;
158 InstantSuggestion suggestion_;
160 DISALLOW_COPY_AND_ASSIGN(SearchBox);
163 #endif // CHROME_RENDERER_SEARCHBOX_SEARCHBOX_H_