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 "components/web_contents_delegate_android/web_contents_delegate_android .h" | 5 #include "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_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "components/web_contents_delegate_android/color_chooser_android.h" | 12 #include "components/web_contents_delegate_android/color_chooser_android.h" |
13 #include "components/web_contents_delegate_android/validation_message_bubble_and roid.h" | 13 #include "components/web_contents_delegate_android/validation_message_bubble_and roid.h" |
14 #include "content/public/browser/android/content_view_core.h" | 14 #include "content/public/browser/android/content_view_core.h" |
15 #include "content/public/browser/color_chooser.h" | 15 #include "content/public/browser/color_chooser.h" |
16 #include "content/public/browser/global_request_id.h" | |
16 #include "content/public/browser/invalidate_type.h" | 17 #include "content/public/browser/invalidate_type.h" |
17 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
19 #include "content/public/browser/navigation_controller.h" | |
18 #include "content/public/browser/page_navigator.h" | 20 #include "content/public/browser/page_navigator.h" |
19 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
20 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
21 #include "content/public/common/page_transition_types.h" | 23 #include "content/public/common/page_transition_types.h" |
22 #include "content/public/common/referrer.h" | 24 #include "content/public/common/referrer.h" |
23 #include "jni/WebContentsDelegateAndroid_jni.h" | 25 #include "jni/WebContentsDelegateAndroid_jni.h" |
24 #include "ui/base/window_open_disposition.h" | 26 #include "ui/base/window_open_disposition.h" |
25 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
26 #include "url/gurl.h" | 28 #include "url/gurl.h" |
27 | 29 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 } | 62 } |
61 | 63 |
62 // OpenURLFromTab() will be called when we're performing a browser-intiated | 64 // OpenURLFromTab() will be called when we're performing a browser-intiated |
63 // navigation. The most common scenario for this is opening new tabs (see | 65 // navigation. The most common scenario for this is opening new tabs (see |
64 // RenderViewImpl::decidePolicyForNavigation for more details). | 66 // RenderViewImpl::decidePolicyForNavigation for more details). |
65 WebContents* WebContentsDelegateAndroid::OpenURLFromTab( | 67 WebContents* WebContentsDelegateAndroid::OpenURLFromTab( |
66 WebContents* source, | 68 WebContents* source, |
67 const content::OpenURLParams& params) { | 69 const content::OpenURLParams& params) { |
68 const GURL& url = params.url; | 70 const GURL& url = params.url; |
69 WindowOpenDisposition disposition = params.disposition; | 71 WindowOpenDisposition disposition = params.disposition; |
70 content::PageTransition transition( | |
71 PageTransitionFromInt(params.transition)); | |
72 | 72 |
73 if (!source || (disposition != CURRENT_TAB && | 73 if (!source || (disposition != CURRENT_TAB && |
74 disposition != NEW_FOREGROUND_TAB && | 74 disposition != NEW_FOREGROUND_TAB && |
75 disposition != NEW_BACKGROUND_TAB && | 75 disposition != NEW_BACKGROUND_TAB && |
76 disposition != OFF_THE_RECORD)) { | 76 disposition != OFF_THE_RECORD)) { |
77 NOTIMPLEMENTED(); | 77 NOTIMPLEMENTED(); |
78 return NULL; | 78 return NULL; |
79 } | 79 } |
80 | 80 |
81 JNIEnv* env = AttachCurrentThread(); | 81 JNIEnv* env = AttachCurrentThread(); |
(...skipping 20 matching lines...) Expand all Loading... | |
102 } | 102 } |
103 Java_WebContentsDelegateAndroid_openNewTab(env, | 103 Java_WebContentsDelegateAndroid_openNewTab(env, |
104 obj.obj(), | 104 obj.obj(), |
105 java_url.obj(), | 105 java_url.obj(), |
106 extra_headers.obj(), | 106 extra_headers.obj(), |
107 post_data.obj(), | 107 post_data.obj(), |
108 disposition); | 108 disposition); |
109 return NULL; | 109 return NULL; |
110 } | 110 } |
111 | 111 |
112 source->GetController().LoadURL(url, params.referrer, transition, | 112 content::NavigationController::LoadURLParams load_params(url); |
113 std::string()); | 113 load_params.referrer = params.referrer; |
114 load_params.frame_tree_node_id = params.frame_tree_node_id; | |
115 load_params.redirect_chain = params.redirect_chain; | |
116 load_params.transition_type = params.transition; | |
117 load_params.extra_headers = params.extra_headers; | |
118 load_params.should_replace_current_entry = | |
119 params.should_replace_current_entry; | |
120 load_params.is_renderer_initiated = params.is_renderer_initiated; | |
121 | |
122 if (params.transferred_global_request_id != content::GlobalRequestID()) { | |
123 load_params.transferred_global_request_id = | |
124 params.transferred_global_request_id; | |
125 } | |
126 | |
127 // Only allows the browser-initiated navigation to use POST. | |
128 if (params.uses_post && !params.is_renderer_initiated) { | |
129 load_params.load_type = | |
130 content::NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; | |
131 load_params.browser_initiated_post_data = | |
132 params.browser_initiated_post_data; | |
133 } | |
134 | |
135 source->GetController().LoadURLWithParams(load_params); | |
Charlie Reis
2014/05/07 22:08:12
I'm guessing this is just a misnomer, but LoadURLI
David Trainor- moved to gerrit
2014/05/07 22:43:54
I can change it but I think we can only reach this
Charlie Reis
2014/05/07 23:16:24
Hmm, that's a good point: we don't use any of this
David Trainor- moved to gerrit
2014/05/12 20:52:45
Yeah I'm looking into fixing that as well. It req
| |
136 | |
114 return source; | 137 return source; |
115 } | 138 } |
116 | 139 |
117 void WebContentsDelegateAndroid::NavigationStateChanged( | 140 void WebContentsDelegateAndroid::NavigationStateChanged( |
118 const WebContents* source, unsigned changed_flags) { | 141 const WebContents* source, unsigned changed_flags) { |
119 JNIEnv* env = AttachCurrentThread(); | 142 JNIEnv* env = AttachCurrentThread(); |
120 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 143 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
121 if (obj.is_null()) | 144 if (obj.is_null()) |
122 return; | 145 return; |
123 Java_WebContentsDelegateAndroid_navigationStateChanged( | 146 Java_WebContentsDelegateAndroid_navigationStateChanged( |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 // Native JNI methods | 371 // Native JNI methods |
349 // ---------------------------------------------------------------------------- | 372 // ---------------------------------------------------------------------------- |
350 | 373 |
351 // Register native methods | 374 // Register native methods |
352 | 375 |
353 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { | 376 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { |
354 return RegisterNativesImpl(env); | 377 return RegisterNativesImpl(env); |
355 } | 378 } |
356 | 379 |
357 } // namespace web_contents_delegate_android | 380 } // namespace web_contents_delegate_android |
OLD | NEW |