| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_web_contents_delegate_android.h" | 5 #include "chrome/browser/android/tab_web_contents_delegate_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.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" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 return true; | 293 return true; |
| 294 #else | 294 #else |
| 295 return false; | 295 return false; |
| 296 #endif | 296 #endif |
| 297 } | 297 } |
| 298 | 298 |
| 299 WebContents* TabWebContentsDelegateAndroid::OpenURLFromTab( | 299 WebContents* TabWebContentsDelegateAndroid::OpenURLFromTab( |
| 300 WebContents* source, | 300 WebContents* source, |
| 301 const content::OpenURLParams& params) { | 301 const content::OpenURLParams& params) { |
| 302 WindowOpenDisposition disposition = params.disposition; | 302 WindowOpenDisposition disposition = params.disposition; |
| 303 if (!source || (disposition != CURRENT_TAB && | 303 if (!source || (disposition != WindowOpenDisposition::CURRENT_TAB && |
| 304 disposition != NEW_FOREGROUND_TAB && | 304 disposition != WindowOpenDisposition::NEW_FOREGROUND_TAB && |
| 305 disposition != NEW_BACKGROUND_TAB && | 305 disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB && |
| 306 disposition != OFF_THE_RECORD && | 306 disposition != WindowOpenDisposition::OFF_THE_RECORD && |
| 307 disposition != NEW_POPUP && | 307 disposition != WindowOpenDisposition::NEW_POPUP && |
| 308 disposition != NEW_WINDOW)) { | 308 disposition != WindowOpenDisposition::NEW_WINDOW)) { |
| 309 // We can't handle this here. Give the parent a chance. | 309 // We can't handle this here. Give the parent a chance. |
| 310 return WebContentsDelegateAndroid::OpenURLFromTab(source, params); | 310 return WebContentsDelegateAndroid::OpenURLFromTab(source, params); |
| 311 } | 311 } |
| 312 | 312 |
| 313 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); | 313 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext()); |
| 314 chrome::NavigateParams nav_params(profile, | 314 chrome::NavigateParams nav_params(profile, |
| 315 params.url, | 315 params.url, |
| 316 params.transition); | 316 params.transition); |
| 317 FillNavigateParamsFromOpenURLParams(&nav_params, params); | 317 FillNavigateParamsFromOpenURLParams(&nav_params, params); |
| 318 nav_params.source_contents = source; | 318 nav_params.source_contents = source; |
| 319 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 319 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 320 nav_params.user_gesture = params.user_gesture; | 320 nav_params.user_gesture = params.user_gesture; |
| 321 | 321 |
| 322 PopupBlockerTabHelper* popup_blocker_helper = | 322 PopupBlockerTabHelper* popup_blocker_helper = |
| 323 PopupBlockerTabHelper::FromWebContents(source); | 323 PopupBlockerTabHelper::FromWebContents(source); |
| 324 DCHECK(popup_blocker_helper); | 324 DCHECK(popup_blocker_helper); |
| 325 | 325 |
| 326 if ((params.disposition == NEW_POPUP || | 326 if ((params.disposition == WindowOpenDisposition::NEW_POPUP || |
| 327 params.disposition == NEW_FOREGROUND_TAB || | 327 params.disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB || |
| 328 params.disposition == NEW_BACKGROUND_TAB || | 328 params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB || |
| 329 params.disposition == NEW_WINDOW) && | 329 params.disposition == WindowOpenDisposition::NEW_WINDOW) && |
| 330 !params.user_gesture && | 330 !params.user_gesture && |
| 331 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 331 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 332 switches::kDisablePopupBlocking)) { | 332 switches::kDisablePopupBlocking)) { |
| 333 if (popup_blocker_helper->MaybeBlockPopup(nav_params, | 333 if (popup_blocker_helper->MaybeBlockPopup(nav_params, |
| 334 blink::WebWindowFeatures())) { | 334 blink::WebWindowFeatures())) { |
| 335 return nullptr; | 335 return nullptr; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 if (disposition == CURRENT_TAB) { | 339 if (disposition == WindowOpenDisposition::CURRENT_TAB) { |
| 340 // Only prerender for a current-tab navigation to avoid session storage | 340 // Only prerender for a current-tab navigation to avoid session storage |
| 341 // namespace issues. | 341 // namespace issues. |
| 342 nav_params.target_contents = source; | 342 nav_params.target_contents = source; |
| 343 prerender::PrerenderManager* prerender_manager = | 343 prerender::PrerenderManager* prerender_manager = |
| 344 prerender::PrerenderManagerFactory::GetForProfile(profile); | 344 prerender::PrerenderManagerFactory::GetForProfile(profile); |
| 345 if (prerender_manager && | 345 if (prerender_manager && |
| 346 prerender_manager->MaybeUsePrerenderedPage(params.url, &nav_params)) { | 346 prerender_manager->MaybeUsePrerenderedPage(params.url, &nav_params)) { |
| 347 return nav_params.target_contents; | 347 return nav_params.target_contents; |
| 348 } | 348 } |
| 349 } | 349 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 362 } | 362 } |
| 363 | 363 |
| 364 void TabWebContentsDelegateAndroid::AddNewContents( | 364 void TabWebContentsDelegateAndroid::AddNewContents( |
| 365 WebContents* source, | 365 WebContents* source, |
| 366 WebContents* new_contents, | 366 WebContents* new_contents, |
| 367 WindowOpenDisposition disposition, | 367 WindowOpenDisposition disposition, |
| 368 const gfx::Rect& initial_rect, | 368 const gfx::Rect& initial_rect, |
| 369 bool user_gesture, | 369 bool user_gesture, |
| 370 bool* was_blocked) { | 370 bool* was_blocked) { |
| 371 // No code for this yet. | 371 // No code for this yet. |
| 372 DCHECK_NE(disposition, SAVE_TO_DISK); | 372 DCHECK_NE(disposition, WindowOpenDisposition::SAVE_TO_DISK); |
| 373 // Can't create a new contents for the current tab - invalid case. | 373 // Can't create a new contents for the current tab - invalid case. |
| 374 DCHECK_NE(disposition, CURRENT_TAB); | 374 DCHECK_NE(disposition, WindowOpenDisposition::CURRENT_TAB); |
| 375 | 375 |
| 376 TabHelpers::AttachTabHelpers(new_contents); | 376 TabHelpers::AttachTabHelpers(new_contents); |
| 377 | 377 |
| 378 JNIEnv* env = AttachCurrentThread(); | 378 JNIEnv* env = AttachCurrentThread(); |
| 379 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); | 379 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
| 380 bool handled = false; | 380 bool handled = false; |
| 381 if (!obj.is_null()) { | 381 if (!obj.is_null()) { |
| 382 ScopedJavaLocalRef<jobject> jsource; | 382 ScopedJavaLocalRef<jobject> jsource; |
| 383 if (source) | 383 if (source) |
| 384 jsource = source->GetJavaWebContents(); | 384 jsource = source->GetJavaWebContents(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 jboolean IsCapturingVideo(JNIEnv* env, | 457 jboolean IsCapturingVideo(JNIEnv* env, |
| 458 const JavaParamRef<jclass>& clazz, | 458 const JavaParamRef<jclass>& clazz, |
| 459 const JavaParamRef<jobject>& java_web_contents) { | 459 const JavaParamRef<jobject>& java_web_contents) { |
| 460 content::WebContents* web_contents = | 460 content::WebContents* web_contents = |
| 461 content::WebContents::FromJavaWebContents(java_web_contents); | 461 content::WebContents::FromJavaWebContents(java_web_contents); |
| 462 scoped_refptr<MediaStreamCaptureIndicator> indicator = | 462 scoped_refptr<MediaStreamCaptureIndicator> indicator = |
| 463 MediaCaptureDevicesDispatcher::GetInstance()-> | 463 MediaCaptureDevicesDispatcher::GetInstance()-> |
| 464 GetMediaStreamCaptureIndicator(); | 464 GetMediaStreamCaptureIndicator(); |
| 465 return indicator->IsCapturingVideo(web_contents); | 465 return indicator->IsCapturingVideo(web_contents); |
| 466 } | 466 } |
| OLD | NEW |