Chromium Code Reviews| 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 | |
| 51 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 56 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
| 52 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 57 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
| 53 if (!core_tab_helper) | 58 if (!core_tab_helper) |
| 54 return NULL; | 59 return NULL; |
| 55 | 60 |
| 56 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 61 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
| 57 if (!core_delegate) | 62 if (!core_delegate) |
| 58 return NULL; | 63 return NULL; |
| 59 | 64 |
| 60 return static_cast<TabAndroid*>(core_delegate); | 65 return static_cast<TabAndroid*>(core_delegate); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 | 168 |
| 164 void TabAndroid::SetSyncId(int sync_id) { | 169 void TabAndroid::SetSyncId(int sync_id) { |
| 165 JNIEnv* env = base::android::AttachCurrentThread(); | 170 JNIEnv* env = base::android::AttachCurrentThread(); |
| 166 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); | 171 ScopedJavaLocalRef<jobject> obj = weak_java_tab_.get(env); |
| 167 if (obj.is_null()) | 172 if (obj.is_null()) |
| 168 return; | 173 return; |
| 169 Java_Tab_setSyncId(env, obj.obj(), sync_id); | 174 Java_Tab_setSyncId(env, obj.obj(), sync_id); |
| 170 } | 175 } |
| 171 | 176 |
| 172 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { | 177 void TabAndroid::HandlePopupNavigation(chrome::NavigateParams* params) { |
| 173 NOTIMPLEMENTED(); | 178 if (!params->url.is_empty()) { |
| 179 bool was_blocked = false; | |
| 180 GURL url = params->url; | |
| 181 params->target_contents = CreateTargetContents(*params, url); | |
| 182 LoadURLInContents(params->target_contents, url, params); | |
| 183 web_contents_delegate_->AddNewContents( | |
| 184 params->source_contents, | |
|
Bernhard Bauer
2014/07/04 14:06:29
Fix alignment. `git cl format` can help you there.
Bernhard Bauer
2014/07/04 16:46:19
This is not fixed yet. Please make sure that you a
| |
| 185 params->target_contents, | |
| 186 params->disposition, | |
| 187 params->window_bounds, | |
| 188 params->user_gesture, | |
| 189 &was_blocked); | |
| 190 if (was_blocked) | |
| 191 params->target_contents = NULL; | |
| 192 } | |
| 193 } | |
| 194 | |
| 195 WebContents* TabAndroid::CreateTargetContents( | |
| 196 const chrome::NavigateParams& params, | |
| 197 const GURL& url) { | |
| 198 WebContents::CreateParams create_params( | |
| 199 params.initiating_profile, | |
| 200 tab_util::GetSiteInstanceForNewTab(params.initiating_profile, url)); | |
| 201 if (params.source_contents) { | |
| 202 create_params.initial_size = | |
| 203 params.source_contents->GetContainerBounds().size(); | |
| 204 if (params.should_set_opener) | |
| 205 create_params.opener = params.source_contents; | |
| 206 } | |
| 207 if (params.disposition == NEW_BACKGROUND_TAB) | |
| 208 create_params.initially_hidden = true; | |
| 209 | |
| 210 WebContents* target_contents = WebContents::Create(create_params); | |
| 211 | |
| 212 // New tabs can have WebUI URLs that will make calls back to arbitrary | |
| 213 // tab helpers, so the entire set of tab helpers needs to be set up | |
| 214 // immediately. | |
| 215 TabHelpers::AttachTabHelpers(target_contents); | |
| 216 return target_contents; | |
| 217 } | |
| 218 | |
| 219 void TabAndroid::LoadURLInContents(content::WebContents* target_contents, | |
| 220 const GURL& url, | |
|
Bernhard Bauer
2014/07/04 14:06:29
Alignment
| |
| 221 chrome::NavigateParams* params) { | |
| 222 NavigationController::LoadURLParams load_url_params(url); | |
| 223 load_url_params.referrer = params->referrer; | |
| 224 load_url_params.frame_tree_node_id = params->frame_tree_node_id; | |
| 225 load_url_params.redirect_chain = params->redirect_chain; | |
| 226 load_url_params.transition_type = params->transition; | |
| 227 load_url_params.extra_headers = params->extra_headers; | |
| 228 load_url_params.should_replace_current_entry = | |
| 229 params->should_replace_current_entry; | |
| 230 | |
| 231 if (params->transferred_global_request_id != GlobalRequestID()) { | |
| 232 load_url_params.is_renderer_initiated = params->is_renderer_initiated; | |
| 233 load_url_params.transferred_global_request_id = | |
| 234 params->transferred_global_request_id; | |
| 235 } else if (params->is_renderer_initiated) { | |
| 236 load_url_params.is_renderer_initiated = true; | |
| 237 } | |
| 238 | |
| 239 // Only allows the browser-initiated navigation to use POST. | |
| 240 if (params->uses_post && !params->is_renderer_initiated) { | |
| 241 load_url_params.load_type = | |
| 242 NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; | |
| 243 load_url_params.browser_initiated_post_data = | |
| 244 params->browser_initiated_post_data; | |
| 245 } | |
| 246 target_contents->GetController().LoadURLWithParams(load_url_params); | |
| 174 } | 247 } |
| 175 | 248 |
| 176 void TabAndroid::OnReceivedHttpAuthRequest(jobject auth_handler, | 249 void TabAndroid::OnReceivedHttpAuthRequest(jobject auth_handler, |
| 177 const base::string16& host, | 250 const base::string16& host, |
| 178 const base::string16& realm) { | 251 const base::string16& realm) { |
| 179 NOTIMPLEMENTED(); | 252 NOTIMPLEMENTED(); |
| 180 } | 253 } |
| 181 | 254 |
| 182 bool TabAndroid::ShouldWelcomePageLinkToTermsOfService() { | 255 bool TabAndroid::ShouldWelcomePageLinkToTermsOfService() { |
| 183 NOTIMPLEMENTED(); | 256 NOTIMPLEMENTED(); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 | 599 |
| 527 static void Init(JNIEnv* env, jobject obj) { | 600 static void Init(JNIEnv* env, jobject obj) { |
| 528 TRACE_EVENT0("native", "TabAndroid::Init"); | 601 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 529 // This will automatically bind to the Java object and pass ownership there. | 602 // This will automatically bind to the Java object and pass ownership there. |
| 530 new TabAndroid(env, obj); | 603 new TabAndroid(env, obj); |
| 531 } | 604 } |
| 532 | 605 |
| 533 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 606 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 534 return RegisterNativesImpl(env); | 607 return RegisterNativesImpl(env); |
| 535 } | 608 } |
| OLD | NEW |