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

Side by Side Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 7258007: Move the tts and ttsEngine APIs out of experimental, and give (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This script contains privileged chrome extension related javascript APIs. 5 // This script contains privileged chrome extension related javascript APIs.
6 // It is loaded by pages whose URL has the chrome-extension protocol. 6 // It is loaded by pages whose URL has the chrome-extension protocol.
7 7
8 var chrome = chrome || {}; 8 var chrome = chrome || {};
9 (function() { 9 (function() {
10 native function GetExtensionAPIDefinition(); 10 native function GetExtensionAPIDefinition();
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 var suggestCallback = function(suggestions) { 525 var suggestCallback = function(suggestions) {
526 chrome.omnibox.sendSuggestions(requestId, suggestions); 526 chrome.omnibox.sendSuggestions(requestId, suggestions);
527 }; 527 };
528 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]); 528 chrome.Event.prototype.dispatch.apply(this, [text, suggestCallback]);
529 }; 529 };
530 } 530 }
531 531
532 function setupTtsEvents() { 532 function setupTtsEvents() {
533 chromeHidden.tts = {}; 533 chromeHidden.tts = {};
534 chromeHidden.tts.handlers = {}; 534 chromeHidden.tts.handlers = {};
535 chrome.experimental.ttsEngine.onSpeak.dispatch = 535 chrome.ttsEngine.onSpeak.dispatch =
536 function(text, options, requestId) { 536 function(text, options, requestId) {
537 var sendTtsEvent = function(event) { 537 var sendTtsEvent = function(event) {
538 chrome.experimental.ttsEngine.sendTtsEvent(requestId, event); 538 chrome.ttsEngine.sendTtsEvent(requestId, event);
539 }; 539 };
540 chrome.Event.prototype.dispatch.apply( 540 chrome.Event.prototype.dispatch.apply(
541 this, [text, options, sendTtsEvent]); 541 this, [text, options, sendTtsEvent]);
542 }; 542 };
543 try { 543 try {
544 chrome.experimental.ttsEngine.onEvent.addListener( 544 chrome.tts.onEvent.addListener(
545 function(event) { 545 function(event) {
546 var eventHandler = chromeHidden.tts.handlers[event.srcId]; 546 var eventHandler = chromeHidden.tts.handlers[event.srcId];
547 if (eventHandler) { 547 if (eventHandler) {
548 eventHandler({ 548 eventHandler({
549 type: event.type, 549 type: event.type,
550 charIndex: event.charIndex, 550 charIndex: event.charIndex,
551 errorMessage: event.errorMessage 551 errorMessage: event.errorMessage
552 }); 552 });
553 if (event.isFinalEvent) { 553 if (event.isFinalEvent) {
554 delete chromeHidden.tts.handlers[event.srcId]; 554 delete chromeHidden.tts.handlers[event.srcId];
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 var suggestions = []; 1001 var suggestions = [];
1002 for (var i = 0; i < userSuggestions.length; i++) { 1002 for (var i = 0; i < userSuggestions.length; i++) {
1003 var parseResult = parseOmniboxDescription( 1003 var parseResult = parseOmniboxDescription(
1004 userSuggestions[i].description); 1004 userSuggestions[i].description);
1005 parseResult.content = userSuggestions[i].content; 1005 parseResult.content = userSuggestions[i].content;
1006 suggestions.push(parseResult); 1006 suggestions.push(parseResult);
1007 } 1007 }
1008 return [requestId, suggestions]; 1008 return [requestId, suggestions];
1009 }; 1009 };
1010 1010
1011 apiFunctions["experimental.tts.speak"].handleRequest = function() { 1011 apiFunctions["tts.speak"].handleRequest = function() {
1012 var args = arguments; 1012 var args = arguments;
1013 if (args.length > 1 && args[1] && args[1].onEvent) { 1013 if (args.length > 1 && args[1] && args[1].onEvent) {
1014 var id = GetNextTtsEventId(); 1014 var id = GetNextTtsEventId();
1015 args[1].srcId = id; 1015 args[1].srcId = id;
1016 chromeHidden.tts.handlers[id] = args[1].onEvent; 1016 chromeHidden.tts.handlers[id] = args[1].onEvent;
1017 } 1017 }
1018 sendRequest(this.name, args, this.definition.parameters); 1018 sendRequest(this.name, args, this.definition.parameters);
1019 return id; 1019 return id;
1020 }; 1020 };
1021 1021
1022 if (chrome.test) { 1022 if (chrome.test) {
1023 chrome.test.getApiDefinitions = GetExtensionAPIDefinition; 1023 chrome.test.getApiDefinitions = GetExtensionAPIDefinition;
1024 } 1024 }
1025 1025
1026 setupPageActionEvents(extensionId); 1026 setupPageActionEvents(extensionId);
1027 setupToolstripEvents(GetRenderViewId()); 1027 setupToolstripEvents(GetRenderViewId());
1028 setupHiddenContextMenuEvent(extensionId); 1028 setupHiddenContextMenuEvent(extensionId);
1029 setupOmniboxEvents(); 1029 setupOmniboxEvents();
1030 setupTtsEvents(); 1030 setupTtsEvents();
1031 }); 1031 });
1032 1032
1033 if (!chrome.experimental) 1033 if (!chrome.experimental)
1034 chrome.experimental = {}; 1034 chrome.experimental = {};
1035 1035
1036 if (!chrome.experimental.accessibility) 1036 if (!chrome.experimental.accessibility)
1037 chrome.experimental.accessibility = {}; 1037 chrome.experimental.accessibility = {};
1038 1038
1039 if (!chrome.experimental.tts) 1039 if (!chrome.tts)
1040 chrome.experimental.tts = {}; 1040 chrome.tts = {};
1041 1041
1042 if (!chrome.experimental.ttsEngine) 1042 if (!chrome.ttsEngine)
1043 chrome.experimental.ttsEngine = {}; 1043 chrome.ttsEngine = {};
1044 })(); 1044 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698