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

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.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/renderer/searchbox/searchbox.cc ('k') | no next file » | 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/renderer/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 const v8::FunctionCallbackInfo<v8::Value>& args); 595 const v8::FunctionCallbackInfo<v8::Value>& args);
596 596
597 // Sets the search box text, completely replacing what the user typed. 597 // Sets the search box text, completely replacing what the user typed.
598 static void SetQuery(const v8::FunctionCallbackInfo<v8::Value>& args); 598 static void SetQuery(const v8::FunctionCallbackInfo<v8::Value>& args);
599 599
600 // Like |SetQuery| but uses a restricted autocomplete result ID to identify 600 // Like |SetQuery| but uses a restricted autocomplete result ID to identify
601 // the text. 601 // the text.
602 static void SetQueryFromAutocompleteResult( 602 static void SetQueryFromAutocompleteResult(
603 const v8::FunctionCallbackInfo<v8::Value>& args); 603 const v8::FunctionCallbackInfo<v8::Value>& args);
604 604
605 // Indicates whether the page supports voice search.
606 static void SetVoiceSearchSupported(
607 const v8::FunctionCallbackInfo<v8::Value>& args);
608
605 // Requests the overlay be shown with the specified contents and height. 609 // Requests the overlay be shown with the specified contents and height.
606 static void ShowOverlay(const v8::FunctionCallbackInfo<v8::Value>& args); 610 static void ShowOverlay(const v8::FunctionCallbackInfo<v8::Value>& args);
607 611
608 // Sets the focus to the omnibox. 612 // Sets the focus to the omnibox.
609 static void FocusOmnibox(const v8::FunctionCallbackInfo<v8::Value>& args); 613 static void FocusOmnibox(const v8::FunctionCallbackInfo<v8::Value>& args);
610 614
611 // Start capturing user key strokes. 615 // Start capturing user key strokes.
612 static void StartCapturingKeyStrokes( 616 static void StartCapturingKeyStrokes(
613 const v8::FunctionCallbackInfo<v8::Value>& args); 617 const v8::FunctionCallbackInfo<v8::Value>& args);
614 618
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 if (name->Equals(v8::String::New("SetSuggestions"))) 710 if (name->Equals(v8::String::New("SetSuggestions")))
707 return v8::FunctionTemplate::New(SetSuggestions); 711 return v8::FunctionTemplate::New(SetSuggestions);
708 if (name->Equals(v8::String::New("SetSuggestion"))) 712 if (name->Equals(v8::String::New("SetSuggestion")))
709 return v8::FunctionTemplate::New(SetSuggestion); 713 return v8::FunctionTemplate::New(SetSuggestion);
710 if (name->Equals(v8::String::New("SetSuggestionFromAutocompleteResult"))) 714 if (name->Equals(v8::String::New("SetSuggestionFromAutocompleteResult")))
711 return v8::FunctionTemplate::New(SetSuggestionFromAutocompleteResult); 715 return v8::FunctionTemplate::New(SetSuggestionFromAutocompleteResult);
712 if (name->Equals(v8::String::New("SetQuery"))) 716 if (name->Equals(v8::String::New("SetQuery")))
713 return v8::FunctionTemplate::New(SetQuery); 717 return v8::FunctionTemplate::New(SetQuery);
714 if (name->Equals(v8::String::New("SetQueryFromAutocompleteResult"))) 718 if (name->Equals(v8::String::New("SetQueryFromAutocompleteResult")))
715 return v8::FunctionTemplate::New(SetQueryFromAutocompleteResult); 719 return v8::FunctionTemplate::New(SetQueryFromAutocompleteResult);
720 if (name->Equals(v8::String::New("SetVoiceSearchSupported")))
721 return v8::FunctionTemplate::New(SetVoiceSearchSupported);
716 if (name->Equals(v8::String::New("ShowOverlay"))) 722 if (name->Equals(v8::String::New("ShowOverlay")))
717 return v8::FunctionTemplate::New(ShowOverlay); 723 return v8::FunctionTemplate::New(ShowOverlay);
718 if (name->Equals(v8::String::New("FocusOmnibox"))) 724 if (name->Equals(v8::String::New("FocusOmnibox")))
719 return v8::FunctionTemplate::New(FocusOmnibox); 725 return v8::FunctionTemplate::New(FocusOmnibox);
720 if (name->Equals(v8::String::New("StartCapturingKeyStrokes"))) 726 if (name->Equals(v8::String::New("StartCapturingKeyStrokes")))
721 return v8::FunctionTemplate::New(StartCapturingKeyStrokes); 727 return v8::FunctionTemplate::New(StartCapturingKeyStrokes);
722 if (name->Equals(v8::String::New("StopCapturingKeyStrokes"))) 728 if (name->Equals(v8::String::New("StopCapturingKeyStrokes")))
723 return v8::FunctionTemplate::New(StopCapturingKeyStrokes); 729 return v8::FunctionTemplate::New(StopCapturingKeyStrokes);
724 if (name->Equals(v8::String::New("UndoAllMostVisitedDeletions"))) 730 if (name->Equals(v8::String::New("UndoAllMostVisitedDeletions")))
725 return v8::FunctionTemplate::New(UndoAllMostVisitedDeletions); 731 return v8::FunctionTemplate::New(UndoAllMostVisitedDeletions);
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 INSTANT_SUGGESTION_SEARCH, 1263 INSTANT_SUGGESTION_SEARCH,
1258 string16(), 1264 string16(),
1259 result.autocomplete_match_index)); 1265 result.autocomplete_match_index));
1260 } 1266 }
1261 1267
1262 search_box->SetSuggestions(suggestions); 1268 search_box->SetSuggestions(suggestions);
1263 search_box->MarkQueryAsRestricted(); 1269 search_box->MarkQueryAsRestricted();
1264 } 1270 }
1265 1271
1266 // static 1272 // static
1273 void SearchBoxExtensionWrapper::SetVoiceSearchSupported(
1274 const v8::FunctionCallbackInfo<v8::Value>& args) {
1275 content::RenderView* render_view = GetRenderView();
1276 if (!render_view || args.Length() < 1) return;
1277
1278 DVLOG(1) << render_view << " SetVoiceSearchSupported";
1279 SearchBox::Get(render_view)->SetVoiceSearchSupported(args[0]->BooleanValue());
1280 }
1281
1282 // static
1267 void SearchBoxExtensionWrapper::ShowOverlay( 1283 void SearchBoxExtensionWrapper::ShowOverlay(
1268 const v8::FunctionCallbackInfo<v8::Value>& args) { 1284 const v8::FunctionCallbackInfo<v8::Value>& args) {
1269 content::RenderView* render_view = GetRenderView(); 1285 content::RenderView* render_view = GetRenderView();
1270 if (!render_view || args.Length() < 1) return; 1286 if (!render_view || args.Length() < 1) return;
1271 1287
1272 int height = 100; 1288 int height = 100;
1273 InstantSizeUnits units = INSTANT_SIZE_PERCENT; 1289 InstantSizeUnits units = INSTANT_SIZE_PERCENT;
1274 if (args[0]->IsInt32()) { 1290 if (args[0]->IsInt32()) {
1275 height = args[0]->Int32Value(); 1291 height = args[0]->Int32Value();
1276 units = INSTANT_SIZE_PIXELS; 1292 units = INSTANT_SIZE_PIXELS;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 Dispatch(frame, kDispatchInputCancelScript); 1560 Dispatch(frame, kDispatchInputCancelScript);
1545 } 1561 }
1546 1562
1547 // static 1563 // static
1548 void SearchBoxExtension::DispatchToggleVoiceSearch( 1564 void SearchBoxExtension::DispatchToggleVoiceSearch(
1549 WebKit::WebFrame* frame) { 1565 WebKit::WebFrame* frame) {
1550 Dispatch(frame, kDispatchToggleVoiceSearchScript); 1566 Dispatch(frame, kDispatchToggleVoiceSearchScript);
1551 } 1567 }
1552 1568
1553 } // namespace extensions_v8 1569 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698