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 7fb557f4dfb3adfdc5da9f4555ae18d057119b5f..c950893ac7f08af2bbe4cde22f82c86617f61eec 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" |
bulach
2013/12/11 13:29:27
nit: no longer needed
benm (inactive)
2013/12/11 20:08:51
Done.
|
#include "base/values.h" |
#include "cc/layers/layer.h" |
#include "cc/output/begin_frame_args.h" |
@@ -107,7 +108,8 @@ ScopedJavaLocalRef<jobject> CreateJavaRect( |
static_cast<int>(rect.y()), |
static_cast<int>(rect.right()), |
static_cast<int>(rect.bottom()))); |
-}; |
+} |
+ |
} // namespace |
// Enables a callback when the underlying WebContents is destroyed, to enable |
@@ -173,7 +175,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."; |
@@ -263,6 +266,8 @@ void ContentViewCoreImpl::Observe(int type, |
} |
} |
SetFocusInternal(HasFocus()); |
+ if (geolocation_needs_pause_) |
+ PauseOrResumeGeolocation(true); |
break; |
} |
case NOTIFICATION_RENDERER_PROCESS_CREATED: { |
@@ -348,6 +353,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); |