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

Side by Side Diff: chrome/renderer/searchbox/searchbox_extension.cc

Issue 1428423002: Remove setVoiceSearchSupported part of EmbeddedSearch SearchBox API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac fix Created 5 years, 1 month 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_extension.h ('k') | chrome/test/data/instant_extended.html » ('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/renderer/searchbox/searchbox_extension.h" 5 #include "chrome/renderer/searchbox/searchbox_extension.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 "if (window.chrome &&" 397 "if (window.chrome &&"
398 " window.chrome.embeddedSearch &&" 398 " window.chrome.embeddedSearch &&"
399 " window.chrome.embeddedSearch.newTabPage &&" 399 " window.chrome.embeddedSearch.newTabPage &&"
400 " window.chrome.embeddedSearch.newTabPage.onthemechange &&" 400 " window.chrome.embeddedSearch.newTabPage.onthemechange &&"
401 " typeof window.chrome.embeddedSearch.newTabPage.onthemechange ==" 401 " typeof window.chrome.embeddedSearch.newTabPage.onthemechange =="
402 " 'function') {" 402 " 'function') {"
403 " window.chrome.embeddedSearch.newTabPage.onthemechange();" 403 " window.chrome.embeddedSearch.newTabPage.onthemechange();"
404 " true;" 404 " true;"
405 "}"; 405 "}";
406 406
407 static const char kDispatchToggleVoiceSearchScript[] =
408 "if (window.chrome &&"
409 " window.chrome.embeddedSearch &&"
410 " window.chrome.embeddedSearch.searchBox &&"
411 " window.chrome.embeddedSearch.searchBox.ontogglevoicesearch &&"
412 " typeof window.chrome.embeddedSearch.searchBox.ontogglevoicesearch =="
413 " 'function') {"
414 " window.chrome.embeddedSearch.searchBox.ontogglevoicesearch();"
415 " true;"
416 "}";
417
418 // ---------------------------------------------------------------------------- 407 // ----------------------------------------------------------------------------
419 408
420 class SearchBoxExtensionWrapper : public v8::Extension { 409 class SearchBoxExtensionWrapper : public v8::Extension {
421 public: 410 public:
422 explicit SearchBoxExtensionWrapper(const base::StringPiece& code); 411 explicit SearchBoxExtensionWrapper(const base::StringPiece& code);
423 412
424 // Allows v8's javascript code to call the native functions defined 413 // Allows v8's javascript code to call the native functions defined
425 // in this class for window.chrome. 414 // in this class for window.chrome.
426 v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate( 415 v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
427 v8::Isolate*, 416 v8::Isolate*,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 const v8::FunctionCallbackInfo<v8::Value>& args); 497 const v8::FunctionCallbackInfo<v8::Value>& args);
509 498
510 // Navigates the window to a URL represented by either a URL string or a 499 // Navigates the window to a URL represented by either a URL string or a
511 // restricted ID. 500 // restricted ID.
512 static void NavigateContentWindow( 501 static void NavigateContentWindow(
513 const v8::FunctionCallbackInfo<v8::Value>& args); 502 const v8::FunctionCallbackInfo<v8::Value>& args);
514 503
515 // Pastes provided value or clipboard's content into the omnibox. 504 // Pastes provided value or clipboard's content into the omnibox.
516 static void Paste(const v8::FunctionCallbackInfo<v8::Value>& args); 505 static void Paste(const v8::FunctionCallbackInfo<v8::Value>& args);
517 506
518 // Indicates whether the page supports voice search.
519 static void SetVoiceSearchSupported(
520 const v8::FunctionCallbackInfo<v8::Value>& args);
521
522 // Start capturing user key strokes. 507 // Start capturing user key strokes.
523 static void StartCapturingKeyStrokes( 508 static void StartCapturingKeyStrokes(
524 const v8::FunctionCallbackInfo<v8::Value>& args); 509 const v8::FunctionCallbackInfo<v8::Value>& args);
525 510
526 // Stop capturing user key strokes. 511 // Stop capturing user key strokes.
527 static void StopCapturingKeyStrokes( 512 static void StopCapturingKeyStrokes(
528 const v8::FunctionCallbackInfo<v8::Value>& args); 513 const v8::FunctionCallbackInfo<v8::Value>& args);
529 514
530 // Undoes the deletion of all Most Visited itens. 515 // Undoes the deletion of all Most Visited itens.
531 static void UndoAllMostVisitedDeletions( 516 static void UndoAllMostVisitedDeletions(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // static 605 // static
621 void SearchBoxExtension::DispatchSuggestionChange(blink::WebFrame* frame) { 606 void SearchBoxExtension::DispatchSuggestionChange(blink::WebFrame* frame) {
622 Dispatch(frame, kDispatchSuggestionChangeEventScript); 607 Dispatch(frame, kDispatchSuggestionChangeEventScript);
623 } 608 }
624 609
625 // static 610 // static
626 void SearchBoxExtension::DispatchThemeChange(blink::WebFrame* frame) { 611 void SearchBoxExtension::DispatchThemeChange(blink::WebFrame* frame) {
627 Dispatch(frame, kDispatchThemeChangeEventScript); 612 Dispatch(frame, kDispatchThemeChangeEventScript);
628 } 613 }
629 614
630 // static
631 void SearchBoxExtension::DispatchToggleVoiceSearch(
632 blink::WebFrame* frame) {
633 Dispatch(frame, kDispatchToggleVoiceSearchScript);
634 }
635
636 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper( 615 SearchBoxExtensionWrapper::SearchBoxExtensionWrapper(
637 const base::StringPiece& code) 616 const base::StringPiece& code)
638 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) { 617 : v8::Extension(kSearchBoxExtensionName, code.data(), 0, 0, code.size()) {
639 } 618 }
640 619
641 v8::Local<v8::FunctionTemplate> 620 v8::Local<v8::FunctionTemplate>
642 SearchBoxExtensionWrapper::GetNativeFunctionTemplate( 621 SearchBoxExtensionWrapper::GetNativeFunctionTemplate(
643 v8::Isolate* isolate, 622 v8::Isolate* isolate,
644 v8::Local<v8::String> name) { 623 v8::Local<v8::String> name) {
645 if (name->Equals( 624 if (name->Equals(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return v8::FunctionTemplate::New(isolate, LogMostVisitedImpression); 664 return v8::FunctionTemplate::New(isolate, LogMostVisitedImpression);
686 } 665 }
687 if (name->Equals( 666 if (name->Equals(
688 v8::String::NewFromUtf8(isolate, "LogMostVisitedNavigation"))) { 667 v8::String::NewFromUtf8(isolate, "LogMostVisitedNavigation"))) {
689 return v8::FunctionTemplate::New(isolate, LogMostVisitedNavigation); 668 return v8::FunctionTemplate::New(isolate, LogMostVisitedNavigation);
690 } 669 }
691 if (name->Equals(v8::String::NewFromUtf8(isolate, "NavigateContentWindow"))) 670 if (name->Equals(v8::String::NewFromUtf8(isolate, "NavigateContentWindow")))
692 return v8::FunctionTemplate::New(isolate, NavigateContentWindow); 671 return v8::FunctionTemplate::New(isolate, NavigateContentWindow);
693 if (name->Equals(v8::String::NewFromUtf8(isolate, "Paste"))) 672 if (name->Equals(v8::String::NewFromUtf8(isolate, "Paste")))
694 return v8::FunctionTemplate::New(isolate, Paste); 673 return v8::FunctionTemplate::New(isolate, Paste);
695 if (name->Equals(v8::String::NewFromUtf8(isolate, "SetVoiceSearchSupported")))
696 return v8::FunctionTemplate::New(isolate, SetVoiceSearchSupported);
697 if (name->Equals( 674 if (name->Equals(
698 v8::String::NewFromUtf8(isolate, "StartCapturingKeyStrokes"))) 675 v8::String::NewFromUtf8(isolate, "StartCapturingKeyStrokes")))
699 return v8::FunctionTemplate::New(isolate, StartCapturingKeyStrokes); 676 return v8::FunctionTemplate::New(isolate, StartCapturingKeyStrokes);
700 if (name->Equals(v8::String::NewFromUtf8(isolate, "StopCapturingKeyStrokes"))) 677 if (name->Equals(v8::String::NewFromUtf8(isolate, "StopCapturingKeyStrokes")))
701 return v8::FunctionTemplate::New(isolate, StopCapturingKeyStrokes); 678 return v8::FunctionTemplate::New(isolate, StopCapturingKeyStrokes);
702 if (name->Equals( 679 if (name->Equals(
703 v8::String::NewFromUtf8(isolate, "UndoAllMostVisitedDeletions"))) 680 v8::String::NewFromUtf8(isolate, "UndoAllMostVisitedDeletions")))
704 return v8::FunctionTemplate::New(isolate, UndoAllMostVisitedDeletions); 681 return v8::FunctionTemplate::New(isolate, UndoAllMostVisitedDeletions);
705 if (name->Equals(v8::String::NewFromUtf8(isolate, "UndoMostVisitedDeletion"))) 682 if (name->Equals(v8::String::NewFromUtf8(isolate, "UndoMostVisitedDeletion")))
706 return v8::FunctionTemplate::New(isolate, UndoMostVisitedDeletion); 683 return v8::FunctionTemplate::New(isolate, UndoMostVisitedDeletion);
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 void SearchBoxExtensionWrapper::StopCapturingKeyStrokes( 1230 void SearchBoxExtensionWrapper::StopCapturingKeyStrokes(
1254 const v8::FunctionCallbackInfo<v8::Value>& args) { 1231 const v8::FunctionCallbackInfo<v8::Value>& args) {
1255 content::RenderView* render_view = GetRenderView(); 1232 content::RenderView* render_view = GetRenderView();
1256 if (!render_view) return; 1233 if (!render_view) return;
1257 1234
1258 DVLOG(1) << render_view << " StopCapturingKeyStrokes"; 1235 DVLOG(1) << render_view << " StopCapturingKeyStrokes";
1259 SearchBox::Get(render_view)->StopCapturingKeyStrokes(); 1236 SearchBox::Get(render_view)->StopCapturingKeyStrokes();
1260 } 1237 }
1261 1238
1262 // static 1239 // static
1263 void SearchBoxExtensionWrapper::SetVoiceSearchSupported(
1264 const v8::FunctionCallbackInfo<v8::Value>& args) {
1265 content::RenderView* render_view = GetRenderView();
1266 if (!render_view) {
1267 return;
1268 }
1269 if (!args.Length()) {
1270 ThrowInvalidParameters(args);
1271 return;
1272 }
1273
1274 DVLOG(1) << render_view << " SetVoiceSearchSupported";
1275 SearchBox::Get(render_view)->SetVoiceSearchSupported(args[0]->BooleanValue());
1276 }
1277
1278 // static
1279 void SearchBoxExtensionWrapper::UndoAllMostVisitedDeletions( 1240 void SearchBoxExtensionWrapper::UndoAllMostVisitedDeletions(
1280 const v8::FunctionCallbackInfo<v8::Value>& args) { 1241 const v8::FunctionCallbackInfo<v8::Value>& args) {
1281 content::RenderView* render_view = GetRenderView(); 1242 content::RenderView* render_view = GetRenderView();
1282 if (!render_view) return; 1243 if (!render_view) return;
1283 1244
1284 DVLOG(1) << render_view << " UndoAllMostVisitedDeletions"; 1245 DVLOG(1) << render_view << " UndoAllMostVisitedDeletions";
1285 SearchBox::Get(render_view)->UndoAllMostVisitedDeletions(); 1246 SearchBox::Get(render_view)->UndoAllMostVisitedDeletions();
1286 } 1247 }
1287 1248
1288 // static 1249 // static
(...skipping 20 matching lines...) Expand all
1309 if (!render_view) return; 1270 if (!render_view) return;
1310 1271
1311 bool display_instant_results = 1272 bool display_instant_results =
1312 SearchBox::Get(render_view)->display_instant_results(); 1273 SearchBox::Get(render_view)->display_instant_results();
1313 DVLOG(1) << render_view << " GetDisplayInstantResults" << 1274 DVLOG(1) << render_view << " GetDisplayInstantResults" <<
1314 display_instant_results; 1275 display_instant_results;
1315 args.GetReturnValue().Set(display_instant_results); 1276 args.GetReturnValue().Set(display_instant_results);
1316 } 1277 }
1317 1278
1318 } // namespace extensions_v8 1279 } // namespace extensions_v8
OLDNEW
« no previous file with comments | « chrome/renderer/searchbox/searchbox_extension.h ('k') | chrome/test/data/instant_extended.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698