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

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

Issue 2975683002: Add GeolocationManager service (Closed)
Patch Set: typo 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/vr/ui_interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/android/vr_shell/vr_shell.h" 5 #include "chrome/browser/android/vr_shell/vr_shell.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 27 matching lines...) Expand all
38 #include "content/public/browser/browser_context.h" 38 #include "content/public/browser/browser_context.h"
39 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/navigation_controller.h" 40 #include "content/public/browser/navigation_controller.h"
41 #include "content/public/browser/render_view_host.h" 41 #include "content/public/browser/render_view_host.h"
42 #include "content/public/browser/render_widget_host.h" 42 #include "content/public/browser/render_widget_host.h"
43 #include "content/public/browser/render_widget_host_iterator.h" 43 #include "content/public/browser/render_widget_host_iterator.h"
44 #include "content/public/browser/render_widget_host_view.h" 44 #include "content/public/browser/render_widget_host_view.h"
45 #include "content/public/browser/web_contents.h" 45 #include "content/public/browser/web_contents.h"
46 #include "content/public/common/content_features.h" 46 #include "content/public/common/content_features.h"
47 #include "content/public/common/referrer.h" 47 #include "content/public/common/referrer.h"
48 #include "content/public/common/service_manager_connection.h"
49 #include "device/geolocation/public/interfaces/geolocation_config.mojom.h"
48 #include "device/vr/android/gvr/cardboard_gamepad_data_fetcher.h" 50 #include "device/vr/android/gvr/cardboard_gamepad_data_fetcher.h"
49 #include "device/vr/android/gvr/gvr_device.h" 51 #include "device/vr/android/gvr/gvr_device.h"
50 #include "device/vr/android/gvr/gvr_device_provider.h" 52 #include "device/vr/android/gvr/gvr_device_provider.h"
51 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h" 53 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
52 #include "gpu/command_buffer/common/mailbox.h" 54 #include "gpu/command_buffer/common/mailbox.h"
53 #include "jni/VrShellImpl_jni.h" 55 #include "jni/VrShellImpl_jni.h"
56 #include "services/service_manager/public/cpp/connector.h"
54 #include "third_party/WebKit/public/platform/WebInputEvent.h" 57 #include "third_party/WebKit/public/platform/WebInputEvent.h"
55 #include "ui/android/view_android.h" 58 #include "ui/android/view_android.h"
56 #include "ui/android/window_android.h" 59 #include "ui/android/window_android.h"
57 #include "ui/base/page_transition_types.h" 60 #include "ui/base/page_transition_types.h"
58 #include "ui/display/display.h" 61 #include "ui/display/display.h"
59 #include "ui/display/screen.h" 62 #include "ui/display/screen.h"
60 #include "ui/gfx/android/java_bitmap.h" 63 #include "ui/gfx/android/java_bitmap.h"
61 #include "ui/gfx/codec/png_codec.h" 64 #include "ui/gfx/codec/png_codec.h"
62 #include "ui/gfx/geometry/size.h" 65 #include "ui/gfx/geometry/size.h"
63 #include "ui/gfx/native_widget_types.h" 66 #include "ui/gfx/native_widget_types.h"
64 #include "url/gurl.h" 67 #include "url/gurl.h"
65 68
66 using base::android::JavaParamRef; 69 using base::android::JavaParamRef;
67 using base::android::JavaRef; 70 using base::android::JavaRef;
68 71
69 namespace vr_shell { 72 namespace vr_shell {
70 73
71 namespace { 74 namespace {
72 vr_shell::VrShell* g_instance; 75 vr_shell::VrShell* g_instance;
73 76
74 constexpr base::TimeDelta poll_media_access_interval_ = 77 constexpr base::TimeDelta poll_media_access_interval_ =
75 base::TimeDelta::FromSecondsD(0.1); 78 base::TimeDelta::FromSecondsD(0.2);
76 79
77 constexpr base::TimeDelta kExitVrDueToUnsupportedModeDelay = 80 constexpr base::TimeDelta kExitVrDueToUnsupportedModeDelay =
78 base::TimeDelta::FromSeconds(5); 81 base::TimeDelta::FromSeconds(5);
79 82
80 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { 83 void SetIsInVR(content::WebContents* contents, bool is_in_vr) {
81 if (contents && contents->GetRenderWidgetHostView()) { 84 if (contents && contents->GetRenderWidgetHostView()) {
82 // TODO(asimjour) Contents should not be aware of VR mode. Instead, we 85 // TODO(asimjour) Contents should not be aware of VR mode. Instead, we
83 // should add a flag for disabling specific UI such as the keyboard (see 86 // should add a flag for disabling specific UI such as the keyboard (see
84 // VrTabHelper for details). 87 // VrTabHelper for details).
85 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); 88 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // be no duplicate WebContents here. 640 // be no duplicate WebContents here.
638 if (indicator->IsCapturingAudio(web_contents)) 641 if (indicator->IsCapturingAudio(web_contents))
639 num_tabs_capturing_audio++; 642 num_tabs_capturing_audio++;
640 if (indicator->IsCapturingVideo(web_contents)) 643 if (indicator->IsCapturingVideo(web_contents))
641 num_tabs_capturing_video++; 644 num_tabs_capturing_video++;
642 if (indicator->IsBeingMirrored(web_contents)) 645 if (indicator->IsBeingMirrored(web_contents))
643 num_tabs_capturing_screen++; 646 num_tabs_capturing_screen++;
644 if (web_contents->IsConnectedToBluetoothDevice()) 647 if (web_contents->IsConnectedToBluetoothDevice())
645 num_tabs_bluetooth_connected++; 648 num_tabs_bluetooth_connected++;
646 } 649 }
650 auto* connector =
651 content::ServiceManagerConnection::GetForProcess()->GetConnector();
652 connector->BindInterface("content_browser", &geolocation_config_);
653
654 geolocation_config_->IsHighAccuracyLocationBeingCaptured(
655 base::Bind(&VrShell::SetHighAccuracyLocation, base::Unretained(this)));
647 656
648 bool is_capturing_audio = num_tabs_capturing_audio > 0; 657 bool is_capturing_audio = num_tabs_capturing_audio > 0;
649 bool is_capturing_video = num_tabs_capturing_video > 0; 658 bool is_capturing_video = num_tabs_capturing_video > 0;
650 bool is_capturing_screen = num_tabs_capturing_screen > 0; 659 bool is_capturing_screen = num_tabs_capturing_screen > 0;
651 bool is_bluetooth_connected = num_tabs_bluetooth_connected > 0; 660 bool is_bluetooth_connected = num_tabs_bluetooth_connected > 0;
652 if (is_capturing_audio != is_capturing_audio_) { 661 if (is_capturing_audio != is_capturing_audio_) {
653 ui_->SetAudioCapturingIndicator(is_capturing_audio); 662 ui_->SetAudioCapturingIndicator(is_capturing_audio);
654 is_capturing_audio_ = is_capturing_audio; 663 is_capturing_audio_ = is_capturing_audio;
655 } 664 }
656 if (is_capturing_video != is_capturing_video_) { 665 if (is_capturing_video != is_capturing_video_) {
657 ui_->SetVideoCapturingIndicator(is_capturing_video); 666 ui_->SetVideoCapturingIndicator(is_capturing_video);
658 is_capturing_video_ = is_capturing_video; 667 is_capturing_video_ = is_capturing_video;
659 } 668 }
660 if (is_capturing_screen != is_capturing_screen_) { 669 if (is_capturing_screen != is_capturing_screen_) {
661 ui_->SetScreenCapturingIndicator(is_capturing_screen); 670 ui_->SetScreenCapturingIndicator(is_capturing_screen);
662 is_capturing_screen_ = is_capturing_screen; 671 is_capturing_screen_ = is_capturing_screen;
663 } 672 }
664 if (is_bluetooth_connected != is_bluetooth_connected_) { 673 if (is_bluetooth_connected != is_bluetooth_connected_) {
665 ui_->SetBluetoothConnectedIndicator(is_bluetooth_connected); 674 ui_->SetBluetoothConnectedIndicator(is_bluetooth_connected);
666 is_bluetooth_connected_ = is_bluetooth_connected; 675 is_bluetooth_connected_ = is_bluetooth_connected;
667 } 676 }
668 } 677 }
669 678
679 void VrShell::SetHighAccuracyLocation(bool high_accuracy_location) {
680 if (high_accuracy_location == high_accuracy_location_)
681 return;
682 ui_->SetLocationAccessIndicator(high_accuracy_location);
683 high_accuracy_location_ = high_accuracy_location;
684 }
685
670 void VrShell::SetContentCssSize(float width, float height, float dpr) { 686 void VrShell::SetContentCssSize(float width, float height, float dpr) {
671 JNIEnv* env = base::android::AttachCurrentThread(); 687 JNIEnv* env = base::android::AttachCurrentThread();
672 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, 688 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height,
673 dpr); 689 dpr);
674 } 690 }
675 691
676 void VrShell::ProcessContentGesture( 692 void VrShell::ProcessContentGesture(
677 std::unique_ptr<blink::WebInputEvent> event) { 693 std::unique_ptr<blink::WebInputEvent> event) {
678 if (input_manager_) { 694 if (input_manager_) {
679 input_manager_->ProcessUpdatedGesture(std::move(event)); 695 input_manager_->ProcessUpdatedGesture(std::move(event));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 jlong gvr_api, 749 jlong gvr_api,
734 jboolean reprojected_rendering) { 750 jboolean reprojected_rendering) {
735 return reinterpret_cast<intptr_t>(new VrShell( 751 return reinterpret_cast<intptr_t>(new VrShell(
736 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), 752 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android),
737 for_web_vr, web_vr_autopresentation_expected, in_cct, 753 for_web_vr, web_vr_autopresentation_expected, in_cct,
738 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 754 VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
739 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 755 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
740 } 756 }
741 757
742 } // namespace vr_shell 758 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/vr/ui_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698