Commit b38b120c authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

VR: Add plumbing between UI and browser omnibox sites

This paves the way to plug in an AutocompleteController, and associated
UI.  Also, drive URL bar and WebVR toast state via model, as omnibox
will require some of the same data.

BUG=777542
R=vollick

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I29e96b5318e0d90b5530c12166db9fe780dba276
Reviewed-on: https://chromium-review.googlesource.com/772393
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Reviewed-by: default avatarBiao She <bshe@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517519}
parent 0b848fbe
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include "chrome/browser/android/vr_shell/vr_shell.h" #include "chrome/browser/android/vr_shell/vr_shell.h"
#include "chrome/browser/android/vr_shell/vr_shell_gl.h" #include "chrome/browser/android/vr_shell/vr_shell_gl.h"
#include "chrome/browser/vr/browser_ui_interface.h" #include "chrome/browser/vr/browser_ui_interface.h"
#include "chrome/browser/vr/toolbar_state.h" #include "chrome/browser/vr/model/omnibox_suggestions.h"
#include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/ui.h" #include "chrome/browser/vr/ui.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
...@@ -107,6 +108,12 @@ void VrGLThread::OnContentPaused(bool enabled) { ...@@ -107,6 +108,12 @@ void VrGLThread::OnContentPaused(bool enabled) {
base::Bind(&VrShell::OnContentPaused, weak_vr_shell_, enabled)); base::Bind(&VrShell::OnContentPaused, weak_vr_shell_, enabled));
} }
void VrGLThread::Navigate(GURL gurl) {
DCHECK(OnGlThread());
main_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&VrShell::Navigate, weak_vr_shell_, gurl));
}
void VrGLThread::NavigateBack() { void VrGLThread::NavigateBack() {
DCHECK(OnGlThread()); DCHECK(OnGlThread());
main_thread_task_runner_->PostTask( main_thread_task_runner_->PostTask(
...@@ -154,6 +161,19 @@ void VrGLThread::SetVoiceSearchActive(bool active) { ...@@ -154,6 +161,19 @@ void VrGLThread::SetVoiceSearchActive(bool active) {
base::Bind(&VrShell::SetVoiceSearchActive, weak_vr_shell_, active)); base::Bind(&VrShell::SetVoiceSearchActive, weak_vr_shell_, active));
} }
void VrGLThread::StartAutocomplete(const base::string16& string) {
DCHECK(OnGlThread());
main_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&VrShell::StartAutocomplete, weak_vr_shell_, string));
}
void VrGLThread::StopAutocomplete() {
DCHECK(OnGlThread());
main_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&VrShell::StopAutocomplete, weak_vr_shell_));
}
void VrGLThread::SetFullscreen(bool enabled) { void VrGLThread::SetFullscreen(bool enabled) {
DCHECK(OnMainThread()); DCHECK(OnMainThread());
task_runner()->PostTask( task_runner()->PostTask(
...@@ -279,6 +299,14 @@ void VrGLThread::OnSpeechRecognitionStateChanged(int new_state) { ...@@ -279,6 +299,14 @@ void VrGLThread::OnSpeechRecognitionStateChanged(int new_state) {
browser_ui_, new_state)); browser_ui_, new_state));
} }
void VrGLThread::SetOmniboxSuggestions(
std::unique_ptr<vr::OmniboxSuggestions> suggestions) {
DCHECK(OnMainThread());
task_runner()->PostTask(
FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetOmniboxSuggestions,
browser_ui_, base::Passed(std::move(suggestions))));
}
bool VrGLThread::OnMainThread() const { bool VrGLThread::OnMainThread() const {
return main_thread_task_runner_->BelongsToCurrentThread(); return main_thread_task_runner_->BelongsToCurrentThread();
} }
......
...@@ -22,6 +22,7 @@ namespace vr_shell { ...@@ -22,6 +22,7 @@ namespace vr_shell {
class VrShell; class VrShell;
class VrShellGl; class VrShellGl;
struct OmniboxSuggestions;
class VrGLThread : public base::android::JavaHandlerThread, class VrGLThread : public base::android::JavaHandlerThread,
public vr::ContentInputForwarder, public vr::ContentInputForwarder,
...@@ -55,6 +56,7 @@ class VrGLThread : public base::android::JavaHandlerThread, ...@@ -55,6 +56,7 @@ class VrGLThread : public base::android::JavaHandlerThread,
// vr::UiBrowserInterface implementation (UI calling to VrShell). // vr::UiBrowserInterface implementation (UI calling to VrShell).
void ExitPresent() override; void ExitPresent() override;
void ExitFullscreen() override; void ExitFullscreen() override;
void Navigate(GURL gurl) override;
void NavigateBack() override; void NavigateBack() override;
void ExitCct() override; void ExitCct() override;
void OnUnsupportedMode(vr::UiUnsupportedMode mode) override; void OnUnsupportedMode(vr::UiUnsupportedMode mode) override;
...@@ -62,6 +64,8 @@ class VrGLThread : public base::android::JavaHandlerThread, ...@@ -62,6 +64,8 @@ class VrGLThread : public base::android::JavaHandlerThread,
vr::ExitVrPromptChoice choice) override; vr::ExitVrPromptChoice choice) override;
void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) override; void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) override;
void SetVoiceSearchActive(bool active) override; void SetVoiceSearchActive(bool active) override;
void StartAutocomplete(const base::string16& string) override;
void StopAutocomplete() override;
// vr::BrowserUiInterface implementation (Browser calling to UI). // vr::BrowserUiInterface implementation (Browser calling to UI).
void SetWebVrMode(bool enabled, bool show_toast) override; void SetWebVrMode(bool enabled, bool show_toast) override;
...@@ -82,6 +86,8 @@ class VrGLThread : public base::android::JavaHandlerThread, ...@@ -82,6 +86,8 @@ class VrGLThread : public base::android::JavaHandlerThread,
void SetSpeechRecognitionEnabled(bool enabled) override; void SetSpeechRecognitionEnabled(bool enabled) override;
void SetRecognitionResult(const base::string16& result) override; void SetRecognitionResult(const base::string16& result) override;
void OnSpeechRecognitionStateChanged(int new_state) override; void OnSpeechRecognitionStateChanged(int new_state) override;
void SetOmniboxSuggestions(
std::unique_ptr<vr::OmniboxSuggestions> result) override;
protected: protected:
void Init() override; void Init() override;
......
...@@ -287,6 +287,13 @@ void VrShell::OnContentPaused(bool paused) { ...@@ -287,6 +287,13 @@ void VrShell::OnContentPaused(bool paused) {
device->Focus(); device->Focus();
} }
void VrShell::Navigate(GURL url) {
JNIEnv* env = base::android::AttachCurrentThread();
Java_VrShellImpl_loadUrl(
env, j_vr_shell_,
base::android::ConvertUTF8ToJavaString(env, url.spec()));
}
void VrShell::NavigateBack() { void VrShell::NavigateBack() {
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
Java_VrShellImpl_navigateBack(env, j_vr_shell_); Java_VrShellImpl_navigateBack(env, j_vr_shell_);
...@@ -746,6 +753,10 @@ void VrShell::SetVoiceSearchActive(bool active) { ...@@ -746,6 +753,10 @@ void VrShell::SetVoiceSearchActive(bool active) {
} }
} }
void VrShell::StartAutocomplete(const base::string16& string) {}
void VrShell::StopAutocomplete() {}
bool VrShell::HasAudioPermission() { bool VrShell::HasAudioPermission() {
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
return Java_VrShellImpl_hasAudioPermission(env, j_vr_shell_); return Java_VrShellImpl_hasAudioPermission(env, j_vr_shell_);
......
...@@ -121,6 +121,7 @@ class VrShell : device::GvrGamepadDataProvider, ...@@ -121,6 +121,7 @@ class VrShell : device::GvrGamepadDataProvider,
jboolean incognito, jboolean incognito,
jint id); jint id);
void OnContentPaused(bool paused); void OnContentPaused(bool paused);
void Navigate(GURL url);
void NavigateBack(); void NavigateBack();
void ExitCct(); void ExitCct();
void ToggleCardboardGamepad(bool enabled); void ToggleCardboardGamepad(bool enabled);
...@@ -182,6 +183,8 @@ class VrShell : device::GvrGamepadDataProvider, ...@@ -182,6 +183,8 @@ class VrShell : device::GvrGamepadDataProvider,
vr::ExitVrPromptChoice choice); vr::ExitVrPromptChoice choice);
void OnContentScreenBoundsChanged(const gfx::SizeF& bounds); void OnContentScreenBoundsChanged(const gfx::SizeF& bounds);
void SetVoiceSearchActive(bool active); void SetVoiceSearchActive(bool active);
void StartAutocomplete(const base::string16& string);
void StopAutocomplete();
bool HasAudioPermission(); bool HasAudioPermission();
void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event, void ProcessContentGesture(std::unique_ptr<blink::WebInputEvent> event,
......
...@@ -124,6 +124,8 @@ static_library("vr_common") { ...@@ -124,6 +124,8 @@ static_library("vr_common") {
"model/omnibox_suggestions.h", "model/omnibox_suggestions.h",
"model/reticle_model.h", "model/reticle_model.h",
"model/speech_recognition_model.h", "model/speech_recognition_model.h",
"model/toolbar_state.cc",
"model/toolbar_state.h",
"model/web_vr_timeout_state.h", "model/web_vr_timeout_state.h",
"pose_util.cc", "pose_util.cc",
"pose_util.h", "pose_util.h",
...@@ -151,8 +153,6 @@ static_library("vr_common") { ...@@ -151,8 +153,6 @@ static_library("vr_common") {
"target_property.h", "target_property.h",
"toolbar_helper.cc", "toolbar_helper.cc",
"toolbar_helper.h", "toolbar_helper.h",
"toolbar_state.cc",
"toolbar_state.h",
"transition.cc", "transition.cc",
"transition.h", "transition.h",
"ui.cc", "ui.cc",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
namespace vr { namespace vr {
struct OmniboxSuggestions;
struct ToolbarState; struct ToolbarState;
// The browser communicates state changes to the VR UI via this interface. // The browser communicates state changes to the VR UI via this interface.
...@@ -36,6 +37,8 @@ class BrowserUiInterface { ...@@ -36,6 +37,8 @@ class BrowserUiInterface {
virtual void SetSpeechRecognitionEnabled(bool enabled) = 0; virtual void SetSpeechRecognitionEnabled(bool enabled) = 0;
virtual void SetRecognitionResult(const base::string16& result) = 0; virtual void SetRecognitionResult(const base::string16& result) = 0;
virtual void OnSpeechRecognitionStateChanged(int new_state) = 0; virtual void OnSpeechRecognitionStateChanged(int new_state) = 0;
virtual void SetOmniboxSuggestions(
std::unique_ptr<OmniboxSuggestions> suggestions) = 0;
// Tab handling. // Tab handling.
virtual void AppendToTabList(bool incognito, virtual void AppendToTabList(bool incognito,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/vr/elements/ui_texture.h" #include "chrome/browser/vr/elements/ui_texture.h"
#include "chrome/browser/vr/toolbar_state.h" #include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/ui_unsupported_mode.h" #include "chrome/browser/vr/ui_unsupported_mode.h"
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
#include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/geometry/rect_f.h"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/vr/elements/render_text_wrapper.h" #include "chrome/browser/vr/elements/render_text_wrapper.h"
#include "chrome/browser/vr/toolbar_state.h" #include "chrome/browser/vr/model/toolbar_state.h"
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
#include "components/toolbar/vector_icons.h" #include "components/toolbar/vector_icons.h"
#include "components/url_formatter/url_formatter.h" #include "components/url_formatter/url_formatter.h"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/vr/elements/ui_texture.h" #include "chrome/browser/vr/elements/ui_texture.h"
#include "chrome/browser/vr/toolbar_state.h" #include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/ui_unsupported_mode.h" #include "chrome/browser/vr/ui_unsupported_mode.h"
namespace gfx { namespace gfx {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/vr/model/omnibox_suggestions.h" #include "chrome/browser/vr/model/omnibox_suggestions.h"
#include "chrome/browser/vr/model/reticle_model.h" #include "chrome/browser/vr/model/reticle_model.h"
#include "chrome/browser/vr/model/speech_recognition_model.h" #include "chrome/browser/vr/model/speech_recognition_model.h"
#include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/model/web_vr_timeout_state.h" #include "chrome/browser/vr/model/web_vr_timeout_state.h"
namespace vr { namespace vr {
...@@ -33,6 +34,7 @@ struct Model { ...@@ -33,6 +34,7 @@ struct Model {
ModalPromptType active_modal_prompt_type = kModalPromptTypeNone; ModalPromptType active_modal_prompt_type = kModalPromptTypeNone;
ToolbarState toolbar_state;
std::vector<OmniboxSuggestion> omnibox_suggestions; std::vector<OmniboxSuggestion> omnibox_suggestions;
}; };
......
...@@ -8,8 +8,19 @@ namespace vr { ...@@ -8,8 +8,19 @@ namespace vr {
OmniboxSuggestion::OmniboxSuggestion(const base::string16& new_content, OmniboxSuggestion::OmniboxSuggestion(const base::string16& new_content,
const base::string16& new_description, const base::string16& new_description,
AutocompleteMatch::Type new_type) AutocompleteMatch::Type new_type,
: content(new_content), description(new_description), type(new_type) {} GURL new_destination)
: content(new_content),
description(new_description),
type(new_type),
destination(new_destination) {}
OmniboxSuggestion::OmniboxSuggestion(const OmniboxSuggestion& other) {
content = other.content;
description = other.description;
type = other.type;
destination = other.destination;
}
OmniboxSuggestions::OmniboxSuggestions() {} OmniboxSuggestions::OmniboxSuggestions() {}
......
...@@ -7,17 +7,21 @@ ...@@ -7,17 +7,21 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_match.h"
#include "url/gurl.h"
namespace vr { namespace vr {
struct OmniboxSuggestion { struct OmniboxSuggestion {
OmniboxSuggestion(const base::string16& new_content, OmniboxSuggestion(const base::string16& new_content,
const base::string16& new_description, const base::string16& new_description,
AutocompleteMatch::Type new_type); AutocompleteMatch::Type new_type,
GURL new_destination);
OmniboxSuggestion(const OmniboxSuggestion& other);
base::string16 content; base::string16 content;
base::string16 description; base::string16 description;
AutocompleteMatch::Type type; AutocompleteMatch::Type type;
GURL destination;
}; };
struct OmniboxSuggestions { struct OmniboxSuggestions {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/vr/toolbar_state.h" #include "chrome/browser/vr/model/toolbar_state.h"
namespace vr { namespace vr {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_TOOLBAR_STATE_H_ #ifndef CHROME_BROWSER_VR_MODEL_TOOLBAR_STATE_H_
#define CHROME_BROWSER_VR_TOOLBAR_STATE_H_ #define CHROME_BROWSER_VR_MODEL_TOOLBAR_STATE_H_
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -39,4 +39,4 @@ struct ToolbarState { ...@@ -39,4 +39,4 @@ struct ToolbarState {
} // namespace vr } // namespace vr
#endif // CHROME_BROWSER_VR_TOOLBAR_STATE_H_ #endif // CHROME_BROWSER_VR_MODEL_TOOLBAR_STATE_H_
...@@ -18,6 +18,7 @@ class MockBrowserInterface : public UiBrowserInterface { ...@@ -18,6 +18,7 @@ class MockBrowserInterface : public UiBrowserInterface {
MOCK_METHOD0(ExitPresent, void()); MOCK_METHOD0(ExitPresent, void());
MOCK_METHOD0(ExitFullscreen, void()); MOCK_METHOD0(ExitFullscreen, void());
MOCK_METHOD1(Navigate, void(GURL gurl));
MOCK_METHOD0(NavigateBack, void()); MOCK_METHOD0(NavigateBack, void());
MOCK_METHOD0(ExitCct, void()); MOCK_METHOD0(ExitCct, void());
MOCK_METHOD1(OnUnsupportedMode, void(UiUnsupportedMode mode)); MOCK_METHOD1(OnUnsupportedMode, void(UiUnsupportedMode mode));
...@@ -25,6 +26,8 @@ class MockBrowserInterface : public UiBrowserInterface { ...@@ -25,6 +26,8 @@ class MockBrowserInterface : public UiBrowserInterface {
void(UiUnsupportedMode reason, ExitVrPromptChoice choice)); void(UiUnsupportedMode reason, ExitVrPromptChoice choice));
MOCK_METHOD1(OnContentScreenBoundsChanged, void(const gfx::SizeF& bounds)); MOCK_METHOD1(OnContentScreenBoundsChanged, void(const gfx::SizeF& bounds));
MOCK_METHOD1(SetVoiceSearchActive, void(bool active)); MOCK_METHOD1(SetVoiceSearchActive, void(bool active));
MOCK_METHOD1(StartAutocomplete, void(const base::string16& string));
MOCK_METHOD0(StopAutocomplete, void());
private: private:
DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface); DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface);
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#ifndef CHROME_BROWSER_VR_TEST_UI_PIXEL_TEST_H_ #ifndef CHROME_BROWSER_VR_TEST_UI_PIXEL_TEST_H_
#define CHROME_BROWSER_VR_TEST_UI_PIXEL_TEST_H_ #define CHROME_BROWSER_VR_TEST_UI_PIXEL_TEST_H_
#include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/test/gl_test_environment.h" #include "chrome/browser/vr/test/gl_test_environment.h"
#include "chrome/browser/vr/test/mock_browser_interface.h" #include "chrome/browser/vr/test/mock_browser_interface.h"
#include "chrome/browser/vr/test/mock_content_input_delegate.h" #include "chrome/browser/vr/test/mock_content_input_delegate.h"
#include "chrome/browser/vr/toolbar_state.h"
#include "chrome/browser/vr/ui.h" #include "chrome/browser/vr/ui.h"
#include "chrome/browser/vr/ui_input_manager.h" #include "chrome/browser/vr/ui_input_manager.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "chrome/browser/vr/controller_mesh.h" #include "chrome/browser/vr/controller_mesh.h"
#include "chrome/browser/vr/model/model.h" #include "chrome/browser/vr/model/model.h"
#include "chrome/browser/vr/model/omnibox_suggestions.h" #include "chrome/browser/vr/model/omnibox_suggestions.h"
#include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/test/constants.h" #include "chrome/browser/vr/test/constants.h"
#include "chrome/browser/vr/toolbar_state.h"
#include "chrome/browser/vr/ui.h" #include "chrome/browser/vr/ui.h"
#include "chrome/browser/vr/ui_element_renderer.h" #include "chrome/browser/vr/ui_element_renderer.h"
#include "chrome/browser/vr/ui_input_manager.h" #include "chrome/browser/vr/ui_input_manager.h"
...@@ -288,7 +288,7 @@ void VrTestContext::CreateFakeOmniboxSuggestions() { ...@@ -288,7 +288,7 @@ void VrTestContext::CreateFakeOmniboxSuggestions() {
result->suggestions.emplace_back(OmniboxSuggestion( result->suggestions.emplace_back(OmniboxSuggestion(
base::UTF8ToUTF16("Suggestion ") + base::IntToString16(i + 1), base::UTF8ToUTF16("Suggestion ") + base::IntToString16(i + 1),
base::UTF8ToUTF16("Description text"), base::UTF8ToUTF16("Description text"),
AutocompleteMatch::Type::VOICE_SUGGEST)); AutocompleteMatch::Type::VOICE_SUGGEST, GURL("http://www.test.com/")));
} }
ui_->SetOmniboxSuggestions(std::move(result)); ui_->SetOmniboxSuggestions(std::move(result));
} }
...@@ -322,4 +322,8 @@ void VrTestContext::OnExitVrPromptResult(vr::UiUnsupportedMode reason, ...@@ -322,4 +322,8 @@ void VrTestContext::OnExitVrPromptResult(vr::UiUnsupportedMode reason,
} }
void VrTestContext::OnContentScreenBoundsChanged(const gfx::SizeF& bounds) {} void VrTestContext::OnContentScreenBoundsChanged(const gfx::SizeF& bounds) {}
void VrTestContext::StartAutocomplete(const base::string16& string) {}
void VrTestContext::StopAutocomplete() {}
void VrTestContext::Navigate(GURL gurl) {}
} // namespace vr } // namespace vr
...@@ -43,6 +43,9 @@ class VrTestContext : public vr::UiBrowserInterface { ...@@ -43,6 +43,9 @@ class VrTestContext : public vr::UiBrowserInterface {
vr::ExitVrPromptChoice choice) override; vr::ExitVrPromptChoice choice) override;
void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) override; void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) override;
void SetVoiceSearchActive(bool active) override; void SetVoiceSearchActive(bool active) override;
void StartAutocomplete(const base::string16& string) override;
void StopAutocomplete() override;
void Navigate(GURL gurl) override;
private: private:
unsigned int CreateFakeContentTexture(); unsigned int CreateFakeContentTexture();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define CHROME_BROWSER_VR_TOOLBAR_HELPER_H_ #define CHROME_BROWSER_VR_TOOLBAR_HELPER_H_
#include "chrome/browser/vr/browser_ui_interface.h" #include "chrome/browser/vr/browser_ui_interface.h"
#include "chrome/browser/vr/toolbar_state.h" #include "chrome/browser/vr/model/toolbar_state.h"
class ToolbarModel; class ToolbarModel;
class ToolbarModelDelegate; class ToolbarModelDelegate;
......
...@@ -62,7 +62,7 @@ void Ui::SetFullscreen(bool enabled) { ...@@ -62,7 +62,7 @@ void Ui::SetFullscreen(bool enabled) {
} }
void Ui::SetToolbarState(const ToolbarState& state) { void Ui::SetToolbarState(const ToolbarState& state) {
scene_manager_->SetToolbarState(state); model_->toolbar_state = state;
} }
void Ui::SetIncognito(bool enabled) { void Ui::SetIncognito(bool enabled) {
......
...@@ -73,6 +73,8 @@ class Ui : public BrowserUiInterface { ...@@ -73,6 +73,8 @@ class Ui : public BrowserUiInterface {
void SetSpeechRecognitionEnabled(bool enabled) override; void SetSpeechRecognitionEnabled(bool enabled) override;
void SetRecognitionResult(const base::string16& result) override; void SetRecognitionResult(const base::string16& result) override;
void OnSpeechRecognitionStateChanged(int new_state) override; void OnSpeechRecognitionStateChanged(int new_state) override;
void SetOmniboxSuggestions(
std::unique_ptr<OmniboxSuggestions> suggestions) override;
bool ShouldRenderWebVr(); bool ShouldRenderWebVr();
void OnGlInitialized(unsigned int content_texture_id, void OnGlInitialized(unsigned int content_texture_id,
...@@ -92,8 +94,6 @@ class Ui : public BrowserUiInterface { ...@@ -92,8 +94,6 @@ class Ui : public BrowserUiInterface {
void OnContentBoundsChanged(int width, int height); void OnContentBoundsChanged(int width, int height);
void OnPlatformControllerInitialized(PlatformController* controller); void OnPlatformControllerInitialized(PlatformController* controller);
void SetOmniboxSuggestions(std::unique_ptr<OmniboxSuggestions> suggestions);
private: private:
UiBrowserInterface* browser_; UiBrowserInterface* browser_;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/browser/vr/exit_vr_prompt_choice.h" #include "chrome/browser/vr/exit_vr_prompt_choice.h"
#include "chrome/browser/vr/ui_unsupported_mode.h" #include "chrome/browser/vr/ui_unsupported_mode.h"
#include "ui/gfx/geometry/size_f.h" #include "ui/gfx/geometry/size_f.h"
#include "url/gurl.h"
namespace vr { namespace vr {
...@@ -19,6 +20,7 @@ class UiBrowserInterface { ...@@ -19,6 +20,7 @@ class UiBrowserInterface {
virtual void ExitPresent() = 0; virtual void ExitPresent() = 0;
virtual void ExitFullscreen() = 0; virtual void ExitFullscreen() = 0;
virtual void Navigate(GURL gurl) = 0;
virtual void NavigateBack() = 0; virtual void NavigateBack() = 0;
virtual void ExitCct() = 0; virtual void ExitCct() = 0;
virtual void OnUnsupportedMode(UiUnsupportedMode mode) = 0; virtual void OnUnsupportedMode(UiUnsupportedMode mode) = 0;
...@@ -26,6 +28,8 @@ class UiBrowserInterface { ...@@ -26,6 +28,8 @@ class UiBrowserInterface {
ExitVrPromptChoice choice) = 0; ExitVrPromptChoice choice) = 0;
virtual void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) = 0; virtual void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) = 0;
virtual void SetVoiceSearchActive(bool active) = 0; virtual void SetVoiceSearchActive(bool active) = 0;
virtual void StartAutocomplete(const base::string16& string) = 0;
virtual void StopAutocomplete() = 0;
}; };
} // namespace vr } // namespace vr
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/vr/model/toolbar_state.h"
#include "chrome/browser/vr/test/constants.h" #include "chrome/browser/vr/test/constants.h"
#include "chrome/browser/vr/test/ui_pixel_test.h" #include "chrome/browser/vr/test/ui_pixel_test.h"
#include "chrome/browser/vr/toolbar_state.h"
#include "components/toolbar/vector_icons.h" #include "components/toolbar/vector_icons.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
...@@ -170,7 +170,7 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser, ...@@ -170,7 +170,7 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser,
CreateSystemIndicators(); CreateSystemIndicators();
CreateUrlBar(model); CreateUrlBar(model);
CreateSuggestionList(model); CreateSuggestionList(model);
CreateWebVrUrlToast(); CreateWebVrUrlToast(model);
CreateCloseButton(); CreateCloseButton();
CreateScreenDimmer(); CreateScreenDimmer();
CreateToasts(model); CreateToasts(model);
...@@ -847,6 +847,8 @@ void UiSceneManager::CreateUrlBar(Model* model) { ...@@ -847,6 +847,8 @@ void UiSceneManager::CreateUrlBar(Model* model) {
url_bar->SetSize(kUrlBarWidth, kUrlBarHeight); url_bar->SetSize(kUrlBarWidth, kUrlBarHeight);
url_bar->AddBinding(VR_BIND(bool, UiSceneManager, this, fullscreen(), url_bar->AddBinding(VR_BIND(bool, UiSceneManager, this, fullscreen(),
UiElement, url_bar.get(), SetVisible(!value))); UiElement, url_bar.get(), SetVisible(!value)));
url_bar->AddBinding(VR_BIND_FUNC(ToolbarState, Model, model, toolbar_state,
UrlBar, url_bar.get(), SetToolbarState));
url_bar_ = url_bar.get(); url_bar_ = url_bar.get();
scene_->AddUiElement(k2dBrowsingForeground, std::move(url_bar)); scene_->AddUiElement(k2dBrowsingForeground, std::move(url_bar));
...@@ -925,24 +927,27 @@ TransientElement* UiSceneManager::AddTransientParent(UiElementName name, ...@@ -925,24 +927,27 @@ TransientElement* UiSceneManager::AddTransientParent(UiElementName name,
return to_return; return to_return;
} }
void UiSceneManager::CreateWebVrUrlToast() { void UiSceneManager::CreateWebVrUrlToast(Model* model) {
webvr_url_toast_transient_parent_ = webvr_url_toast_transient_parent_ =
AddTransientParent(kWebVrUrlToastTransientParent, kWebVrViewportAwareRoot, AddTransientParent(kWebVrUrlToastTransientParent, kWebVrViewportAwareRoot,
kWebVrUrlToastTimeoutSeconds, true); kWebVrUrlToastTimeoutSeconds, true);
auto url_bar = base::MakeUnique<WebVrUrlToast>( auto element = base::MakeUnique<WebVrUrlToast>(
512, 512,
base::Bind(&UiSceneManager::OnUnsupportedMode, base::Unretained(this))); base::Bind(&UiSceneManager::OnUnsupportedMode, base::Unretained(this)));
url_bar->set_name(kWebVrUrlToast); element->set_name(kWebVrUrlToast);
url_bar->set_opacity_when_visible(0.8f); element->set_opacity_when_visible(0.8f);
url_bar->set_draw_phase(kPhaseOverlayForeground); element->set_draw_phase(kPhaseOverlayForeground);
url_bar->SetVisible(true); element->SetVisible(true);
url_bar->set_hit_testable(false); element->set_hit_testable(false);
url_bar->SetTranslate(0, kWebVrToastDistance * sin(kWebVrUrlToastRotationRad), element->SetTranslate(0, kWebVrToastDistance * sin(kWebVrUrlToastRotationRad),
-kWebVrToastDistance * cos(kWebVrUrlToastRotationRad)); -kWebVrToastDistance * cos(kWebVrUrlToastRotationRad));
url_bar->SetRotate(1, 0, 0, kWebVrUrlToastRotationRad); element->SetRotate(1, 0, 0, kWebVrUrlToastRotationRad);
url_bar->SetSize(kWebVrUrlToastWidth, kWebVrUrlToastHeight); element->SetSize(kWebVrUrlToastWidth, kWebVrUrlToastHeight);
webvr_url_toast_ = url_bar.get(); element->AddBinding(VR_BIND_FUNC(ToolbarState, Model, model, toolbar_state,
scene_->AddUiElement(kWebVrUrlToastTransientParent, std::move(url_bar)); WebVrUrlToast, element.get(),
SetToolbarState));
webvr_url_toast_ = element.get();
scene_->AddUiElement(kWebVrUrlToastTransientParent, std::move(element));
} }
void UiSceneManager::CreateCloseButton() { void UiSceneManager::CreateCloseButton() {
...@@ -1417,11 +1422,6 @@ void UiSceneManager::OnExitPromptChoice(bool chose_exit, ...@@ -1417,11 +1422,6 @@ void UiSceneManager::OnExitPromptChoice(bool chose_exit,
: ExitVrPromptChoice::CHOICE_STAY); : ExitVrPromptChoice::CHOICE_STAY);
} }
void UiSceneManager::SetToolbarState(const ToolbarState& state) {
url_bar_->SetToolbarState(state);
webvr_url_toast_->SetToolbarState(state);
}
void UiSceneManager::SetIsExiting() { void UiSceneManager::SetIsExiting() {
if (exiting_) if (exiting_)
return; return;
......
...@@ -124,7 +124,6 @@ class UiSceneManager { ...@@ -124,7 +124,6 @@ class UiSceneManager {
// BrowserUiInterface support methods. // BrowserUiInterface support methods.
void SetFullscreen(bool fullscreen); void SetFullscreen(bool fullscreen);
void SetIncognito(bool incognito); void SetIncognito(bool incognito);
void SetToolbarState(const ToolbarState& state);
void SetWebVrMode(bool web_vr, bool show_toast); void SetWebVrMode(bool web_vr, bool show_toast);
void SetIsExiting(); void SetIsExiting();
void SetVideoCapturingIndicator(bool enabled); void SetVideoCapturingIndicator(bool enabled);
...@@ -174,7 +173,7 @@ class UiSceneManager { ...@@ -174,7 +173,7 @@ class UiSceneManager {
void CreateViewportAwareRoot(); void CreateViewportAwareRoot();
void CreateUrlBar(Model* model); void CreateUrlBar(Model* model);
void CreateSuggestionList(Model* model); void CreateSuggestionList(Model* model);
void CreateWebVrUrlToast(); void CreateWebVrUrlToast(Model* model);
void CreateCloseButton(); void CreateCloseButton();
void CreateExitPrompt(Model* model); void CreateExitPrompt(Model* model);
void CreateAudioPermissionPrompt(Model* model); void CreateAudioPermissionPrompt(Model* model);
......
...@@ -816,7 +816,7 @@ TEST_F(UiSceneManagerTest, OmniboxSuggestionBindings) { ...@@ -816,7 +816,7 @@ TEST_F(UiSceneManagerTest, OmniboxSuggestionBindings) {
model_->omnibox_suggestions.emplace_back( model_->omnibox_suggestions.emplace_back(
OmniboxSuggestion(base::string16(), base::string16(), OmniboxSuggestion(base::string16(), base::string16(),
AutocompleteMatch::Type::VOICE_SUGGEST)); AutocompleteMatch::Type::VOICE_SUGGEST, GURL()));
OnBeginFrame(); OnBeginFrame();
EXPECT_EQ(container->children().size(), 1u); EXPECT_EQ(container->children().size(), 1u);
EXPECT_GT(NumVisibleChildren(kSuggestionLayout), initially_visible); EXPECT_GT(NumVisibleChildren(kSuggestionLayout), initially_visible);
......
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