| OLD | NEW |
| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_context.h" | 10 #include "android_webview/browser/aw_browser_context.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 base::android::GetDefaultLocale(), | 272 base::android::GetDefaultLocale(), |
| 273 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); | 273 AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void AwContents::SetAwAutofillClient(jobject client) { | 276 void AwContents::SetAwAutofillClient(jobject client) { |
| 277 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 277 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 278 JNIEnv* env = AttachCurrentThread(); | 278 JNIEnv* env = AttachCurrentThread(); |
| 279 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 279 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 280 if (obj.is_null()) | 280 if (obj.is_null()) |
| 281 return; | 281 return; |
| 282 Java_AwContents_setAwAutofillClient(env, obj.obj(), client); | 282 Java_AwContents_setAwAutofillClient(env, obj, client); |
| 283 } | 283 } |
| 284 | 284 |
| 285 AwContents::~AwContents() { | 285 AwContents::~AwContents() { |
| 286 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_.get())); | 286 DCHECK_EQ(this, AwContents::FromWebContents(web_contents_.get())); |
| 287 web_contents_->RemoveUserData(kAwContentsUserDataKey); | 287 web_contents_->RemoveUserData(kAwContentsUserDataKey); |
| 288 if (find_helper_.get()) | 288 if (find_helper_.get()) |
| 289 find_helper_->SetListener(NULL); | 289 find_helper_->SetListener(NULL); |
| 290 if (icon_helper_.get()) | 290 if (icon_helper_.get()) |
| 291 icon_helper_->SetListener(NULL); | 291 icon_helper_->SetListener(NULL); |
| 292 base::subtle::Atomic32 instance_count = | 292 base::subtle::Atomic32 instance_count = |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 jlong function_table) {} | 370 jlong function_table) {} |
| 371 | 371 |
| 372 // static | 372 // static |
| 373 jint GetNativeInstanceCount(JNIEnv* env, const JavaParamRef<jclass>&) { | 373 jint GetNativeInstanceCount(JNIEnv* env, const JavaParamRef<jclass>&) { |
| 374 return base::subtle::NoBarrier_Load(&g_instance_count); | 374 return base::subtle::NoBarrier_Load(&g_instance_count); |
| 375 } | 375 } |
| 376 | 376 |
| 377 namespace { | 377 namespace { |
| 378 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message, | 378 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message, |
| 379 bool has_images) { | 379 bool has_images) { |
| 380 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(), | 380 Java_AwContents_onDocumentHasImagesResponse(AttachCurrentThread(), has_images, |
| 381 has_images, | 381 message); |
| 382 message.obj()); | |
| 383 } | 382 } |
| 384 } // namespace | 383 } // namespace |
| 385 | 384 |
| 386 void AwContents::DocumentHasImages(JNIEnv* env, | 385 void AwContents::DocumentHasImages(JNIEnv* env, |
| 387 const JavaParamRef<jobject>& obj, | 386 const JavaParamRef<jobject>& obj, |
| 388 const JavaParamRef<jobject>& message) { | 387 const JavaParamRef<jobject>& message) { |
| 389 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 388 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 390 ScopedJavaGlobalRef<jobject> j_message; | 389 ScopedJavaGlobalRef<jobject> j_message; |
| 391 j_message.Reset(env, message); | 390 j_message.Reset(env, message); |
| 392 render_view_host_ext_->DocumentHasImages( | 391 render_view_host_ext_->DocumentHasImages( |
| 393 base::Bind(&DocumentHasImagesCallback, j_message)); | 392 base::Bind(&DocumentHasImagesCallback, j_message)); |
| 394 } | 393 } |
| 395 | 394 |
| 396 namespace { | 395 namespace { |
| 397 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback, | 396 void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback, |
| 398 const base::FilePath& path, | 397 const base::FilePath& path, |
| 399 int64_t size) { | 398 int64_t size) { |
| 400 JNIEnv* env = AttachCurrentThread(); | 399 JNIEnv* env = AttachCurrentThread(); |
| 401 // Android files are UTF8, so the path conversion below is safe. | 400 // Android files are UTF8, so the path conversion below is safe. |
| 402 Java_AwContents_generateMHTMLCallback( | 401 Java_AwContents_generateMHTMLCallback( |
| 403 env, | 402 env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, |
| 404 ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()).obj(), | 403 callback->obj()); |
| 405 size, callback->obj()); | |
| 406 } | 404 } |
| 407 } // namespace | 405 } // namespace |
| 408 | 406 |
| 409 void AwContents::GenerateMHTML(JNIEnv* env, | 407 void AwContents::GenerateMHTML(JNIEnv* env, |
| 410 const JavaParamRef<jobject>& obj, | 408 const JavaParamRef<jobject>& obj, |
| 411 const JavaParamRef<jstring>& jpath, | 409 const JavaParamRef<jstring>& jpath, |
| 412 const JavaParamRef<jobject>& callback) { | 410 const JavaParamRef<jobject>& callback) { |
| 413 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 411 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 414 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); | 412 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| 415 j_callback->Reset(env, callback); | 413 j_callback->Reset(env, callback); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 434 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 432 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 435 JNIEnv* env = AttachCurrentThread(); | 433 JNIEnv* env = AttachCurrentThread(); |
| 436 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 434 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 437 if (obj.is_null()) | 435 if (obj.is_null()) |
| 438 return false; | 436 return false; |
| 439 | 437 |
| 440 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); | 438 ScopedJavaLocalRef<jstring> jhost = ConvertUTF8ToJavaString(env, host); |
| 441 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); | 439 ScopedJavaLocalRef<jstring> jrealm = ConvertUTF8ToJavaString(env, realm); |
| 442 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( | 440 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( |
| 443 "onReceivedHttpAuthRequest"); | 441 "onReceivedHttpAuthRequest"); |
| 444 Java_AwContents_onReceivedHttpAuthRequest(env, obj.obj(), handler.obj(), | 442 Java_AwContents_onReceivedHttpAuthRequest(env, obj, handler, jhost, jrealm); |
| 445 jhost.obj(), jrealm.obj()); | |
| 446 return true; | 443 return true; |
| 447 } | 444 } |
| 448 | 445 |
| 449 void AwContents::SetOffscreenPreRaster(bool enabled) { | 446 void AwContents::SetOffscreenPreRaster(bool enabled) { |
| 450 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 447 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 451 browser_view_renderer_.SetOffscreenPreRaster(enabled); | 448 browser_view_renderer_.SetOffscreenPreRaster(enabled); |
| 452 } | 449 } |
| 453 | 450 |
| 454 void AwContents::AddVisitedLinks( | 451 void AwContents::AddVisitedLinks( |
| 455 JNIEnv* env, | 452 JNIEnv* env, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 479 | 476 |
| 480 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef& java_ref, | 477 void ShowGeolocationPromptHelperTask(const JavaObjectWeakGlobalRef& java_ref, |
| 481 const GURL& origin) { | 478 const GURL& origin) { |
| 482 JNIEnv* env = AttachCurrentThread(); | 479 JNIEnv* env = AttachCurrentThread(); |
| 483 ScopedJavaLocalRef<jobject> j_ref = java_ref.get(env); | 480 ScopedJavaLocalRef<jobject> j_ref = java_ref.get(env); |
| 484 if (j_ref.obj()) { | 481 if (j_ref.obj()) { |
| 485 ScopedJavaLocalRef<jstring> j_origin( | 482 ScopedJavaLocalRef<jstring> j_origin( |
| 486 ConvertUTF8ToJavaString(env, origin.spec())); | 483 ConvertUTF8ToJavaString(env, origin.spec())); |
| 487 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( | 484 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( |
| 488 "onGeolocationPermissionsShowPrompt"); | 485 "onGeolocationPermissionsShowPrompt"); |
| 489 Java_AwContents_onGeolocationPermissionsShowPrompt(env, | 486 Java_AwContents_onGeolocationPermissionsShowPrompt(env, j_ref, j_origin); |
| 490 j_ref.obj(), | |
| 491 j_origin.obj()); | |
| 492 } | 487 } |
| 493 } | 488 } |
| 494 | 489 |
| 495 void ShowGeolocationPromptHelper(const JavaObjectWeakGlobalRef& java_ref, | 490 void ShowGeolocationPromptHelper(const JavaObjectWeakGlobalRef& java_ref, |
| 496 const GURL& origin) { | 491 const GURL& origin) { |
| 497 JNIEnv* env = AttachCurrentThread(); | 492 JNIEnv* env = AttachCurrentThread(); |
| 498 if (java_ref.get(env).obj()) { | 493 if (java_ref.get(env).obj()) { |
| 499 content::BrowserThread::PostTask( | 494 content::BrowserThread::PostTask( |
| 500 content::BrowserThread::UI, | 495 content::BrowserThread::UI, |
| 501 FROM_HERE, | 496 FROM_HERE, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 ++it; | 550 ++it; |
| 556 } | 551 } |
| 557 } | 552 } |
| 558 | 553 |
| 559 if (removed_current_outstanding_callback) { | 554 if (removed_current_outstanding_callback) { |
| 560 JNIEnv* env = AttachCurrentThread(); | 555 JNIEnv* env = AttachCurrentThread(); |
| 561 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); | 556 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); |
| 562 if (j_ref.obj()) { | 557 if (j_ref.obj()) { |
| 563 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( | 558 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( |
| 564 "onGeolocationPermissionsHidePrompt"); | 559 "onGeolocationPermissionsHidePrompt"); |
| 565 Java_AwContents_onGeolocationPermissionsHidePrompt(env, j_ref.obj()); | 560 Java_AwContents_onGeolocationPermissionsHidePrompt(env, j_ref); |
| 566 } | 561 } |
| 567 if (!pending_geolocation_prompts_.empty()) { | 562 if (!pending_geolocation_prompts_.empty()) { |
| 568 ShowGeolocationPromptHelper(java_ref_, | 563 ShowGeolocationPromptHelper(java_ref_, |
| 569 pending_geolocation_prompts_.front().first); | 564 pending_geolocation_prompts_.front().first); |
| 570 } | 565 } |
| 571 } | 566 } |
| 572 } | 567 } |
| 573 | 568 |
| 574 void AwContents::OnPermissionRequest( | 569 void AwContents::OnPermissionRequest( |
| 575 base::android::ScopedJavaLocalRef<jobject> j_request, | 570 base::android::ScopedJavaLocalRef<jobject> j_request, |
| 576 AwPermissionRequest* request) { | 571 AwPermissionRequest* request) { |
| 577 DCHECK(!j_request.is_null()); | 572 DCHECK(!j_request.is_null()); |
| 578 DCHECK(request); | 573 DCHECK(request); |
| 579 | 574 |
| 580 JNIEnv* env = AttachCurrentThread(); | 575 JNIEnv* env = AttachCurrentThread(); |
| 581 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); | 576 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); |
| 582 if (j_ref.is_null()) { | 577 if (j_ref.is_null()) { |
| 583 permission_request_handler_->CancelRequest(request->GetOrigin(), | 578 permission_request_handler_->CancelRequest(request->GetOrigin(), |
| 584 request->GetResources()); | 579 request->GetResources()); |
| 585 return; | 580 return; |
| 586 } | 581 } |
| 587 | 582 |
| 588 Java_AwContents_onPermissionRequest(env, j_ref.obj(), j_request.obj()); | 583 Java_AwContents_onPermissionRequest(env, j_ref, j_request); |
| 589 } | 584 } |
| 590 | 585 |
| 591 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest* request) { | 586 void AwContents::OnPermissionRequestCanceled(AwPermissionRequest* request) { |
| 592 JNIEnv* env = AttachCurrentThread(); | 587 JNIEnv* env = AttachCurrentThread(); |
| 593 ScopedJavaLocalRef<jobject> j_request = request->GetJavaObject(); | 588 ScopedJavaLocalRef<jobject> j_request = request->GetJavaObject(); |
| 594 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); | 589 ScopedJavaLocalRef<jobject> j_ref = java_ref_.get(env); |
| 595 if (j_request.is_null() || j_ref.is_null()) | 590 if (j_request.is_null() || j_ref.is_null()) |
| 596 return; | 591 return; |
| 597 | 592 |
| 598 Java_AwContents_onPermissionRequestCanceled( | 593 Java_AwContents_onPermissionRequestCanceled(env, j_ref, j_request); |
| 599 env, j_ref.obj(), j_request.obj()); | |
| 600 } | 594 } |
| 601 | 595 |
| 602 void AwContents::PreauthorizePermission(JNIEnv* env, | 596 void AwContents::PreauthorizePermission(JNIEnv* env, |
| 603 const JavaParamRef<jobject>& obj, | 597 const JavaParamRef<jobject>& obj, |
| 604 const JavaParamRef<jstring>& origin, | 598 const JavaParamRef<jstring>& origin, |
| 605 jlong resources) { | 599 jlong resources) { |
| 606 permission_request_handler_->PreauthorizePermission( | 600 permission_request_handler_->PreauthorizePermission( |
| 607 GURL(base::android::ConvertJavaStringToUTF8(env, origin)), resources); | 601 GURL(base::android::ConvertJavaStringToUTF8(env, origin)), resources); |
| 608 } | 602 } |
| 609 | 603 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 622 } | 616 } |
| 623 | 617 |
| 624 void AwContents::RequestGeolocationPermission( | 618 void AwContents::RequestGeolocationPermission( |
| 625 const GURL& origin, | 619 const GURL& origin, |
| 626 const base::Callback<void(bool)>& callback) { | 620 const base::Callback<void(bool)>& callback) { |
| 627 JNIEnv* env = AttachCurrentThread(); | 621 JNIEnv* env = AttachCurrentThread(); |
| 628 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 622 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 629 if (obj.is_null()) | 623 if (obj.is_null()) |
| 630 return; | 624 return; |
| 631 | 625 |
| 632 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env, obj.obj())) { | 626 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env, obj)) { |
| 633 ShowGeolocationPrompt(origin, callback); | 627 ShowGeolocationPrompt(origin, callback); |
| 634 return; | 628 return; |
| 635 } | 629 } |
| 636 permission_request_handler_->SendRequest( | 630 permission_request_handler_->SendRequest( |
| 637 std::unique_ptr<AwPermissionRequestDelegate>(new SimplePermissionRequest( | 631 std::unique_ptr<AwPermissionRequestDelegate>(new SimplePermissionRequest( |
| 638 origin, AwPermissionRequest::Geolocation, callback))); | 632 origin, AwPermissionRequest::Geolocation, callback))); |
| 639 } | 633 } |
| 640 | 634 |
| 641 void AwContents::CancelGeolocationPermissionRequests(const GURL& origin) { | 635 void AwContents::CancelGeolocationPermissionRequests(const GURL& origin) { |
| 642 JNIEnv* env = AttachCurrentThread(); | 636 JNIEnv* env = AttachCurrentThread(); |
| 643 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 637 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 644 if (obj.is_null()) | 638 if (obj.is_null()) |
| 645 return; | 639 return; |
| 646 | 640 |
| 647 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env, obj.obj())) { | 641 if (Java_AwContents_useLegacyGeolocationPermissionAPI(env, obj)) { |
| 648 HideGeolocationPrompt(origin); | 642 HideGeolocationPrompt(origin); |
| 649 return; | 643 return; |
| 650 } | 644 } |
| 651 permission_request_handler_->CancelRequest( | 645 permission_request_handler_->CancelRequest( |
| 652 origin, AwPermissionRequest::Geolocation); | 646 origin, AwPermissionRequest::Geolocation); |
| 653 } | 647 } |
| 654 | 648 |
| 655 void AwContents::RequestMIDISysexPermission( | 649 void AwContents::RequestMIDISysexPermission( |
| 656 const GURL& origin, | 650 const GURL& origin, |
| 657 const base::Callback<void(bool)>& callback) { | 651 const base::Callback<void(bool)>& callback) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 699 |
| 706 void AwContents::OnFindResultReceived(int active_ordinal, | 700 void AwContents::OnFindResultReceived(int active_ordinal, |
| 707 int match_count, | 701 int match_count, |
| 708 bool finished) { | 702 bool finished) { |
| 709 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 703 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 710 JNIEnv* env = AttachCurrentThread(); | 704 JNIEnv* env = AttachCurrentThread(); |
| 711 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 705 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 712 if (obj.is_null()) | 706 if (obj.is_null()) |
| 713 return; | 707 return; |
| 714 | 708 |
| 715 Java_AwContents_onFindResultReceived( | 709 Java_AwContents_onFindResultReceived(env, obj, active_ordinal, match_count, |
| 716 env, obj.obj(), active_ordinal, match_count, finished); | 710 finished); |
| 717 } | 711 } |
| 718 | 712 |
| 719 bool AwContents::ShouldDownloadFavicon(const GURL& icon_url) { | 713 bool AwContents::ShouldDownloadFavicon(const GURL& icon_url) { |
| 720 return g_should_download_favicons; | 714 return g_should_download_favicons; |
| 721 } | 715 } |
| 722 | 716 |
| 723 void AwContents::OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) { | 717 void AwContents::OnReceivedIcon(const GURL& icon_url, const SkBitmap& bitmap) { |
| 724 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 718 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 725 JNIEnv* env = AttachCurrentThread(); | 719 JNIEnv* env = AttachCurrentThread(); |
| 726 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 720 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 727 if (obj.is_null()) | 721 if (obj.is_null()) |
| 728 return; | 722 return; |
| 729 | 723 |
| 730 content::NavigationEntry* entry = | 724 content::NavigationEntry* entry = |
| 731 web_contents_->GetController().GetLastCommittedEntry(); | 725 web_contents_->GetController().GetLastCommittedEntry(); |
| 732 | 726 |
| 733 if (entry) { | 727 if (entry) { |
| 734 entry->GetFavicon().valid = true; | 728 entry->GetFavicon().valid = true; |
| 735 entry->GetFavicon().url = icon_url; | 729 entry->GetFavicon().url = icon_url; |
| 736 entry->GetFavicon().image = gfx::Image::CreateFrom1xBitmap(bitmap); | 730 entry->GetFavicon().image = gfx::Image::CreateFrom1xBitmap(bitmap); |
| 737 } | 731 } |
| 738 | 732 |
| 739 Java_AwContents_onReceivedIcon( | 733 Java_AwContents_onReceivedIcon(env, obj, gfx::ConvertToJavaBitmap(&bitmap)); |
| 740 env, obj.obj(), gfx::ConvertToJavaBitmap(&bitmap).obj()); | |
| 741 } | 734 } |
| 742 | 735 |
| 743 void AwContents::OnReceivedTouchIconUrl(const std::string& url, | 736 void AwContents::OnReceivedTouchIconUrl(const std::string& url, |
| 744 bool precomposed) { | 737 bool precomposed) { |
| 745 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 738 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 746 JNIEnv* env = AttachCurrentThread(); | 739 JNIEnv* env = AttachCurrentThread(); |
| 747 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 740 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 748 if (obj.is_null()) | 741 if (obj.is_null()) |
| 749 return; | 742 return; |
| 750 | 743 |
| 751 Java_AwContents_onReceivedTouchIconUrl( | 744 Java_AwContents_onReceivedTouchIconUrl( |
| 752 env, obj.obj(), ConvertUTF8ToJavaString(env, url).obj(), precomposed); | 745 env, obj, ConvertUTF8ToJavaString(env, url), precomposed); |
| 753 } | 746 } |
| 754 | 747 |
| 755 void AwContents::PostInvalidate() { | 748 void AwContents::PostInvalidate() { |
| 756 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 749 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 757 JNIEnv* env = AttachCurrentThread(); | 750 JNIEnv* env = AttachCurrentThread(); |
| 758 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 751 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 759 if (!obj.is_null()) | 752 if (!obj.is_null()) |
| 760 Java_AwContents_postInvalidateOnAnimation(env, obj.obj()); | 753 Java_AwContents_postInvalidateOnAnimation(env, obj); |
| 761 } | 754 } |
| 762 | 755 |
| 763 void AwContents::OnNewPicture() { | 756 void AwContents::OnNewPicture() { |
| 764 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 757 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 765 JNIEnv* env = AttachCurrentThread(); | 758 JNIEnv* env = AttachCurrentThread(); |
| 766 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 759 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 767 if (!obj.is_null()) { | 760 if (!obj.is_null()) { |
| 768 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( | 761 devtools_instrumentation::ScopedEmbedderCallbackTask embedder_callback( |
| 769 "onNewPicture"); | 762 "onNewPicture"); |
| 770 Java_AwContents_onNewPicture(env, obj.obj()); | 763 Java_AwContents_onNewPicture(env, obj); |
| 771 } | 764 } |
| 772 } | 765 } |
| 773 | 766 |
| 774 base::android::ScopedJavaLocalRef<jbyteArray> AwContents::GetCertificate( | 767 base::android::ScopedJavaLocalRef<jbyteArray> AwContents::GetCertificate( |
| 775 JNIEnv* env, | 768 JNIEnv* env, |
| 776 const JavaParamRef<jobject>& obj) { | 769 const JavaParamRef<jobject>& obj) { |
| 777 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 770 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 778 content::NavigationEntry* entry = | 771 content::NavigationEntry* entry = |
| 779 web_contents_->GetController().GetLastCommittedEntry(); | 772 web_contents_->GetController().GetLastCommittedEntry(); |
| 780 if (!entry) | 773 if (!entry) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 href = ConvertUTF16ToJavaString(env, data.href); | 817 href = ConvertUTF16ToJavaString(env, data.href); |
| 825 | 818 |
| 826 ScopedJavaLocalRef<jstring> anchor_text; | 819 ScopedJavaLocalRef<jstring> anchor_text; |
| 827 if (data.anchor_text.length()) | 820 if (data.anchor_text.length()) |
| 828 anchor_text = ConvertUTF16ToJavaString(env, data.anchor_text); | 821 anchor_text = ConvertUTF16ToJavaString(env, data.anchor_text); |
| 829 | 822 |
| 830 ScopedJavaLocalRef<jstring> img_src; | 823 ScopedJavaLocalRef<jstring> img_src; |
| 831 if (data.img_src.is_valid()) | 824 if (data.img_src.is_valid()) |
| 832 img_src = ConvertUTF8ToJavaString(env, data.img_src.spec()); | 825 img_src = ConvertUTF8ToJavaString(env, data.img_src.spec()); |
| 833 | 826 |
| 834 Java_AwContents_updateHitTestData(env, | 827 Java_AwContents_updateHitTestData(env, obj, data.type, extra_data_for_type, |
| 835 obj, | 828 href, anchor_text, img_src); |
| 836 data.type, | |
| 837 extra_data_for_type.obj(), | |
| 838 href.obj(), | |
| 839 anchor_text.obj(), | |
| 840 img_src.obj()); | |
| 841 } | 829 } |
| 842 | 830 |
| 843 void AwContents::OnSizeChanged(JNIEnv* env, | 831 void AwContents::OnSizeChanged(JNIEnv* env, |
| 844 const JavaParamRef<jobject>& obj, | 832 const JavaParamRef<jobject>& obj, |
| 845 int w, | 833 int w, |
| 846 int h, | 834 int h, |
| 847 int ow, | 835 int ow, |
| 848 int oh) { | 836 int oh) { |
| 849 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 837 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 850 browser_view_renderer_.OnSizeChanged(w, h); | 838 browser_view_renderer_.OnSizeChanged(w, h); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 } | 1012 } |
| 1025 | 1013 |
| 1026 gfx::Point AwContents::GetLocationOnScreen() { | 1014 gfx::Point AwContents::GetLocationOnScreen() { |
| 1027 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1015 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1028 JNIEnv* env = AttachCurrentThread(); | 1016 JNIEnv* env = AttachCurrentThread(); |
| 1029 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1017 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1030 if (obj.is_null()) | 1018 if (obj.is_null()) |
| 1031 return gfx::Point(); | 1019 return gfx::Point(); |
| 1032 std::vector<int> location; | 1020 std::vector<int> location; |
| 1033 base::android::JavaIntArrayToIntVector( | 1021 base::android::JavaIntArrayToIntVector( |
| 1034 env, | 1022 env, Java_AwContents_getLocationOnScreen(env, obj).obj(), &location); |
| 1035 Java_AwContents_getLocationOnScreen(env, obj.obj()).obj(), | |
| 1036 &location); | |
| 1037 return gfx::Point(location[0], location[1]); | 1023 return gfx::Point(location[0], location[1]); |
| 1038 } | 1024 } |
| 1039 | 1025 |
| 1040 void AwContents::ScrollContainerViewTo(const gfx::Vector2d& new_value) { | 1026 void AwContents::ScrollContainerViewTo(const gfx::Vector2d& new_value) { |
| 1041 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1027 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1042 JNIEnv* env = AttachCurrentThread(); | 1028 JNIEnv* env = AttachCurrentThread(); |
| 1043 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1029 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1044 if (obj.is_null()) | 1030 if (obj.is_null()) |
| 1045 return; | 1031 return; |
| 1046 Java_AwContents_scrollContainerViewTo( | 1032 Java_AwContents_scrollContainerViewTo(env, obj, new_value.x(), new_value.y()); |
| 1047 env, obj.obj(), new_value.x(), new_value.y()); | |
| 1048 } | 1033 } |
| 1049 | 1034 |
| 1050 void AwContents::UpdateScrollState(const gfx::Vector2d& max_scroll_offset, | 1035 void AwContents::UpdateScrollState(const gfx::Vector2d& max_scroll_offset, |
| 1051 const gfx::SizeF& contents_size_dip, | 1036 const gfx::SizeF& contents_size_dip, |
| 1052 float page_scale_factor, | 1037 float page_scale_factor, |
| 1053 float min_page_scale_factor, | 1038 float min_page_scale_factor, |
| 1054 float max_page_scale_factor) { | 1039 float max_page_scale_factor) { |
| 1055 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1040 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1056 JNIEnv* env = AttachCurrentThread(); | 1041 JNIEnv* env = AttachCurrentThread(); |
| 1057 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1042 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1058 if (obj.is_null()) | 1043 if (obj.is_null()) |
| 1059 return; | 1044 return; |
| 1060 Java_AwContents_updateScrollState(env, | 1045 Java_AwContents_updateScrollState( |
| 1061 obj.obj(), | 1046 env, obj, max_scroll_offset.x(), max_scroll_offset.y(), |
| 1062 max_scroll_offset.x(), | 1047 contents_size_dip.width(), contents_size_dip.height(), page_scale_factor, |
| 1063 max_scroll_offset.y(), | 1048 min_page_scale_factor, max_page_scale_factor); |
| 1064 contents_size_dip.width(), | |
| 1065 contents_size_dip.height(), | |
| 1066 page_scale_factor, | |
| 1067 min_page_scale_factor, | |
| 1068 max_page_scale_factor); | |
| 1069 } | 1049 } |
| 1070 | 1050 |
| 1071 void AwContents::DidOverscroll(const gfx::Vector2d& overscroll_delta, | 1051 void AwContents::DidOverscroll(const gfx::Vector2d& overscroll_delta, |
| 1072 const gfx::Vector2dF& overscroll_velocity) { | 1052 const gfx::Vector2dF& overscroll_velocity) { |
| 1073 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1053 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1074 JNIEnv* env = AttachCurrentThread(); | 1054 JNIEnv* env = AttachCurrentThread(); |
| 1075 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1055 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1076 if (obj.is_null()) | 1056 if (obj.is_null()) |
| 1077 return; | 1057 return; |
| 1078 Java_AwContents_didOverscroll(env, obj.obj(), overscroll_delta.x(), | 1058 Java_AwContents_didOverscroll(env, obj, overscroll_delta.x(), |
| 1079 overscroll_delta.y(), overscroll_velocity.x(), | 1059 overscroll_delta.y(), overscroll_velocity.x(), |
| 1080 overscroll_velocity.y()); | 1060 overscroll_velocity.y()); |
| 1081 } | 1061 } |
| 1082 | 1062 |
| 1083 void AwContents::SetDipScale(JNIEnv* env, | 1063 void AwContents::SetDipScale(JNIEnv* env, |
| 1084 const JavaParamRef<jobject>& obj, | 1064 const JavaParamRef<jobject>& obj, |
| 1085 jfloat dip_scale) { | 1065 jfloat dip_scale) { |
| 1086 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1066 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1087 SetDipScaleInternal(dip_scale); | 1067 SetDipScaleInternal(dip_scale); |
| 1088 } | 1068 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1111 render_view_host_ext_->SmoothScroll(target_x / scale, target_y / scale, | 1091 render_view_host_ext_->SmoothScroll(target_x / scale, target_y / scale, |
| 1112 duration_ms); | 1092 duration_ms); |
| 1113 } | 1093 } |
| 1114 | 1094 |
| 1115 void AwContents::OnWebLayoutPageScaleFactorChanged(float page_scale_factor) { | 1095 void AwContents::OnWebLayoutPageScaleFactorChanged(float page_scale_factor) { |
| 1116 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1096 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1117 JNIEnv* env = AttachCurrentThread(); | 1097 JNIEnv* env = AttachCurrentThread(); |
| 1118 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1098 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1119 if (obj.is_null()) | 1099 if (obj.is_null()) |
| 1120 return; | 1100 return; |
| 1121 Java_AwContents_onWebLayoutPageScaleFactorChanged(env, obj.obj(), | 1101 Java_AwContents_onWebLayoutPageScaleFactorChanged(env, obj, |
| 1122 page_scale_factor); | 1102 page_scale_factor); |
| 1123 } | 1103 } |
| 1124 | 1104 |
| 1125 void AwContents::OnWebLayoutContentsSizeChanged( | 1105 void AwContents::OnWebLayoutContentsSizeChanged( |
| 1126 const gfx::Size& contents_size) { | 1106 const gfx::Size& contents_size) { |
| 1127 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1107 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1128 JNIEnv* env = AttachCurrentThread(); | 1108 JNIEnv* env = AttachCurrentThread(); |
| 1129 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1109 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 1130 if (obj.is_null()) | 1110 if (obj.is_null()) |
| 1131 return; | 1111 return; |
| 1132 Java_AwContents_onWebLayoutContentsSizeChanged( | 1112 Java_AwContents_onWebLayoutContentsSizeChanged( |
| 1133 env, obj.obj(), contents_size.width(), contents_size.height()); | 1113 env, obj, contents_size.width(), contents_size.height()); |
| 1134 } | 1114 } |
| 1135 | 1115 |
| 1136 jlong AwContents::CapturePicture(JNIEnv* env, | 1116 jlong AwContents::CapturePicture(JNIEnv* env, |
| 1137 const JavaParamRef<jobject>& obj, | 1117 const JavaParamRef<jobject>& obj, |
| 1138 int width, | 1118 int width, |
| 1139 int height) { | 1119 int height) { |
| 1140 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1120 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1141 return reinterpret_cast<intptr_t>( | 1121 return reinterpret_cast<intptr_t>( |
| 1142 new AwPicture(browser_view_renderer_.CapturePicture(width, height))); | 1122 new AwPicture(browser_view_renderer_.CapturePicture(width, height))); |
| 1143 } | 1123 } |
| 1144 | 1124 |
| 1145 void AwContents::EnableOnNewPicture(JNIEnv* env, | 1125 void AwContents::EnableOnNewPicture(JNIEnv* env, |
| 1146 const JavaParamRef<jobject>& obj, | 1126 const JavaParamRef<jobject>& obj, |
| 1147 jboolean enabled) { | 1127 jboolean enabled) { |
| 1148 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1128 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1149 browser_view_renderer_.EnableOnNewPicture(enabled); | 1129 browser_view_renderer_.EnableOnNewPicture(enabled); |
| 1150 } | 1130 } |
| 1151 | 1131 |
| 1152 namespace { | 1132 namespace { |
| 1153 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref, | 1133 void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref, |
| 1154 jlong request_id, | 1134 jlong request_id, |
| 1155 ScopedJavaGlobalRef<jobject>* callback, | 1135 ScopedJavaGlobalRef<jobject>* callback, |
| 1156 bool result) { | 1136 bool result) { |
| 1157 JNIEnv* env = AttachCurrentThread(); | 1137 JNIEnv* env = AttachCurrentThread(); |
| 1158 ScopedJavaLocalRef<jobject> obj = java_ref.get(env); | 1138 ScopedJavaLocalRef<jobject> obj = java_ref.get(env); |
| 1159 if (obj.is_null()) | 1139 if (obj.is_null()) |
| 1160 return; | 1140 return; |
| 1161 Java_AwContents_invokeVisualStateCallback( | 1141 Java_AwContents_invokeVisualStateCallback(env, obj, callback->obj(), |
| 1162 env, obj.obj(), callback->obj(), request_id); | 1142 request_id); |
| 1163 } | 1143 } |
| 1164 } // namespace | 1144 } // namespace |
| 1165 | 1145 |
| 1166 void AwContents::InsertVisualStateCallback( | 1146 void AwContents::InsertVisualStateCallback( |
| 1167 JNIEnv* env, | 1147 JNIEnv* env, |
| 1168 const JavaParamRef<jobject>& obj, | 1148 const JavaParamRef<jobject>& obj, |
| 1169 jlong request_id, | 1149 jlong request_id, |
| 1170 const JavaParamRef<jobject>& callback) { | 1150 const JavaParamRef<jobject>& callback) { |
| 1171 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1151 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1172 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); | 1152 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 int routing_id = new_host->GetRoutingID(); | 1285 int routing_id = new_host->GetRoutingID(); |
| 1306 // At this point, the current RVH may or may not contain a compositor. So | 1286 // At this point, the current RVH may or may not contain a compositor. So |
| 1307 // compositor_ may be nullptr, in which case | 1287 // compositor_ may be nullptr, in which case |
| 1308 // BrowserViewRenderer::DidInitializeCompositor() callback is time when the | 1288 // BrowserViewRenderer::DidInitializeCompositor() callback is time when the |
| 1309 // new compositor is constructed. | 1289 // new compositor is constructed. |
| 1310 browser_view_renderer_.SetActiveCompositorID( | 1290 browser_view_renderer_.SetActiveCompositorID( |
| 1311 CompositorID(process_id, routing_id)); | 1291 CompositorID(process_id, routing_id)); |
| 1312 } | 1292 } |
| 1313 | 1293 |
| 1314 } // namespace android_webview | 1294 } // namespace android_webview |
| OLD | NEW |