Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 17132011: Add setVoiceSearchSupported to the searchbox API. This will be used to determine whether to show a … (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebase past 16035020, add test. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/search/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // LoadCommittedDetails::type to be NAVIGATION_TYPE_IN_PAGE. Unfortunately, 134 // LoadCommittedDetails::type to be NAVIGATION_TYPE_IN_PAGE. Unfortunately,
135 // they are different in some cases. To workaround this bug, we are checking 135 // they are different in some cases. To workaround this bug, we are checking
136 // (is_in_page || type == NAVIGATION_TYPE_IN_PAGE). Please refer to 136 // (is_in_page || type == NAVIGATION_TYPE_IN_PAGE). Please refer to
137 // crbug.com/251330 for more details. 137 // crbug.com/251330 for more details.
138 if (load_details->is_in_page || 138 if (load_details->is_in_page ||
139 load_details->type == content::NAVIGATION_TYPE_IN_PAGE) { 139 load_details->type == content::NAVIGATION_TYPE_IN_PAGE) {
140 return; 140 return;
141 } 141 }
142 142
143 model_.SetInstantSupportState(INSTANT_SUPPORT_UNKNOWN); 143 model_.SetInstantSupportState(INSTANT_SUPPORT_UNKNOWN);
144 model_.SetVoiceSearchSupported(false);
144 } 145 }
145 146
146 bool SearchTabHelper::OnMessageReceived(const IPC::Message& message) { 147 bool SearchTabHelper::OnMessageReceived(const IPC::Message& message) {
147 bool handled = true; 148 bool handled = true;
148 IPC_BEGIN_MESSAGE_MAP(SearchTabHelper, message) 149 IPC_BEGIN_MESSAGE_MAP(SearchTabHelper, message)
149 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxShowBars, 150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxShowBars,
150 OnSearchBoxShowBars) 151 OnSearchBoxShowBars)
151 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxHideBars, 152 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxHideBars,
152 OnSearchBoxHideBars) 153 OnSearchBoxHideBars)
153 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, 154 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined,
154 OnInstantSupportDetermined) 155 OnInstantSupportDetermined)
156 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported,
157 OnSetVoiceSearchSupported)
155 IPC_MESSAGE_UNHANDLED(handled = false) 158 IPC_MESSAGE_UNHANDLED(handled = false)
156 IPC_END_MESSAGE_MAP() 159 IPC_END_MESSAGE_MAP()
157 return handled; 160 return handled;
158 } 161 }
159 162
160 void SearchTabHelper::DidFinishLoad( 163 void SearchTabHelper::DidFinishLoad(
161 int64 /* frame_id */, 164 int64 /* frame_id */,
162 const GURL& /* validated_url */, 165 const GURL& /* validated_url */,
163 bool is_main_frame, 166 bool is_main_frame,
164 content::RenderViewHost* /* render_view_host */) { 167 content::RenderViewHost* /* render_view_host */) {
(...skipping 11 matching lines...) Expand all
176 type = SearchMode::MODE_SEARCH_RESULTS; 179 type = SearchMode::MODE_SEARCH_RESULTS;
177 origin = SearchMode::ORIGIN_SEARCH; 180 origin = SearchMode::ORIGIN_SEARCH;
178 } 181 }
179 if (user_input_in_progress_) 182 if (user_input_in_progress_)
180 type = SearchMode::MODE_SEARCH_SUGGESTIONS; 183 type = SearchMode::MODE_SEARCH_SUGGESTIONS;
181 184
182 if (type == SearchMode::MODE_NTP && origin == SearchMode::ORIGIN_NTP && 185 if (type == SearchMode::MODE_NTP && origin == SearchMode::ORIGIN_NTP &&
183 !popup_is_open_ && !user_text_is_empty_) { 186 !popup_is_open_ && !user_text_is_empty_) {
184 // We're switching back (|popup_is_open_| is false) to an NTP (type and 187 // We're switching back (|popup_is_open_| is false) to an NTP (type and
185 // mode are |NTP|) with suggestions (|user_text_is_empty_| is false), don't 188 // mode are |NTP|) with suggestions (|user_text_is_empty_| is false), don't
186 // modify visibility of top bars. This specific omnibox state is set when 189 // modify visibility of top bars or voice search support. This specific
187 // OmniboxEditModelChanged() is called from 190 // omnibox state is set when OmniboxEditModelChanged() is called from
188 // OmniboxEditModel::SetInputInProgress() which is called from 191 // OmniboxEditModel::SetInputInProgress() which is called from
189 // OmniboxEditModel::Revert(). 192 // OmniboxEditModel::Revert().
190 model_.SetState(SearchModel::State(SearchMode(type, origin), 193 model_.SetState(SearchModel::State(SearchMode(type, origin),
191 model_.state().top_bars_visible, 194 model_.state().top_bars_visible,
192 model_.instant_support())); 195 model_.instant_support(),
196 model_.state().voice_search_supported));
193 } else { 197 } else {
194 model_.SetMode(SearchMode(type, origin)); 198 model_.SetMode(SearchMode(type, origin));
195 } 199 }
196 } 200 }
197 201
198 void SearchTabHelper::DetermineIfPageSupportsInstant() { 202 void SearchTabHelper::DetermineIfPageSupportsInstant() {
199 Profile* profile = 203 Profile* profile =
200 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 204 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
201 if (!chrome::ShouldAssignURLToInstantRenderer(web_contents_->GetURL(), 205 if (!chrome::ShouldAssignURLToInstantRenderer(web_contents_->GetURL(),
202 profile)) { 206 profile)) {
(...skipping 22 matching lines...) Expand all
225 if (web_contents()->IsActiveEntry(page_id)) 229 if (web_contents()->IsActiveEntry(page_id))
226 model_.SetTopBarsVisible(true); 230 model_.SetTopBarsVisible(true);
227 } 231 }
228 232
229 void SearchTabHelper::OnSearchBoxHideBars(int page_id) { 233 void SearchTabHelper::OnSearchBoxHideBars(int page_id) {
230 if (web_contents()->IsActiveEntry(page_id)) { 234 if (web_contents()->IsActiveEntry(page_id)) {
231 model_.SetTopBarsVisible(false); 235 model_.SetTopBarsVisible(false);
232 Send(new ChromeViewMsg_SearchBoxBarsHidden(routing_id())); 236 Send(new ChromeViewMsg_SearchBoxBarsHidden(routing_id()));
233 } 237 }
234 } 238 }
239
240 void SearchTabHelper::OnSetVoiceSearchSupported(int page_id, bool supported) {
241 if (web_contents()->IsActiveEntry(page_id))
242 model_.SetVoiceSearchSupported(supported);
243 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698