Commit 04bba6df authored by Roberto Carrillo's avatar Roberto Carrillo Committed by Commit Bot

Revert "Add speech recognition API wrapper in VR"

This reverts commit 37d5fc56.

Reason for revert: Speculative revert for SOLINK failure in https://build.chromium.org/p/chromium.linux/builders/Android%20Arm64%20Builder%20%28dbg%29/builds/46752

Original change's description:
> Add speech recognition API wrapper in VR
> 
> This CL adds an invisible button which should trigger voice search.
> Note that the UI will change significantly. The main purpose of this
> CL is to add speech recognition API wrapper.
> 
> Bug: 773767
> Change-Id: If760a88cc950b231d3b2c14b94403afd8f23c56b
> Reviewed-on: https://chromium-review.googlesource.com/701174
> Commit-Queue: Biao She <bshe@chromium.org>
> Reviewed-by: Ian Vollick <vollick@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#510182}

TBR=vollick@chromium.org,bshe@chromium.org

Change-Id: I2943d46e3d7d160852371a33f16e44ba1d62fbb6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 773767
Reviewed-on: https://chromium-review.googlesource.com/729319Reviewed-by: default avatarRoberto Carrillo <robertocn@chromium.org>
Commit-Queue: Roberto Carrillo <robertocn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510219}
parent 2bdaf0af
......@@ -49,7 +49,6 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver;
import org.chromium.chrome.browser.tabmodel.TabModelUtils;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.common.BrowserControlsState;
import org.chromium.ui.UiUtils;
......@@ -735,13 +734,6 @@ public class VrShellImpl
UrlConstants.NTP_URL, TabLaunchType.FROM_CHROME_UI);
}
@CalledByNative
private void loadUrl(String url) {
// TODO(bshe): reuse voice suggestion provider if possible.
assert mTab != null;
mTab.loadUrl(new LoadUrlParams(url));
}
@VisibleForTesting
@Override
@CalledByNative
......
......@@ -146,13 +146,6 @@ void VrGLThread::OnContentScreenBoundsChanged(const gfx::SizeF& bounds) {
weak_vr_shell_, bounds));
}
void VrGLThread::SetVoiceSearchActivate(bool activate) {
DCHECK(OnGlThread());
main_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&VrShell::SetVoiceSearchActivate, weak_vr_shell_, activate));
}
void VrGLThread::SetFullscreen(bool enabled) {
DCHECK(OnMainThread());
task_runner()->PostTask(
......
......@@ -58,7 +58,6 @@ class VrGLThread : public base::android::JavaHandlerThread,
void OnExitVrPromptResult(vr::UiUnsupportedMode reason,
vr::ExitVrPromptChoice choice) override;
void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) override;
void SetVoiceSearchActivate(bool activate) override;
// vr::BrowserUiInterface implementation (Browser calling to UI).
void SetWebVrMode(bool enabled, bool show_toast) override;
......
......@@ -27,19 +27,14 @@
#include "chrome/browser/android/vr_shell/vr_shell_gl.h"
#include "chrome/browser/android/vr_shell/vr_usage_monitor.h"
#include "chrome/browser/android/vr_shell/vr_web_contents_observer.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/vr/toolbar_helper.h"
#include "chrome/browser/vr/ui_interface.h"
#include "chrome/browser/vr/ui_scene_manager.h"
#include "chrome/browser/vr/vr_tab_helper.h"
#include "chrome/browser/vr/web_contents_event_forwarder.h"
#include "chrome/common/url_constants.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
......@@ -721,23 +716,6 @@ void VrShell::OnContentScreenBoundsChanged(const gfx::SizeF& bounds) {
window_size.height(), dpr);
}
void VrShell::SetVoiceSearchActivate(bool activate) {
if (!activate && !speech_recognizer_)
return;
if (!speech_recognizer_) {
Profile* profile = ProfileManager::GetActiveUserProfile();
std::string profile_locale = g_browser_process->GetApplicationLocale();
speech_recognizer_.reset(new vr::SpeechRecognizer(
this, profile->GetRequestContext(), profile_locale));
}
if (activate) {
speech_recognizer_->Start();
} else {
speech_recognizer_->Stop();
}
}
void VrShell::PollMediaAccessFlag() {
poll_capturing_media_task_.Cancel();
......@@ -879,17 +857,6 @@ bool VrShell::ShouldDisplayURL() const {
return ChromeToolbarModelDelegate::ShouldDisplayURL();
}
void VrShell::OnVoiceResults(const base::string16& result) {
TemplateURLService* template_url_service =
TemplateURLServiceFactory::GetForProfile(
ProfileManager::GetActiveUserProfile());
GURL url(GetDefaultSearchURLForSearchTerms(template_url_service, result));
JNIEnv* env = base::android::AttachCurrentThread();
Java_VrShellImpl_loadUrl(
env, j_vr_shell_,
base::android::ConvertUTF8ToJavaString(env, url.spec()));
}
// ----------------------------------------------------------------------------
// Native JNI methods
// ----------------------------------------------------------------------------
......
......@@ -13,10 +13,8 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h"
#include "chrome/browser/vr/exit_vr_prompt_choice.h"
#include "chrome/browser/vr/speech_recognizer.h"
#include "chrome/browser/vr/ui.h"
#include "chrome/browser/vr/ui_unsupported_mode.h"
#include "content/public/browser/web_contents_observer.h"
......@@ -62,11 +60,12 @@ enum UiAction {
EXIT_PRESENT,
};
class VrMetricsHelper;
// The native instance of the Java VrShell. This class is not threadsafe and
// must only be used on the UI thread.
class VrShell : device::GvrGamepadDataProvider,
device::CardboardGamepadDataProvider,
vr::VoiceResultDelegate,
public ChromeToolbarModelDelegate {
public:
VrShell(JNIEnv* env,
......@@ -181,7 +180,6 @@ class VrShell : device::GvrGamepadDataProvider,
void OnExitVrPromptResult(vr::UiUnsupportedMode reason,
vr::ExitVrPromptChoice choice);
void OnContentScreenBoundsChanged(const gfx::SizeF& bounds);
void SetVoiceSearchActivate(bool activate);
void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event,
int content_id);
......@@ -203,8 +201,6 @@ class VrShell : device::GvrGamepadDataProvider,
content::WebContents* GetActiveWebContents() const override;
bool ShouldDisplayURL() const override;
void OnVoiceResults(const base::string16& result) override;
private:
~VrShell() override;
void PostToGlThread(const base::Location& from_here,
......@@ -239,7 +235,6 @@ class VrShell : device::GvrGamepadDataProvider,
std::unique_ptr<vr::WebContentsEventForwarder> web_contents_event_forwarder_;
std::unique_ptr<AndroidUiGestureTarget> android_ui_gesture_target_;
std::unique_ptr<VrMetricsHelper> metrics_helper_;
std::unique_ptr<vr::SpeechRecognizer> speech_recognizer_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
std::unique_ptr<VrGLThread> gl_thread_;
......
......@@ -107,8 +107,6 @@ source_set("vr_common_source") {
"service/vr_display_host.h",
"service/vr_service_impl.cc",
"service/vr_service_impl.h",
"speech_recognizer.cc",
"speech_recognizer.h",
"target_property.cc",
"target_property.h",
"toolbar_helper.cc",
......@@ -147,12 +145,12 @@ source_set("vr_common_source") {
"//cc/paint",
"//chrome/app:generated_resources",
"//chrome/browser/resources:vr_shell_resources",
"//chrome/common:constants",
"//components/security_state/core",
"//components/strings",
"//components/toolbar",
"//components/url_formatter",
"//components/vector_icons",
"//components/vector_icons",
"//content/public/browser",
"//content/public/common",
"//skia",
......@@ -210,7 +208,6 @@ test("vr_common_unittests") {
"fps_meter_unittest.cc",
"gltf_parser_unittest.cc",
"service/vr_device_manager_unittest.cc",
"speech_recognizer_unittest.cc",
"test/animation_utils.cc",
"test/animation_utils.h",
"test/fake_ui_element_renderer.cc",
......@@ -243,7 +240,6 @@ test("vr_common_unittests") {
deps = [
":vr_test_support",
"//cc:test_support",
"//content/test:test_support",
"//mojo/common",
"//mojo/public/cpp/bindings",
"//testing/gmock",
......@@ -305,6 +301,11 @@ source_set("vr_test_support") {
# TODO(mthiesse, crbug.com/769373): Remove dependency on device/vr:fakes.
"//device/vr:fakes",
# TODO(mthiesse): Figure out why these webrtc deps are necessary for compiling these tests.
# Is a dependency missing from some other target?
"//third_party/webrtc/api:video_frame_api",
"//third_party/webrtc/system_wrappers:metrics_default",
]
if (is_win) {
......
......@@ -31,7 +31,6 @@ enum UiElementName {
kBluetoothConnectedIndicator,
kLoadingIndicator,
kCloseButton,
kVoiceSearchButton,
kScreenDimmer,
kExitWarning,
kExitPrompt,
......
This diff is collapsed.
// Copyright 2017 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.
#ifndef CHROME_BROWSER_VR_SPEECH_RECOGNIZER_H_
#define CHROME_BROWSER_VR_SPEECH_RECOGNIZER_H_
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
namespace content {
class SpeechRecognitionManager;
}
namespace net {
class URLRequestContextGetter;
}
namespace vr {
// Note that speech recognition is activated on VR UI thread. This means it
// usually involves 3 threads. In the simplest case, the thread communication
// looks like the following:
// VR UI thread Browser thread IO thread
// | | |
// |----ActivateVS----->| |
// | |------Start------> |
// | | |
// | |<-NotifyStateChange-|
// |<--OnSRStateChanged-| |
// | | |
// | |<--OnSpeechResult---|
// |<--OnSRStateChanged-| |
// | navigate |
// | | |
// VS = voice search, SR = speech recognition
enum SpeechRecognitionState {
SPEECH_RECOGNITION_OFF = 0,
SPEECH_RECOGNITION_READY,
SPEECH_RECOGNITION_RECOGNIZING,
SPEECH_RECOGNITION_IN_SPEECH,
SPEECH_RECOGNITION_NETWORK_ERROR,
};
class VoiceResultDelegate {
public:
virtual void OnVoiceResults(const base::string16& result) = 0;
};
class SpeechRecognizerOnIO;
// An interface for IO to communicate with browser UI thread.
// This is used by SpeechRecognizerOnIO class who lives on IO thread.
class IOBrowserUIInterface {
public:
// Receive a speech recognition result. |is_final| indicated whether the
// result is an intermediate or final result. If |is_final| is true, then the
// recognizer stops and no more results will be returned.
virtual void OnSpeechResult(const base::string16& query, bool is_final) = 0;
// Invoked regularly to indicate the average sound volume.
virtual void OnSpeechSoundLevelChanged(float level) = 0;
// Invoked when the state of speech recognition is changed.
virtual void OnSpeechRecognitionStateChanged(
SpeechRecognitionState new_state) = 0;
protected:
virtual ~IOBrowserUIInterface() {}
};
// SpeechRecognizer is a wrapper around the speech recognition engine that
// simplifies its use from the UI thread. This class handles all setup/shutdown,
// collection of results, error cases, and threading.
class SpeechRecognizer : public IOBrowserUIInterface {
public:
SpeechRecognizer(VoiceResultDelegate* delegate,
net::URLRequestContextGetter* url_request_context_getter,
const std::string& locale);
~SpeechRecognizer() override;
// Start/stop the speech recognizer.
// Must be called on the UI thread.
void Start();
void Stop();
// Overridden from vr::IOBrowserUIInterface:
void OnSpeechResult(const base::string16& query, bool is_final) override;
void OnSpeechSoundLevelChanged(float level) override;
void OnSpeechRecognitionStateChanged(
vr::SpeechRecognitionState new_state) override;
void GetSpeechAuthParameters(std::string* auth_scope,
std::string* auth_token);
static void SetManagerForTest(content::SpeechRecognitionManager* manager);
void SetSpeechTimerForTest(std::unique_ptr<base::Timer> speech_timer);
private:
VoiceResultDelegate* delegate_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
std::string locale_;
// Note that this object is destroyed on IO thread.
std::unique_ptr<SpeechRecognizerOnIO> speech_recognizer_on_io_;
base::WeakPtrFactory<SpeechRecognizer> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer);
};
} // namespace vr
#endif // CHROME_BROWSER_VR_SPEECH_RECOGNIZER_H_
This diff is collapsed.
......@@ -24,7 +24,6 @@ class MockBrowserInterface : public UiBrowserInterface {
MOCK_METHOD2(OnExitVrPromptResult,
void(UiUnsupportedMode reason, ExitVrPromptChoice choice));
MOCK_METHOD1(OnContentScreenBoundsChanged, void(const gfx::SizeF& bounds));
MOCK_METHOD1(SetVoiceSearchActivate, void(bool activate));
private:
DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface);
......
......@@ -11,7 +11,7 @@
namespace vr {
// An interface for the VR UI to communicate with VrShell. Many of the functions
// An interface for the UI to communicate with VrShell. Many of the functions
// in this interface are proxies to methods on VrShell.
class UiBrowserInterface {
public:
......@@ -25,7 +25,6 @@ class UiBrowserInterface {
virtual void OnExitVrPromptResult(UiUnsupportedMode reason,
ExitVrPromptChoice choice) = 0;
virtual void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) = 0;
virtual void SetVoiceSearchActivate(bool activate) = 0;
};
} // namespace vr
......
......@@ -38,7 +38,6 @@
#include "chrome/browser/vr/ui_scene.h"
#include "chrome/browser/vr/ui_scene_constants.h"
#include "chrome/browser/vr/vr_gl_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -101,7 +100,6 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser,
CreateToasts();
CreateSplashScreen();
CreateUnderDevelopmentNotice();
CreateVoiceSearchButton();
ConfigureScene();
}
......@@ -394,21 +392,6 @@ void UiSceneManager::CreateViewportAwareRoot() {
scene_->AddUiElement(k2dBrowsingRoot, std::move(element));
}
void UiSceneManager::CreateVoiceSearchButton() {
// TODO(bshe): Use a proper microphone button and update size and translation
// according to UX.
auto element = base::MakeUnique<Button>(
base::Bind(&UiSceneManager::OnVoiceSearchButtonClicked,
base::Unretained(this)),
base::MakeUnique<CloseButtonTexture>());
element->set_name(kVoiceSearchButton);
element->set_draw_phase(kPhaseForeground);
element->SetTranslate(0.f, 0.f, -kCloseButtonDistance);
element->SetSize(kCloseButtonWidth, kCloseButtonHeight);
voice_search_button_ = element.get();
scene_->AddUiElement(k2dBrowsingForeground, std::move(element));
}
void UiSceneManager::CreateUrlBar(Model* model) {
auto url_bar = base::MakeUnique<UrlBar>(
512,
......@@ -696,9 +679,6 @@ void UiSceneManager::ConfigureScene() {
// Close button is a special control element that needs to be hidden when in
// WebVR, but it needs to be visible when in cct or fullscreen.
close_button_->SetVisible(browsing_mode && (fullscreen_ || in_cct_));
voice_search_button_->SetVisible(
browsing_mode &&
base::FeatureList::IsEnabled(features::kExperimentalVRFeatures));
// Content elements.
for (UiElement* element : content_elements_) {
......@@ -927,11 +907,6 @@ void UiSceneManager::OnCloseButtonClicked() {
}
}
void UiSceneManager::OnVoiceSearchButtonClicked() {
recognizing_speech_ = !recognizing_speech_;
browser_->SetVoiceSearchActivate(recognizing_speech_);
}
void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) {
browser_->OnUnsupportedMode(mode);
}
......
......@@ -62,7 +62,6 @@ struct UiInitialState;
// kUrlBar
// kLoadingIndicator
// kExitButton
// kUnderDevelopmentNotice
// kFullscreenToast
// kScreenDimmer
// k2dBrowsingViewportAwareRoot
......@@ -140,7 +139,6 @@ class UiSceneManager {
void CreateCloseButton();
void CreateExitPrompt();
void CreateToasts();
void CreateVoiceSearchButton();
void ConfigureScene();
void ConfigureExclusiveScreenToast();
......@@ -152,7 +150,6 @@ class UiSceneManager {
void OnExitPromptBackplaneClicked();
void OnCloseButtonClicked();
void OnUnsupportedMode(UiUnsupportedMode mode);
void OnVoiceSearchButtonClicked();
ColorScheme::Mode mode() const;
TransientElement* AddTransientParent(UiElementName name,
......@@ -181,7 +178,6 @@ class UiSceneManager {
Rect* ceiling_ = nullptr;
Grid* floor_ = nullptr;
UiElement* close_button_ = nullptr;
UiElement* voice_search_button_ = nullptr;
UrlBar* url_bar_ = nullptr;
TransientElement* webvr_url_toast_transient_parent_ = nullptr;
WebVrUrlToast* webvr_url_toast_ = nullptr;
......@@ -207,7 +203,6 @@ class UiSceneManager {
bool screen_capturing_ = false;
bool location_access_ = false;
bool bluetooth_connected_ = false;
bool recognizing_speech_ = false;
UiUnsupportedMode exit_vr_prompt_reason_ = UiUnsupportedMode::kCount;
std::vector<Rect*> background_panels_;
......
......@@ -52,7 +52,6 @@ const std::set<UiElementName> kHitTestableElements = {
kUrlBar,
kLoadingIndicator,
kCloseButton,
kVoiceSearchButton,
};
const std::set<UiElementName> kElementsVisibleWithExitWarning = {
kScreenDimmer, kExitWarning,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment