diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 00:05:23 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 00:05:23 +0000 |
commit | 8314cc5be9d5237e22f953ce1f42fb05903af6a8 (patch) | |
tree | b0e32fe9b97b059c7076d05a8f64dee9df3372e7 | |
parent | d244de1a81fcdc87d3abae1e140d156ba31f907c (diff) | |
download | chromium_src-8314cc5be9d5237e22f953ce1f42fb05903af6a8.zip chromium_src-8314cc5be9d5237e22f953ce1f42fb05903af6a8.tar.gz chromium_src-8314cc5be9d5237e22f953ce1f42fb05903af6a8.tar.bz2 |
Add --enable-speech-input switch and set ENABLE_INPUT_SPEECH=1
Flip the compile-time enable switch for speech input to on and add a
command-line switch to put the functionality behind. The command-line
flag will be used both on the Chromium side and in WebKit via
WebRuntimeFeatures.
This CL depends on the webkit patch https://bugs.webkit.org/show_bug.cgi?id=43146
BUG=none
TEST=browser_tests --gtest_filter=SpeechInputEnableSwitchTest.*
Review URL: http://codereview.chromium.org/3064017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54235 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/features_override.gypi | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rw-r--r-- | chrome/browser/speech/enable_speech_input_switch_browsertest.cc | 36 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 3 | ||||
-rw-r--r-- | chrome/test/data/speech/enable_speech_input_switch_test.html | 22 |
8 files changed, 68 insertions, 0 deletions
diff --git a/build/features_override.gypi b/build/features_override.gypi index c6d9dc9..c7f19b1 100644 --- a/build/features_override.gypi +++ b/build/features_override.gypi @@ -25,6 +25,7 @@ 'ENABLE_GEOLOCATION=1', 'ENABLE_ICONDATABASE=0', 'ENABLE_INDEXED_DATABASE=1', + 'ENABLE_INPUT_SPEECH=1', 'ENABLE_JAVASCRIPT_DEBUGGER=1', 'ENABLE_JSC_MULTIPLE_THREADS=0', 'ENABLE_METER_TAG=1', diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 2506617..0fc328d 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -548,6 +548,7 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kDisableApplicationCache, switches::kEnableDeviceOrientation, switches::kEnableIndexedDatabase, + switches::kEnableSpeechInput, switches::kDisableGeolocation, switches::kShowPaintRects, switches::kEnableOpenMax, diff --git a/chrome/browser/speech/enable_speech_input_switch_browsertest.cc b/chrome/browser/speech/enable_speech_input_switch_browsertest.cc new file mode 100644 index 0000000..c7381d3 --- /dev/null +++ b/chrome/browser/speech/enable_speech_input_switch_browsertest.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+
+class SpeechInputEnableSwitchTest : public InProcessBrowserTest {
+ public:
+ GURL testUrl(const FilePath::CharType* filename) {
+ const FilePath kTestDir(FILE_PATH_LITERAL("speech"));
+ return ui_test_utils::GetTestUrl(kTestDir, FilePath(filename));
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(SpeechInputEnableSwitchTest, UnavailabilityTest) {
+ // Test that speech input is not available to a web page if
+ // the runtime switch is disabled.
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ bool has_switch = command_line.HasSwitch(switches::kEnableSpeechInput);
+ ASSERT_FALSE(has_switch) << "This test does not make sense if "
+ << "--enable-speech-input is set.";
+
+ GURL test_url = testUrl(
+ FILE_PATH_LITERAL("enable_speech_input_switch_test.html"));
+ ui_test_utils::NavigateToURL(browser(), test_url);
+ std::string status = browser()->GetSelectedTabContents()->GetURL().ref();
+ EXPECT_EQ("pass", status) << "Page detected speech input properties.";
+}
+
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 7ee4b16..cbf67c9 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1599,6 +1599,7 @@ 'browser/renderer_host/test/render_view_host_manager_browsertest.cc', 'browser/safe_browsing/safe_browsing_browsertest.cc', 'browser/sessions/session_restore_browsertest.cc', + 'browser/speech/enable_speech_input_switch_browsertest.cc', 'browser/ssl/ssl_browser_tests.cc', 'browser/task_manager_browsertest.cc', 'browser/views/browser_actions_container_browsertest.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 3aadd0a..de031cb 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -376,6 +376,9 @@ const char kEnablePrintPreview[] = "enable-print-preview"; // parameter to indicate if the provider should be the default. const char kEnableSearchProviderApiV2[] = "enable-search-provider-api-v2"; +// Enables speech input. +const char kEnableSpeechInput[] = "enable-speech-input"; + // Enables StatsTable, logging statistics to a global named shared memory table. const char kEnableStatsTable[] = "enable-stats-table"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index b0f3c28..a28cf6b 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -122,6 +122,7 @@ extern const char kEnablePreparsedJsCaching[]; extern const char kEnablePreconnect[]; extern const char kEnablePrintPreview[]; extern const char kEnableSearchProviderApiV2[]; +extern const char kEnableSpeechInput[]; extern const char kEnableStatsTable[]; extern const char kEnableSync[]; extern const char kEnableSyncAutofill[]; diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 03e468a..060ff77 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -912,6 +912,9 @@ void RenderThread::EnsureWebKitInitialized() { WebRuntimeFeatures::enableDeviceOrientation( command_line.HasSwitch(switches::kEnableDeviceOrientation)); + + WebRuntimeFeatures::enableSpeechInput( + command_line.HasSwitch(switches::kEnableSpeechInput)); } void RenderThread::IdleHandler() { diff --git a/chrome/test/data/speech/enable_speech_input_switch_test.html b/chrome/test/data/speech/enable_speech_input_switch_test.html new file mode 100644 index 0000000..9524c7c --- /dev/null +++ b/chrome/test/data/speech/enable_speech_input_switch_test.html @@ -0,0 +1,22 @@ +<html>
+ <head>
+ <title>SpeechInputEnableSwitchTest</title>
+ <script type="text/javascript">
+ function run() {
+ var inputField = document.getElementById('inputField');
+ if (inputField.speech) {
+ document.getElementById('status').innerHTML = 'FAIL';
+ document.location = '#fail';
+ } else {
+ document.getElementById('status').innerHTML = 'PASS';
+ document.location = '#pass';
+ }
+ }
+ </script>
+ </head>
+ <body onload="run()">
+ <input id='inputField' speech><br>
+ <div id="status">Running...</div>
+ </body>
+</html>
+
|