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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 10916160: Upstreaming SelectFileDialog for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Elliot's nits Created 8 years, 3 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/common/content_client.h" 30 #include "content/public/common/content_client.h"
31 #include "content/public/common/page_transition_types.h" 31 #include "content/public/common/page_transition_types.h"
32 #include "jni/ContentViewCore_jni.h" 32 #include "jni/ContentViewCore_jni.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent Factory.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent Factory.h"
36 #include "ui/gfx/android/java_bitmap.h" 36 #include "ui/gfx/android/java_bitmap.h"
37 #include "ui/gfx/android/window_android.h"
37 #include "webkit/glue/webmenuitem.h" 38 #include "webkit/glue/webmenuitem.h"
38 #include "webkit/user_agent/user_agent_util.h" 39 #include "webkit/user_agent/user_agent_util.h"
39 40
40 using base::android::AttachCurrentThread; 41 using base::android::AttachCurrentThread;
41 using base::android::ConvertJavaStringToUTF16; 42 using base::android::ConvertJavaStringToUTF16;
42 using base::android::ConvertJavaStringToUTF8; 43 using base::android::ConvertJavaStringToUTF8;
43 using base::android::ConvertUTF16ToJavaString; 44 using base::android::ConvertUTF16ToJavaString;
44 using base::android::ConvertUTF8ToJavaString; 45 using base::android::ConvertUTF8ToJavaString;
45 using base::android::GetClass; 46 using base::android::GetClass;
46 using base::android::HasField; 47 using base::android::HasField;
(...skipping 24 matching lines...) Expand all
71 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, 72 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env,
72 jobject obj) { 73 jobject obj) {
73 return reinterpret_cast<ContentViewCore*>( 74 return reinterpret_cast<ContentViewCore*>(
74 env->GetIntField(obj, g_native_content_view)); 75 env->GetIntField(obj, g_native_content_view));
75 } 76 }
76 77
77 78
78 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, 79 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj,
79 bool hardware_accelerated, 80 bool hardware_accelerated,
80 bool take_ownership_of_web_contents, 81 bool take_ownership_of_web_contents,
81 WebContents* web_contents) 82 WebContents* web_contents,
83 WindowAndroid* window_android)
82 : java_ref_(env, obj), 84 : java_ref_(env, obj),
83 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 85 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
84 owns_web_contents_(take_ownership_of_web_contents), 86 owns_web_contents_(take_ownership_of_web_contents),
85 tab_crashed_(false) { 87 tab_crashed_(false),
88 window_android_(window_android) {
86 DCHECK(web_contents) << 89 DCHECK(web_contents) <<
87 "A ContentViewCoreImpl should be created with a valid WebContents."; 90 "A ContentViewCoreImpl should be created with a valid WebContents.";
88 91
89 // TODO(leandrogracia): make use of the hardware_accelerated argument. 92 // TODO(leandrogracia): make use of the hardware_accelerated argument.
90 93
91 InitJNI(env, obj); 94 InitJNI(env, obj);
92 95
93 notification_registrar_.Add(this, 96 notification_registrar_.Add(this,
94 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 97 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
95 NotificationService::AllSources()); 98 NotificationService::AllSources());
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // -------------------------------------------------------------------------- 519 // --------------------------------------------------------------------------
517 // Methods called from native code 520 // Methods called from native code
518 // -------------------------------------------------------------------------- 521 // --------------------------------------------------------------------------
519 522
520 void ContentViewCoreImpl::LoadUrl( 523 void ContentViewCoreImpl::LoadUrl(
521 NavigationController::LoadURLParams& params) { 524 NavigationController::LoadURLParams& params) {
522 web_contents()->GetController().LoadURLWithParams(params); 525 web_contents()->GetController().LoadURLWithParams(params);
523 PostLoadUrl(params.url); 526 PostLoadUrl(params.url);
524 } 527 }
525 528
529 WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() {
530 return window_android_;
531 }
532
526 void ContentViewCoreImpl::PostLoadUrl(const GURL& url) { 533 void ContentViewCoreImpl::PostLoadUrl(const GURL& url) {
527 tab_crashed_ = false; 534 tab_crashed_ = false;
528 // TODO(tedchoc): Update the content view client of the page load request. 535 // TODO(tedchoc): Update the content view client of the page load request.
529 } 536 }
530 537
531 // ---------------------------------------------------------------------------- 538 // ----------------------------------------------------------------------------
532 // Native JNI methods 539 // Native JNI methods
533 // ---------------------------------------------------------------------------- 540 // ----------------------------------------------------------------------------
534 541
535 // This is called for each ContentViewCore. 542 // This is called for each ContentViewCore.
536 jint Init(JNIEnv* env, jobject obj, 543 jint Init(JNIEnv* env, jobject obj,
537 jboolean hardware_accelerated, 544 jboolean hardware_accelerated,
538 jboolean take_ownership_of_web_contents, 545 jboolean take_ownership_of_web_contents,
539 jint native_web_contents) { 546 jint native_web_contents,
547 jint native_window) {
540 ContentViewCoreImpl* view = new ContentViewCoreImpl( 548 ContentViewCoreImpl* view = new ContentViewCoreImpl(
541 env, obj, hardware_accelerated, take_ownership_of_web_contents, 549 env, obj, hardware_accelerated, take_ownership_of_web_contents,
542 reinterpret_cast<WebContents*>(native_web_contents)); 550 reinterpret_cast<WebContents*>(native_web_contents),
551 reinterpret_cast<WindowAndroid*>(native_window));
543 return reinterpret_cast<jint>(view); 552 return reinterpret_cast<jint>(view);
544 } 553 }
545 554
546 jint EvaluateJavaScript(JNIEnv* env, jobject obj, jstring script) { 555 jint EvaluateJavaScript(JNIEnv* env, jobject obj, jstring script) {
547 ContentViewCoreImpl* view = static_cast<ContentViewCoreImpl*> 556 ContentViewCoreImpl* view = static_cast<ContentViewCoreImpl*>
548 (ContentViewCore::GetNativeContentViewCore(env, obj)); 557 (ContentViewCore::GetNativeContentViewCore(env, obj));
549 558
550 return view->EvaluateJavaScript(env, obj, script); 559 return view->EvaluateJavaScript(env, obj, script);
551 } 560 }
552 561
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { 717 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) {
709 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; 718 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!";
710 return false; 719 return false;
711 } 720 }
712 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); 721 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I");
713 722
714 return RegisterNativesImpl(env) >= 0; 723 return RegisterNativesImpl(env) >= 0;
715 } 724 }
716 725
717 } // namespace content 726 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698