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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.h

Issue 2960903002: VR: Use ToolbarModel to drive VR URL bar state. (Closed)
Patch Set: Update toolbar build file to include vector icons for Android. Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/android/jni_weak_ref.h" 12 #include "base/android/jni_weak_ref.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "chrome/browser/android/vr_shell/ui_interface.h" 17 #include "chrome/browser/android/vr_shell/ui_interface.h"
18 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h" 18 #include "chrome/browser/android/vr_shell/ui_unsupported_mode.h"
19 #include "chrome/browser/android/vr_shell/vr_controller_model.h" 19 #include "chrome/browser/android/vr_shell/vr_controller_model.h"
20 #include "chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.h"
20 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
21 #include "device/vr/android/gvr/cardboard_gamepad_data_provider.h" 22 #include "device/vr/android/gvr/cardboard_gamepad_data_provider.h"
22 #include "device/vr/android/gvr/gvr_delegate.h" 23 #include "device/vr/android/gvr/gvr_delegate.h"
23 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" 24 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
24 #include "device/vr/vr_service.mojom.h" 25 #include "device/vr/vr_service.mojom.h"
25 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" 26 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
26 27
27 namespace blink { 28 namespace blink {
28 class WebInputEvent; 29 class WebInputEvent;
29 } 30 }
30 31
31 namespace content { 32 namespace content {
32 class WebContents; 33 class WebContents;
33 } 34 }
34 35
35 namespace ui { 36 namespace ui {
36 class WindowAndroid; 37 class WindowAndroid;
37 } 38 }
38 39
39 namespace vr_shell { 40 namespace vr_shell {
40 41
41 class AndroidUiGestureTarget; 42 class AndroidUiGestureTarget;
43 class ToolbarHelper;
42 class UiInterface; 44 class UiInterface;
43 class VrCompositor; 45 class VrCompositor;
44 class VrGLThread; 46 class VrGLThread;
45 class VrInputManager; 47 class VrInputManager;
46 class VrMetricsHelper; 48 class VrMetricsHelper;
47 class VrShellDelegate; 49 class VrShellDelegate;
48 class VrWebContentsObserver; 50 class VrWebContentsObserver;
49 51
50 enum UiAction { 52 enum UiAction {
51 HISTORY_BACK = 0, 53 HISTORY_BACK = 0,
52 HISTORY_FORWARD, 54 HISTORY_FORWARD,
53 RELOAD, 55 RELOAD,
54 SHOW_TAB, 56 SHOW_TAB,
55 OPEN_NEW_TAB, 57 OPEN_NEW_TAB,
56 EXIT_PRESENT, 58 EXIT_PRESENT,
57 }; 59 };
58 60
59 class VrMetricsHelper; 61 class VrMetricsHelper;
60 62
61 // The native instance of the Java VrShell. This class is not threadsafe and 63 // The native instance of the Java VrShell. This class is not threadsafe and
62 // must only be used on the UI thread. 64 // must only be used on the UI thread.
63 class VrShell : public device::GvrDelegate, 65 class VrShell : public device::GvrDelegate,
64 device::GvrGamepadDataProvider, 66 device::GvrGamepadDataProvider,
65 device::CardboardGamepadDataProvider { 67 device::CardboardGamepadDataProvider,
68 public ChromeToolbarModelDelegate {
66 public: 69 public:
67 VrShell(JNIEnv* env, 70 VrShell(JNIEnv* env,
68 jobject obj, 71 jobject obj,
69 ui::WindowAndroid* window, 72 ui::WindowAndroid* window,
70 bool for_web_vr, 73 bool for_web_vr,
71 bool web_vr_autopresentation_expected, 74 bool web_vr_autopresentation_expected,
72 bool in_cct, 75 bool in_cct,
73 VrShellDelegate* delegate, 76 VrShellDelegate* delegate,
74 gvr_context* gvr_api, 77 gvr_context* gvr_api,
75 bool reprojected_rendering); 78 bool reprojected_rendering);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void SubmitControllerModel(std::unique_ptr<VrControllerModel> model); 171 void SubmitControllerModel(std::unique_ptr<VrControllerModel> model);
169 172
170 // device::GvrGamepadDataProvider implementation. 173 // device::GvrGamepadDataProvider implementation.
171 void UpdateGamepadData(device::GvrGamepadData) override; 174 void UpdateGamepadData(device::GvrGamepadData) override;
172 void RegisterGvrGamepadDataFetcher(device::GvrGamepadDataFetcher*) override; 175 void RegisterGvrGamepadDataFetcher(device::GvrGamepadDataFetcher*) override;
173 176
174 // device::CardboardGamepadDataProvider implementation. 177 // device::CardboardGamepadDataProvider implementation.
175 void RegisterCardboardGamepadDataFetcher( 178 void RegisterCardboardGamepadDataFetcher(
176 device::CardboardGamepadDataFetcher*) override; 179 device::CardboardGamepadDataFetcher*) override;
177 180
181 // ChromeToolbarModelDelegate implementation.
182 content::WebContents* GetActiveWebContents() const override;
183
178 private: 184 private:
179 ~VrShell() override; 185 ~VrShell() override;
180 void WaitForGlThread(); 186 void WaitForGlThread();
181 void PostToGlThread(const tracked_objects::Location& from_here, 187 void PostToGlThread(const tracked_objects::Location& from_here,
182 const base::Closure& task); 188 const base::Closure& task);
183 void SetUiState(); 189 void SetUiState();
184 190
185 // device::GvrDelegate implementation. 191 // device::GvrDelegate implementation.
186 void SetWebVRSecureOrigin(bool secure_origin) override; 192 void SetWebVRSecureOrigin(bool secure_origin) override;
187 void UpdateVSyncInterval(int64_t timebase_nanos, 193 void UpdateVSyncInterval(int64_t timebase_nanos,
(...skipping 26 matching lines...) Expand all
214 VrShellDelegate* delegate_provider_ = nullptr; 220 VrShellDelegate* delegate_provider_ = nullptr;
215 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_; 221 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_;
216 222
217 std::unique_ptr<VrInputManager> input_manager_; 223 std::unique_ptr<VrInputManager> input_manager_;
218 std::unique_ptr<AndroidUiGestureTarget> android_ui_gesture_target_; 224 std::unique_ptr<AndroidUiGestureTarget> android_ui_gesture_target_;
219 std::unique_ptr<VrMetricsHelper> metrics_helper_; 225 std::unique_ptr<VrMetricsHelper> metrics_helper_;
220 226
221 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 227 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
222 std::unique_ptr<VrGLThread> gl_thread_; 228 std::unique_ptr<VrGLThread> gl_thread_;
223 bool thread_started_ = false; 229 bool thread_started_ = false;
230 bool reprojected_rendering_;
231
224 UiInterface* ui_; 232 UiInterface* ui_;
225 bool reprojected_rendering_; 233 std::unique_ptr<ToolbarHelper> toolbar_;
226 234
227 jobject content_surface_ = nullptr; 235 jobject content_surface_ = nullptr;
228 bool taken_surface_ = false; 236 bool taken_surface_ = false;
229 base::CancelableClosure poll_capturing_media_task_; 237 base::CancelableClosure poll_capturing_media_task_;
230 bool is_capturing_audio_ = false; 238 bool is_capturing_audio_ = false;
231 bool is_capturing_video_ = false; 239 bool is_capturing_video_ = false;
232 bool is_capturing_screen_ = false; 240 bool is_capturing_screen_ = false;
233 241
234 // Are we currently providing a gamepad factory to the gamepad manager? 242 // Are we currently providing a gamepad factory to the gamepad manager?
235 bool gvr_gamepad_source_active_ = false; 243 bool gvr_gamepad_source_active_ = false;
236 bool cardboard_gamepad_source_active_ = false; 244 bool cardboard_gamepad_source_active_ = false;
237 245
238 // Registered fetchers, must remain alive for UpdateGamepadData calls. 246 // Registered fetchers, must remain alive for UpdateGamepadData calls.
239 // That's ok since the fetcher is only destroyed from VrShell's destructor. 247 // That's ok since the fetcher is only destroyed from VrShell's destructor.
240 device::GvrGamepadDataFetcher* gvr_gamepad_data_fetcher_ = nullptr; 248 device::GvrGamepadDataFetcher* gvr_gamepad_data_fetcher_ = nullptr;
241 device::CardboardGamepadDataFetcher* cardboard_gamepad_data_fetcher_ = 249 device::CardboardGamepadDataFetcher* cardboard_gamepad_data_fetcher_ =
242 nullptr; 250 nullptr;
243 int64_t cardboard_gamepad_timer_ = 0; 251 int64_t cardboard_gamepad_timer_ = 0;
244 252
245 base::WeakPtrFactory<VrShell> weak_ptr_factory_; 253 base::WeakPtrFactory<VrShell> weak_ptr_factory_;
246 254
247 DISALLOW_COPY_AND_ASSIGN(VrShell); 255 DISALLOW_COPY_AND_ASSIGN(VrShell);
248 }; 256 };
249 257
250 bool RegisterVrShell(JNIEnv* env); 258 bool RegisterVrShell(JNIEnv* env);
251 259
252 } // namespace vr_shell 260 } // namespace vr_shell
253 261
254 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_ 262 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_gl_thread.cc ('k') | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698