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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 65273002: Add a mechanism to pause and resume geolocation requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
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 5b7fb8b4be1dad8e0699c9955156b983ffa2d1b7..fd808fed4f3841f3f33587219fac6f21bad1c076 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -107,7 +107,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 +174,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 +265,8 @@ void ContentViewCoreImpl::Observe(int type,
}
}
SetFocusInternal(HasFocus());
+ if (geolocation_needs_pause_)
+ PauseOrResumeGeolocation(true);
break;
}
case NOTIFICATION_RENDERER_PROCESS_CREATED: {
@@ -348,6 +352,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);
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/geolocation/geolocation_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698