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

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

Issue 10963041: Revert "Revert 158067 - Remove native side of content_view_client" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add additional_input_paths as a variable and input to java.gypi 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
« no previous file with comments | « content/browser/android/web_contents_observer_android.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/web_contents_observer_android.h" 5 #include "content/browser/android/web_contents_observer_android.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include <jni.h> 9 #include <jni.h>
10 10
(...skipping 17 matching lines...) Expand all
28 JNIEnv* env, 28 JNIEnv* env,
29 jobject obj, 29 jobject obj,
30 WebContents* web_contents) 30 WebContents* web_contents)
31 : WebContentsObserver(web_contents), 31 : WebContentsObserver(web_contents),
32 weak_java_observer_(env, obj){ 32 weak_java_observer_(env, obj){
33 } 33 }
34 34
35 WebContentsObserverAndroid::~WebContentsObserverAndroid() { 35 WebContentsObserverAndroid::~WebContentsObserverAndroid() {
36 } 36 }
37 37
38 jint Init(JNIEnv* env, jobject obj, jint native_web_contents) { 38 jint Init(JNIEnv* env, jobject obj, jint native_content_view_core) {
39 WebContents* web_contents = 39 ContentViewCore* content_view_core =
40 reinterpret_cast<WebContents*>(native_web_contents); 40 reinterpret_cast<ContentViewCore*>(native_content_view_core);
41 WebContentsObserverAndroid* native_observer = new WebContentsObserverAndroid( 41 WebContentsObserverAndroid* native_observer = new WebContentsObserverAndroid(
42 env, obj, web_contents); 42 env, obj, content_view_core->GetWebContents());
43 return reinterpret_cast<jint>(native_observer); 43 return reinterpret_cast<jint>(native_observer);
44 } 44 }
45 45
46 void WebContentsObserverAndroid::Destroy(JNIEnv* env, jobject obj) { 46 void WebContentsObserverAndroid::Destroy(JNIEnv* env, jobject obj) {
47 delete this; 47 delete this;
48 } 48 }
49 49
50 void WebContentsObserverAndroid::WebContentsDestroyed( 50 void WebContentsObserverAndroid::WebContentsDestroyed(
51 WebContents* web_contents) { 51 WebContents* web_contents) {
52 JNIEnv* env = AttachCurrentThread(); 52 JNIEnv* env = AttachCurrentThread();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 int64 frame_id, 98 int64 frame_id,
99 const GURL& validated_url, 99 const GURL& validated_url,
100 bool is_main_frame, 100 bool is_main_frame,
101 int error_code, 101 int error_code,
102 const string16& error_description, 102 const string16& error_description,
103 RenderViewHost* render_view_host) { 103 RenderViewHost* render_view_host) {
104 DidFailLoadInternal( 104 DidFailLoadInternal(
105 false, is_main_frame, error_code, error_description, validated_url); 105 false, is_main_frame, error_code, error_description, validated_url);
106 } 106 }
107 107
108 void WebContentsObserverAndroid::DidNavigateMainFrame(
109 const LoadCommittedDetails& details,
110 const FrameNavigateParams& params) {
111 JNIEnv* env = AttachCurrentThread();
112 ScopedJavaLocalRef<jobject> obj = weak_java_observer_.get(env);
113 if (obj.is_null())
114 return;
115 ScopedJavaLocalRef<jstring> jstring_url =
116 ConvertUTF8ToJavaString(env, params.url.spec());
117 ScopedJavaLocalRef<jstring> jstring_base_url =
118 ConvertUTF8ToJavaString(env, params.base_url.spec());
119 Java_WebContentsObserverAndroid_didNavigateMainFrame(
120 env, obj.obj(), jstring_url.obj(), jstring_base_url.obj());
121 }
122
108 void WebContentsObserverAndroid::DidFailLoadInternal( 123 void WebContentsObserverAndroid::DidFailLoadInternal(
109 bool is_provisional_load, 124 bool is_provisional_load,
110 bool is_main_frame, 125 bool is_main_frame,
111 int error_code, 126 int error_code,
112 const string16& description, 127 const string16& description,
113 const GURL& url) { 128 const GURL& url) {
114 JNIEnv* env = AttachCurrentThread(); 129 JNIEnv* env = AttachCurrentThread();
115 ScopedJavaLocalRef<jobject> obj = weak_java_observer_.get(env); 130 ScopedJavaLocalRef<jobject> obj = weak_java_observer_.get(env);
116 if (obj.is_null()) 131 if (obj.is_null())
117 return; 132 return;
(...skipping 11 matching lines...) Expand all
129 } 144 }
130 145
131 bool RegisterWebContentsObserverAndroid(JNIEnv* env) { 146 bool RegisterWebContentsObserverAndroid(JNIEnv* env) {
132 if (!HasClass(env, kWebContentsObserverAndroidClassPath)) { 147 if (!HasClass(env, kWebContentsObserverAndroidClassPath)) {
133 DLOG(ERROR) << "Unable to find class WebContentsObserverAndroid!"; 148 DLOG(ERROR) << "Unable to find class WebContentsObserverAndroid!";
134 return false; 149 return false;
135 } 150 }
136 return RegisterNativesImpl(env); 151 return RegisterNativesImpl(env);
137 } 152 }
138 } // namespace content 153 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/web_contents_observer_android.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698