OLD | NEW |
---|---|
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 "chrome/browser/component/web_contents_delegate_android/web_contents_de legate_android.h" | 5 #include "content/components/web_contents_delegate_android/web_contents_delegate _android.h" |
6 | 6 |
7 #include <android/keycodes.h> | 7 #include <android/keycodes.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
11 #include "content/public/browser/android/content_view_core.h" | 11 #include "content/public/browser/android/content_view_core.h" |
12 #include "content/public/browser/render_widget_host_view.h" | 12 #include "content/public/browser/render_widget_host_view.h" |
13 #include "content/public/browser/invalidate_type.h" | 13 #include "content/public/browser/invalidate_type.h" |
14 #include "content/public/browser/page_navigator.h" | 14 #include "content/public/browser/page_navigator.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/page_transition_types.h" | 18 #include "content/public/common/page_transition_types.h" |
19 #include "content/public/common/referrer.h" | 19 #include "content/public/common/referrer.h" |
20 #include "jni/WebContentsDelegateAndroid_jni.h" | 20 #include "jni/WebContentsDelegateAndroid_jni.h" |
21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
22 #include "webkit/glue/window_open_disposition.h" | 22 #include "webkit/glue/window_open_disposition.h" |
23 | 23 |
24 using base::android::AttachCurrentThread; | 24 using base::android::AttachCurrentThread; |
25 using base::android::ConvertUTF8ToJavaString; | 25 using base::android::ConvertUTF8ToJavaString; |
26 using base::android::ConvertUTF16ToJavaString; | 26 using base::android::ConvertUTF16ToJavaString; |
27 using base::android::HasClass; | 27 using base::android::HasClass; |
28 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
29 using content::WebContents; | |
30 | 29 |
31 namespace web_contents_delegate_android { | 30 namespace content { |
32 | 31 |
33 WebContentsDelegateAndroid::WebContentsDelegateAndroid(JNIEnv* env, jobject obj) | 32 WebContentsDelegateAndroid::WebContentsDelegateAndroid(JNIEnv* env, jobject obj) |
34 : weak_java_delegate_(env, obj) { | 33 : weak_java_delegate_(env, obj) { |
35 } | 34 } |
36 | 35 |
37 WebContentsDelegateAndroid::~WebContentsDelegateAndroid() { | 36 WebContentsDelegateAndroid::~WebContentsDelegateAndroid() { |
38 } | 37 } |
39 | 38 |
40 ScopedJavaLocalRef<jobject> | 39 ScopedJavaLocalRef<jobject> |
41 WebContentsDelegateAndroid::GetJavaDelegate(JNIEnv* env) const { | 40 WebContentsDelegateAndroid::GetJavaDelegate(JNIEnv* env) const { |
42 return weak_java_delegate_.get(env); | 41 return weak_java_delegate_.get(env); |
43 } | 42 } |
44 | 43 |
45 // ---------------------------------------------------------------------------- | 44 // ---------------------------------------------------------------------------- |
46 // WebContentsDelegate methods | 45 // WebContentsDelegate methods |
47 // ---------------------------------------------------------------------------- | 46 // ---------------------------------------------------------------------------- |
48 | 47 |
49 // OpenURLFromTab() will be called when we're performing a browser-intiated | 48 // OpenURLFromTab() will be called when we're performing a browser-intiated |
50 // navigation. The most common scenario for this is opening new tabs (see | 49 // navigation. The most common scenario for this is opening new tabs (see |
51 // RenderViewImpl::decidePolicyForNavigation for more details). | 50 // RenderViewImpl::decidePolicyForNavigation for more details). |
52 WebContents* WebContentsDelegateAndroid::OpenURLFromTab( | 51 WebContents* WebContentsDelegateAndroid::OpenURLFromTab( |
53 WebContents* source, | 52 WebContents* source, |
54 const content::OpenURLParams& params) { | 53 const content::OpenURLParams& params) { |
jam
2012/11/12 17:24:40
ditto
John Knottenbelt
2012/11/12 18:07:46
Done.
| |
55 const GURL& url = params.url; | 54 const GURL& url = params.url; |
56 WindowOpenDisposition disposition = params.disposition; | 55 WindowOpenDisposition disposition = params.disposition; |
57 content::PageTransition transition( | 56 content::PageTransition transition( |
58 PageTransitionFromInt(params.transition)); | 57 PageTransitionFromInt(params.transition)); |
59 | 58 |
60 if (!source || (disposition != CURRENT_TAB && | 59 if (!source || (disposition != CURRENT_TAB && |
61 disposition != NEW_FOREGROUND_TAB && | 60 disposition != NEW_FOREGROUND_TAB && |
62 disposition != NEW_BACKGROUND_TAB && | 61 disposition != NEW_BACKGROUND_TAB && |
63 disposition != OFF_THE_RECORD)) { | 62 disposition != OFF_THE_RECORD)) { |
64 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 // Register native methods | 286 // Register native methods |
288 | 287 |
289 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 288 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
290 if (!HasClass(env, kWebContentsDelegateAndroidClassPath)) { | 289 if (!HasClass(env, kWebContentsDelegateAndroidClassPath)) { |
291 DLOG(ERROR) << "Unable to find class WebContentsDelegateAndroid!"; | 290 DLOG(ERROR) << "Unable to find class WebContentsDelegateAndroid!"; |
292 return false; | 291 return false; |
293 } | 292 } |
294 return RegisterNativesImpl(env); | 293 return RegisterNativesImpl(env); |
295 } | 294 } |
296 | 295 |
297 } // namespace web_contents_delegate_android | 296 } // namespace content |
OLD | NEW |