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

Side by Side Diff: android_webview/native/aw_contents.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: Wire up onPause/onResume Created 7 years, 1 month 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "android_webview/native/aw_contents.h" 5 #include "android_webview/native/aw_contents.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "android_webview/browser/aw_browser_context.h" 9 #include "android_webview/browser/aw_browser_context.h"
10 #include "android_webview/browser/aw_browser_main_parts.h" 10 #include "android_webview/browser/aw_browser_main_parts.h"
(...skipping 24 matching lines...) Expand all
35 #include "base/strings/string16.h" 35 #include "base/strings/string16.h"
36 #include "base/supports_user_data.h" 36 #include "base/supports_user_data.h"
37 #include "components/autofill/content/browser/autofill_driver_impl.h" 37 #include "components/autofill/content/browser/autofill_driver_impl.h"
38 #include "components/autofill/core/browser/autofill_manager.h" 38 #include "components/autofill/core/browser/autofill_manager.h"
39 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 39 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
40 #include "components/navigation_interception/intercept_navigation_delegate.h" 40 #include "components/navigation_interception/intercept_navigation_delegate.h"
41 #include "content/public/browser/android/content_view_core.h" 41 #include "content/public/browser/android/content_view_core.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/cert_store.h" 43 #include "content/public/browser/cert_store.h"
44 #include "content/public/browser/favicon_status.h" 44 #include "content/public/browser/favicon_status.h"
45 #include "content/public/browser/geolocation_provider.h"
45 #include "content/public/browser/navigation_entry.h" 46 #include "content/public/browser/navigation_entry.h"
46 #include "content/public/browser/render_process_host.h" 47 #include "content/public/browser/render_process_host.h"
47 #include "content/public/browser/render_view_host.h" 48 #include "content/public/browser/render_view_host.h"
48 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
49 #include "content/public/common/renderer_preferences.h" 50 #include "content/public/common/renderer_preferences.h"
50 #include "content/public/common/ssl_status.h" 51 #include "content/public/common/ssl_status.h"
51 #include "jni/AwContents_jni.h" 52 #include "jni/AwContents_jni.h"
52 #include "net/cert/x509_certificate.h" 53 #include "net/cert/x509_certificate.h"
53 #include "third_party/skia/include/core/SkPicture.h" 54 #include "third_party/skia/include/core/SkPicture.h"
54 #include "ui/base/l10n/l10n_util_android.h" 55 #include "ui/base/l10n/l10n_util_android.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; 151 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
151 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR: 152 case gfx::FontRenderParams::SUBPIXEL_RENDERING_VBGR:
152 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; 153 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
153 default: 154 default:
154 NOTREACHED() << "Unhandled subpixel rendering style " 155 NOTREACHED() << "Unhandled subpixel rendering style "
155 << subpixel_rendering; 156 << subpixel_rendering;
156 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; 157 return content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT;
157 } 158 }
158 } 159 }
159 160
161 void PauseOrResumeGeolocationUpdatesInternal(bool should_pause) {
162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
163 if (should_pause) {
164 content::GeolocationProvider::GetInstance()->
165 PauseAllLocationUpdateCallbacks();
166 } else {
167 content::GeolocationProvider::GetInstance()->
168 ResumeAllLocationUpdateCallbacks();
169 }
170 }
171
160 } // namespace 172 } // namespace
161 173
162 // static 174 // static
163 AwContents* AwContents::FromWebContents(WebContents* web_contents) { 175 AwContents* AwContents::FromWebContents(WebContents* web_contents) {
164 return AwContentsUserData::GetContents(web_contents); 176 return AwContentsUserData::GetContents(web_contents);
165 } 177 }
166 178
167 // static 179 // static
168 AwContents* AwContents::FromID(int render_process_id, int render_view_id) { 180 AwContents* AwContents::FromID(int render_process_id, int render_view_id) {
169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 static void SetAwDrawGLFunctionTable(JNIEnv* env, jclass, jint function_table) { 347 static void SetAwDrawGLFunctionTable(JNIEnv* env, jclass, jint function_table) {
336 GpuMemoryBufferFactoryImpl::SetAwDrawGLFunctionTable( 348 GpuMemoryBufferFactoryImpl::SetAwDrawGLFunctionTable(
337 reinterpret_cast<AwDrawGLFunctionTable*>(function_table)); 349 reinterpret_cast<AwDrawGLFunctionTable*>(function_table));
338 } 350 }
339 351
340 static jint GetAwDrawGLFunction(JNIEnv* env, jclass) { 352 static jint GetAwDrawGLFunction(JNIEnv* env, jclass) {
341 return reinterpret_cast<jint>(&DrawGLFunction); 353 return reinterpret_cast<jint>(&DrawGLFunction);
342 } 354 }
343 355
344 // static 356 // static
357 void PauseOrResumeGeolocation(JNIEnv* env,
358 jclass,
359 jboolean should_pause) {
360 content::BrowserThread::PostTask(
361 content::BrowserThread::IO,
362 FROM_HERE,
363 base::Bind(&PauseOrResumeGeolocationUpdatesInternal, should_pause));
364 }
365
366 // static
345 jint GetNativeInstanceCount(JNIEnv* env, jclass) { 367 jint GetNativeInstanceCount(JNIEnv* env, jclass) {
346 return base::subtle::NoBarrier_Load(&g_instance_count); 368 return base::subtle::NoBarrier_Load(&g_instance_count);
347 } 369 }
348 370
349 jint AwContents::GetAwDrawGLViewContext(JNIEnv* env, jobject obj) { 371 jint AwContents::GetAwDrawGLViewContext(JNIEnv* env, jobject obj) {
350 return reinterpret_cast<jint>(browser_view_renderer_.get()); 372 return reinterpret_cast<jint>(browser_view_renderer_.get());
351 } 373 }
352 374
353 namespace { 375 namespace {
354 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message, 376 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message,
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 void AwContents::SetViewVisibility(JNIEnv* env, jobject obj, bool visible) { 707 void AwContents::SetViewVisibility(JNIEnv* env, jobject obj, bool visible) {
686 browser_view_renderer_->SetViewVisibility(visible); 708 browser_view_renderer_->SetViewVisibility(visible);
687 } 709 }
688 710
689 void AwContents::SetWindowVisibility(JNIEnv* env, jobject obj, bool visible) { 711 void AwContents::SetWindowVisibility(JNIEnv* env, jobject obj, bool visible) {
690 browser_view_renderer_->SetWindowVisibility(visible); 712 browser_view_renderer_->SetWindowVisibility(visible);
691 } 713 }
692 714
693 void AwContents::SetIsPaused(JNIEnv* env, jobject obj, bool paused) { 715 void AwContents::SetIsPaused(JNIEnv* env, jobject obj, bool paused) {
694 browser_view_renderer_->SetIsPaused(paused); 716 browser_view_renderer_->SetIsPaused(paused);
717 render_view_host_ext_->PauseOrResumeGeolocation(paused);
718
695 if (paused) { 719 if (paused) {
696 ContentViewCore* cvc = 720 ContentViewCore* cvc =
697 ContentViewCore::FromWebContents(web_contents_.get()); 721 ContentViewCore::FromWebContents(web_contents_.get());
698 if (cvc) 722 if (cvc)
699 cvc->PauseVideo(); 723 cvc->PauseVideo();
700 } 724 }
701 } 725 }
702 726
703 void AwContents::OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h) { 727 void AwContents::OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h) {
704 browser_view_renderer_->OnAttachedToWindow(w, h); 728 browser_view_renderer_->OnAttachedToWindow(w, h);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 938
915 void AwContents::TrimMemory(JNIEnv* env, jobject obj, jint level) { 939 void AwContents::TrimMemory(JNIEnv* env, jobject obj, jint level) {
916 browser_view_renderer_->TrimMemory(level); 940 browser_view_renderer_->TrimMemory(level);
917 } 941 }
918 942
919 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { 943 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) {
920 g_should_download_favicons = true; 944 g_should_download_favicons = true;
921 } 945 }
922 946
923 } // namespace android_webview 947 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698