| Index: content/browser/android/content_view_core_impl.cc
|
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
|
| index 474e99536851d6b9c8e2de9aa1644b96243cda30..f5861923405f31e29dadd3183c57ee5a2117ca7f 100644
|
| --- a/content/browser/android/content_view_core_impl.cc
|
| +++ b/content/browser/android/content_view_core_impl.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "base/synchronization/waitable_event.h"
|
| #include "base/values.h"
|
| #include "cc/layers/layer.h"
|
| #include "cc/output/begin_frame_args.h"
|
| @@ -107,7 +108,17 @@ ScopedJavaLocalRef<jobject> CreateJavaRect(
|
| static_cast<int>(rect.y()),
|
| static_cast<int>(rect.right()),
|
| static_cast<int>(rect.bottom())));
|
| -};
|
| +}
|
| +
|
| +void IsGeolocationActiveForTestingOnIOThread(
|
| + scoped_refptr<GeolocationDispatcherHost> d,
|
| + base::WaitableEvent* completion,
|
| + bool* result) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + *result = d->IsGeolocationActive();
|
| + completion->Signal();
|
| +}
|
| +
|
| } // namespace
|
|
|
| // Enables a callback when the underlying WebContents is destroyed, to enable
|
| @@ -173,7 +184,8 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj,
|
| kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)),
|
| view_android_(view_android),
|
| window_android_(window_android),
|
| - device_orientation_(0) {
|
| + device_orientation_(0),
|
| + geolocation_needs_pause_(false) {
|
| CHECK(web_contents) <<
|
| "A ContentViewCoreImpl should be created with a valid WebContents.";
|
|
|
| @@ -258,6 +270,8 @@ void ContentViewCoreImpl::Observe(int type,
|
| }
|
| }
|
| SetFocusInternal(HasFocus());
|
| + if (geolocation_needs_pause_)
|
| + PauseOrResumeGeolocation(true);
|
| break;
|
| }
|
| case NOTIFICATION_RENDERER_PROCESS_CREATED: {
|
| @@ -343,6 +357,26 @@ void ContentViewCoreImpl::PauseVideo() {
|
| host->Send(new ViewMsg_PauseVideo(host->GetRoutingID()));
|
| }
|
|
|
| +void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) {
|
| + geolocation_needs_pause_ = should_pause;
|
| + RenderViewHostImpl* rvh =
|
| + static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
|
| + if (rvh) {
|
| + scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher =
|
| + static_cast<RenderProcessHostImpl*>(
|
| + web_contents_->GetRenderProcessHost())->
|
| + geolocation_dispatcher_host();
|
| + if (geolocation_dispatcher.get()) {
|
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
| + base::Bind(&GeolocationDispatcherHost::PauseOrResume,
|
| + geolocation_dispatcher,
|
| + rvh->GetRoutingID(),
|
| + should_pause));
|
| + geolocation_needs_pause_ = false;
|
| + }
|
| + }
|
| +}
|
| +
|
| void ContentViewCoreImpl::OnTabCrashed() {
|
| JNIEnv* env = AttachCurrentThread();
|
| ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
|
| @@ -1627,6 +1661,29 @@ void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
|
| rvhi->SendOrientationChangeEvent(device_orientation_);
|
| }
|
|
|
| +bool ContentViewCoreImpl::IsGeolocationActiveForTesting(JNIEnv* env,
|
| + jobject obj) {
|
| + RenderViewHostImpl* rvh =
|
| + static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
|
| + if (rvh) {
|
| + scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher =
|
| + static_cast<RenderProcessHostImpl*>(
|
| + web_contents_->GetRenderProcessHost())->
|
| + geolocation_dispatcher_host();
|
| + if (geolocation_dispatcher.get()) {
|
| + bool result = false;
|
| + base::WaitableEvent completion(false, false);
|
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
| + base::Bind(IsGeolocationActiveForTestingOnIOThread,
|
| + geolocation_dispatcher, &completion, &result));
|
| + completion.Wait();
|
| + return result;
|
| + }
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| // This is called for each ContentView.
|
| jlong Init(JNIEnv* env, jobject obj,
|
| jboolean hardware_accelerated,
|
|
|