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/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" | 11 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
12 #include "chrome/browser/browser_about_handler.h" | 12 #include "chrome/browser/browser_about_handler.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
15 #include "chrome/browser/google/google_url_tracker_factory.h" | 15 #include "chrome/browser/google/google_url_tracker_factory.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/prerender/prerender_contents.h" | 17 #include "chrome/browser/prerender/prerender_contents.h" |
18 #include "chrome/browser/prerender/prerender_manager.h" | 18 #include "chrome/browser/prerender/prerender_manager.h" |
19 #include "chrome/browser/prerender/prerender_manager_factory.h" | 19 #include "chrome/browser/prerender/prerender_manager_factory.h" |
20 #include "chrome/browser/printing/print_view_manager_basic.h" | 20 #include "chrome/browser/printing/print_view_manager_basic.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_android.h" | 22 #include "chrome/browser/profiles/profile_android.h" |
23 #include "chrome/browser/search/search.h" | 23 #include "chrome/browser/search/search.h" |
24 #include "chrome/browser/sessions/session_tab_helper.h" | 24 #include "chrome/browser/sessions/session_tab_helper.h" |
25 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" | 25 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h" |
26 #include "chrome/browser/tab_contents/tab_util.h" | |
26 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg ate.h" | 27 #include "chrome/browser/ui/android/content_settings/popup_blocked_infobar_deleg ate.h" |
27 #include "chrome/browser/ui/android/context_menu_helper.h" | 28 #include "chrome/browser/ui/android/context_menu_helper.h" |
28 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" | 29 #include "chrome/browser/ui/android/infobars/infobar_container_android.h" |
29 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 30 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
30 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 31 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
31 #include "chrome/browser/ui/android/window_android_helper.h" | 32 #include "chrome/browser/ui/android/window_android_helper.h" |
32 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 33 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
33 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 34 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
34 #include "chrome/browser/ui/search/search_tab_helper.h" | 35 #include "chrome/browser/ui/search/search_tab_helper.h" |
35 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 36 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
36 #include "chrome/browser/ui/tab_helpers.h" | 37 #include "chrome/browser/ui/tab_helpers.h" |
37 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" | 38 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h" |
38 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
39 #include "components/google/core/browser/google_url_tracker.h" | 40 #include "components/google/core/browser/google_url_tracker.h" |
40 #include "components/google/core/browser/google_util.h" | 41 #include "components/google/core/browser/google_util.h" |
41 #include "components/infobars/core/infobar_container.h" | 42 #include "components/infobars/core/infobar_container.h" |
42 #include "components/url_fixer/url_fixer.h" | 43 #include "components/url_fixer/url_fixer.h" |
43 #include "content/public/browser/android/content_view_core.h" | 44 #include "content/public/browser/android/content_view_core.h" |
44 #include "content/public/browser/navigation_entry.h" | 45 #include "content/public/browser/navigation_entry.h" |
45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
46 #include "content/public/browser/user_metrics.h" | 47 #include "content/public/browser/user_metrics.h" |
47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
48 #include "jni/Tab_jni.h" | 49 #include "jni/Tab_jni.h" |
49 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 50 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
50 | 51 |
52 using content::GlobalRequestID; | |
53 using content::NavigationController; | |
54 using content::WebContents; | |
55 | |
56 namespace { | |
57 | |
58 WebContents* CreateTargetContents(const chrome::NavigateParams& params, | |
59 const GURL& url) { | |
60 WebContents::CreateParams create_params( | |
61 params.initiating_profile, | |
62 tab_util::GetSiteInstanceForNewTab(params.initiating_profile, url)); | |
63 if (params.source_contents) { | |
64 create_params.initial_size = | |
65 params.source_contents->GetContainerBounds().size(); | |
66 if (params.should_set_opener) | |
67 create_params.opener = params.source_contents; | |
68 } | |
69 if (params.disposition == NEW_BACKGROUND_TAB) | |
70 create_params.initially_hidden = true; | |
71 | |
72 WebContents* target_contents = WebContents::Create(create_params); | |
73 | |
74 // New tabs can have WebUI URLs that will make calls back to arbitrary | |
75 // tab helpers, so the entire set of tab helpers needs to be set up | |
76 // immediately. | |
77 TabAndroid::AttachTabHelpers(target_contents); | |
78 return target_contents; | |
79 } | |
80 | |
81 void LoadURLInContents(content::WebContents* target_contents, | |
82 const GURL& url, | |
83 chrome::NavigateParams* params) { | |
84 NavigationController::LoadURLParams load_url_params(url); | |
85 load_url_params.referrer = params->referrer; | |
86 load_url_params.frame_tree_node_id = params->frame_tree_node_id; | |
87 load_url_params.redirect_chain = params->redirect_chain; | |
88 load_url_params.transition_type = params->transition; | |
89 load_url_params.extra_headers = params->extra_headers; | |
90 load_url_params.should_replace_current_entry = | |
91 params->should_replace_current_entry; | |
92 | |
93 if (params->transferred_global_request_id != GlobalRequestID()) { | |
94 load_url_params.is_renderer_initiated = params->is_renderer_initiated; | |
95 load_url_params.transferred_global_request_id = | |
96 params->transferred_global_request_id; | |
97 } else if (params->is_renderer_initiated) { | |
98 load_url_params.is_renderer_initiated = true; | |
99 } | |
100 | |
101 // Only allows the browser-initiated navigation to use POST. | |
102 if (params->uses_post && !params->is_renderer_initiated) { | |
103 load_url_params.load_type = | |
104 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; | |
105 load_url_params.browser_initiated_post_data = | |
106 params->browser_initiated_post_data; | |
107 } | |
108 target_contents->GetController().LoadURLWithParams(load_url_params); | |
109 } | |
110 | |
111 } // namespace | |
Bernhard Bauer
2014/07/04 16:46:20
One more space before //.
| |
112 | |
51 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 113 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
52 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 114 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
53 if (!core_tab_helper) | 115 if (!core_tab_helper) |
54 return NULL; | 116 return NULL; |
55 | 117 |
56 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 118 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
57 if (!core_delegate) | 119 if (!core_delegate) |
58 return NULL; | 120 return NULL; |
59 | 121 |
60 return static_cast<TabAndroid*>(core_delegate); | 122 return static_cast<TabAndroid*>(core_delegate); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 225 |
164 void TabAndroid::SetSyncId(int sync_id) { | 226 void TabAndroid::SetSyncId(int sync_id) { |
165 JNIEnv* env = base::android::AttachCurrentThread(); | 227 JNIEnv* env = base::android::AttachCurrentThread(); |
166 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); | 228 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); |
167 if (obj.is_null()) | 229 if (obj.is_null()) |
168 return; | 230 return; |
169 Java_Tab_setSyncId(env, obj.obj(), sync_id); | 231 Java_Tab_setSyncId(env, obj.obj(), sync_id); |
170 } | 232 } |
171 | 233 |
172 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { | 234 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { |
173 NOTIMPLEMENTED(); | 235 if (!params->url.is_empty()) { |
236 bool was_blocked = false; | |
237 GURL url = params->url; | |
238 params->target_contents = CreateTargetContents(*params, url); | |
239 LoadURLInContents(params->target_contents, url, params); | |
240 web_contents_delegate_->AddNewContents( | |
241 params->source_contents, | |
242 params->target_contents, | |
243 params->disposition, | |
244 params->window_bounds, | |
245 params->user_gesture, | |
246 &was_blocked); | |
247 if (was_blocked) | |
248 params->target_contents = NULL; | |
249 } | |
174 } | 250 } |
175 | 251 |
176 void TabAndroid::OnReceivedHttpAuthRequest(jobject auth_handler, | 252 void TabAndroid::OnReceivedHttpAuthRequest(jobject auth_handler, |
177 const base::string16& host, | 253 const base::string16& host, |
178 const base::string16& realm) { | 254 const base::string16& realm) { |
179 NOTIMPLEMENTED(); | 255 NOTIMPLEMENTED(); |
180 } | 256 } |
181 | 257 |
182 bool TabAndroid::ShouldWelcomePageLinkToTermsOfService() { | 258 bool TabAndroid::ShouldWelcomePageLinkToTermsOfService() { |
183 NOTIMPLEMENTED(); | 259 NOTIMPLEMENTED(); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 | 602 |
527 static void Init(JNIEnv* env, jobject obj) { | 603 static void Init(JNIEnv* env, jobject obj) { |
528 TRACE_EVENT0("native", "TabAndroid::Init"); | 604 TRACE_EVENT0("native", "TabAndroid::Init"); |
529 // This will automatically bind to the Java object and pass ownership there. | 605 // This will automatically bind to the Java object and pass ownership there. |
530 new TabAndroid(env, obj); | 606 new TabAndroid(env, obj); |
531 } | 607 } |
532 | 608 |
533 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 609 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
534 return RegisterNativesImpl(env); | 610 return RegisterNativesImpl(env); |
535 } | 611 } |
OLD | NEW |