| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 #if defined(OS_ANDROID) | 141 #if defined(OS_ANDROID) |
| 142 #include <cpu-features.h> | 142 #include <cpu-features.h> |
| 143 | 143 |
| 144 #include "content/common/gpu/client/context_provider_command_buffer.h" | 144 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 145 #include "content/renderer/android/synchronous_compositor_factory.h" | 145 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 146 #include "content/renderer/java/gin_java_bridge_dispatcher.h" | 146 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
| 147 #include "content/renderer/media/android/renderer_media_player_manager.h" | 147 #include "content/renderer/media/android/renderer_media_player_manager.h" |
| 148 #include "content/renderer/media/android/stream_texture_factory_impl.h" | 148 #include "content/renderer/media/android/stream_texture_factory_impl.h" |
| 149 #include "content/renderer/media/android/webmediaplayer_android.h" | 149 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 150 #else |
| 151 #include "webkit/common/gpu/context_provider_web_context.h" |
| 150 #endif | 152 #endif |
| 151 | 153 |
| 152 #if defined(ENABLE_BROWSER_CDMS) | 154 #if defined(ENABLE_BROWSER_CDMS) |
| 153 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 155 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
| 154 #endif | 156 #endif |
| 155 | 157 |
| 156 using blink::WebContextMenuData; | 158 using blink::WebContextMenuData; |
| 157 using blink::WebData; | 159 using blink::WebData; |
| 158 using blink::WebDataSource; | 160 using blink::WebDataSource; |
| 159 using blink::WebDocument; | 161 using blink::WebDocument; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (urls[i] != GURL(kSwappedOutURL)) | 235 if (urls[i] != GURL(kSwappedOutURL)) |
| 234 result->push_back(urls[i]); | 236 result->push_back(urls[i]); |
| 235 else | 237 else |
| 236 result->push_back(blank_url); | 238 result->push_back(blank_url); |
| 237 } | 239 } |
| 238 } | 240 } |
| 239 | 241 |
| 240 // Returns the original request url. If there is no redirect, the original | 242 // Returns the original request url. If there is no redirect, the original |
| 241 // url is the same as ds->request()->url(). If the WebDataSource belongs to a | 243 // url is the same as ds->request()->url(). If the WebDataSource belongs to a |
| 242 // frame was loaded by loadData, the original url will be ds->unreachableURL() | 244 // frame was loaded by loadData, the original url will be ds->unreachableURL() |
| 243 static GURL GetOriginalRequestURL(WebDataSource* ds) { | 245 GURL GetOriginalRequestURL(WebDataSource* ds) { |
| 244 // WebDataSource has unreachable URL means that the frame is loaded through | 246 // WebDataSource has unreachable URL means that the frame is loaded through |
| 245 // blink::WebFrame::loadData(), and the base URL will be in the redirect | 247 // blink::WebFrame::loadData(), and the base URL will be in the redirect |
| 246 // chain. However, we never visited the baseURL. So in this case, we should | 248 // chain. However, we never visited the baseURL. So in this case, we should |
| 247 // use the unreachable URL as the original URL. | 249 // use the unreachable URL as the original URL. |
| 248 if (ds->hasUnreachableURL()) | 250 if (ds->hasUnreachableURL()) |
| 249 return ds->unreachableURL(); | 251 return ds->unreachableURL(); |
| 250 | 252 |
| 251 std::vector<GURL> redirects; | 253 std::vector<GURL> redirects; |
| 252 GetRedirectChain(ds, &redirects); | 254 GetRedirectChain(ds, &redirects); |
| 253 if (!redirects.empty()) | 255 if (!redirects.empty()) |
| 254 return redirects.at(0); | 256 return redirects.at(0); |
| 255 | 257 |
| 256 return ds->originalRequest().url(); | 258 return ds->originalRequest().url(); |
| 257 } | 259 } |
| 258 | 260 |
| 259 NOINLINE static void CrashIntentionally() { | 261 NOINLINE void CrashIntentionally() { |
| 260 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 262 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 261 // that the signature is easier to triage in crash reports. | 263 // that the signature is easier to triage in crash reports. |
| 262 volatile int* zero = NULL; | 264 volatile int* zero = NULL; |
| 263 *zero = 0; | 265 *zero = 0; |
| 264 } | 266 } |
| 265 | 267 |
| 266 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 268 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
| 267 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 269 NOINLINE void MaybeTriggerAsanError(const GURL& url) { |
| 268 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 270 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
| 269 // order to trigger an Address Sanitizer (ASAN) error report. | 271 // order to trigger an Address Sanitizer (ASAN) error report. |
| 270 const char kCrashDomain[] = "crash"; | 272 const char kCrashDomain[] = "crash"; |
| 271 const char kHeapOverflow[] = "/heap-overflow"; | 273 const char kHeapOverflow[] = "/heap-overflow"; |
| 272 const char kHeapUnderflow[] = "/heap-underflow"; | 274 const char kHeapUnderflow[] = "/heap-underflow"; |
| 273 const char kUseAfterFree[] = "/use-after-free"; | 275 const char kUseAfterFree[] = "/use-after-free"; |
| 274 #if defined(SYZYASAN) | 276 #if defined(SYZYASAN) |
| 275 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; | 277 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; |
| 276 const char kCorruptHeap[] = "/corrupt-heap"; | 278 const char kCorruptHeap[] = "/corrupt-heap"; |
| 277 #endif | 279 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 292 #if defined(SYZYASAN) | 294 #if defined(SYZYASAN) |
| 293 } else if (crash_type == kCorruptHeapBlock) { | 295 } else if (crash_type == kCorruptHeapBlock) { |
| 294 base::debug::AsanCorruptHeapBlock(); | 296 base::debug::AsanCorruptHeapBlock(); |
| 295 } else if (crash_type == kCorruptHeap) { | 297 } else if (crash_type == kCorruptHeap) { |
| 296 base::debug::AsanCorruptHeap(); | 298 base::debug::AsanCorruptHeap(); |
| 297 #endif | 299 #endif |
| 298 } | 300 } |
| 299 } | 301 } |
| 300 #endif // ADDRESS_SANITIZER || SYZYASAN | 302 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 301 | 303 |
| 302 static void MaybeHandleDebugURL(const GURL& url) { | 304 void MaybeHandleDebugURL(const GURL& url) { |
| 303 if (!url.SchemeIs(kChromeUIScheme)) | 305 if (!url.SchemeIs(kChromeUIScheme)) |
| 304 return; | 306 return; |
| 305 if (url == GURL(kChromeUICrashURL)) { | 307 if (url == GURL(kChromeUICrashURL)) { |
| 306 CrashIntentionally(); | 308 CrashIntentionally(); |
| 307 } else if (url == GURL(kChromeUIDumpURL)) { | 309 } else if (url == GURL(kChromeUIDumpURL)) { |
| 308 // This URL will only correctly create a crash dump file if content is | 310 // This URL will only correctly create a crash dump file if content is |
| 309 // hosted in a process that has correctly called | 311 // hosted in a process that has correctly called |
| 310 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation | 312 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation |
| 311 // of base::debug::DumpWithoutCrashing for more details. | 313 // of base::debug::DumpWithoutCrashing for more details. |
| 312 base::debug::DumpWithoutCrashing(); | 314 base::debug::DumpWithoutCrashing(); |
| 313 } else if (url == GURL(kChromeUIKillURL)) { | 315 } else if (url == GURL(kChromeUIKillURL)) { |
| 314 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); | 316 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
| 315 } else if (url == GURL(kChromeUIHangURL)) { | 317 } else if (url == GURL(kChromeUIHangURL)) { |
| 316 for (;;) { | 318 for (;;) { |
| 317 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 319 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 318 } | 320 } |
| 319 } else if (url == GURL(kChromeUIShorthangURL)) { | 321 } else if (url == GURL(kChromeUIShorthangURL)) { |
| 320 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 322 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 321 } | 323 } |
| 322 | 324 |
| 323 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 325 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
| 324 MaybeTriggerAsanError(url); | 326 MaybeTriggerAsanError(url); |
| 325 #endif // ADDRESS_SANITIZER || SYZYASAN | 327 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 326 } | 328 } |
| 327 | 329 |
| 328 // Returns false unless this is a top-level navigation. | 330 // Returns false unless this is a top-level navigation. |
| 329 static bool IsTopLevelNavigation(WebFrame* frame) { | 331 bool IsTopLevelNavigation(WebFrame* frame) { |
| 330 return frame->parent() == NULL; | 332 return frame->parent() == NULL; |
| 331 } | 333 } |
| 332 | 334 |
| 333 // Returns false unless this is a top-level navigation that crosses origins. | 335 // Returns false unless this is a top-level navigation that crosses origins. |
| 334 static bool IsNonLocalTopLevelNavigation(const GURL& url, | 336 bool IsNonLocalTopLevelNavigation(const GURL& url, |
| 335 WebFrame* frame, | 337 WebFrame* frame, |
| 336 WebNavigationType type, | 338 WebNavigationType type, |
| 337 bool is_form_post) { | 339 bool is_form_post) { |
| 338 if (!IsTopLevelNavigation(frame)) | 340 if (!IsTopLevelNavigation(frame)) |
| 339 return false; | 341 return false; |
| 340 | 342 |
| 341 // Navigations initiated within Webkit are not sent out to the external host | 343 // Navigations initiated within Webkit are not sent out to the external host |
| 342 // in the following cases. | 344 // in the following cases. |
| 343 // 1. The url scheme is not http/https | 345 // 1. The url scheme is not http/https |
| 344 // 2. The origin of the url and the opener is the same in which case the | 346 // 2. The origin of the url and the opener is the same in which case the |
| 345 // opener relationship is maintained. | 347 // opener relationship is maintained. |
| 346 // 3. Reloads/form submits/back forward navigations | 348 // 3. Reloads/form submits/back forward navigations |
| 347 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) | 349 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 browser_navigation_start, renderer_navigation_start); | 405 browser_navigation_start, renderer_navigation_start); |
| 404 double navigation_start_seconds = | 406 double navigation_start_seconds = |
| 405 (navigation_start - base::TimeTicks()).InSecondsF(); | 407 (navigation_start - base::TimeTicks()).InSecondsF(); |
| 406 frame->provisionalDataSource()->setNavigationStartTime( | 408 frame->provisionalDataSource()->setNavigationStartTime( |
| 407 navigation_start_seconds); | 409 navigation_start_seconds); |
| 408 // TODO(clamy): We need to provide additional timing values for the | 410 // TODO(clamy): We need to provide additional timing values for the |
| 409 // Navigation Timing API to work with browser-side navigations. | 411 // Navigation Timing API to work with browser-side navigations. |
| 410 } | 412 } |
| 411 } | 413 } |
| 412 | 414 |
| 415 #if !defined(OS_ANDROID) |
| 416 cc::ContextProvider* GetSharedMainThreadContextProvider() { |
| 417 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 418 DCHECK(render_thread); |
| 419 DCHECK(render_thread->message_loop() == base::MessageLoop::current()); |
| 420 return render_thread->SharedMainThreadContextProvider().get(); |
| 421 } |
| 422 #endif |
| 423 |
| 424 RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) = NULL; |
| 425 |
| 413 } // namespace | 426 } // namespace |
| 414 | 427 |
| 415 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) = | |
| 416 NULL; | |
| 417 | 428 |
| 418 // static | 429 // static |
| 419 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 430 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
| 420 int32 routing_id) { | 431 int32 routing_id) { |
| 421 DCHECK(routing_id != MSG_ROUTING_NONE); | 432 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 422 | 433 |
| 423 if (g_create_render_frame_impl) | 434 if (g_create_render_frame_impl) |
| 424 return g_create_render_frame_impl(render_view, routing_id); | 435 return g_create_render_frame_impl(render_view, routing_id); |
| 425 else | 436 else |
| 426 return new RenderFrameImpl(render_view, routing_id); | 437 return new RenderFrameImpl(render_view, routing_id); |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 base::Unretained(GetContentClient()->renderer()), | 1636 base::Unretained(GetContentClient()->renderer()), |
| 1626 static_cast<RenderFrame*>(this)), | 1637 static_cast<RenderFrame*>(this)), |
| 1627 render_thread->GetAudioRendererMixerManager()->CreateInput( | 1638 render_thread->GetAudioRendererMixerManager()->CreateInput( |
| 1628 render_view_->routing_id_, routing_id_), | 1639 render_view_->routing_id_, routing_id_), |
| 1629 *render_thread->GetAudioHardwareConfig(), | 1640 *render_thread->GetAudioHardwareConfig(), |
| 1630 new RenderMediaLog(), | 1641 new RenderMediaLog(), |
| 1631 render_thread->GetGpuFactories(), | 1642 render_thread->GetGpuFactories(), |
| 1632 render_thread->GetMediaThreadTaskRunner(), | 1643 render_thread->GetMediaThreadTaskRunner(), |
| 1633 render_thread->compositor_message_loop_proxy(), | 1644 render_thread->compositor_message_loop_proxy(), |
| 1634 base::Bind(&EncryptedMediaPlayerSupportImpl::Create), | 1645 base::Bind(&EncryptedMediaPlayerSupportImpl::Create), |
| 1646 base::Bind(&GetSharedMainThreadContextProvider), |
| 1635 initial_cdm); | 1647 initial_cdm); |
| 1636 return new media::WebMediaPlayerImpl(frame, | 1648 return new media::WebMediaPlayerImpl(frame, |
| 1637 client, | 1649 client, |
| 1638 weak_factory_.GetWeakPtr(), | 1650 weak_factory_.GetWeakPtr(), |
| 1639 params); | 1651 params); |
| 1640 #endif // defined(OS_ANDROID) | 1652 #endif // defined(OS_ANDROID) |
| 1641 } | 1653 } |
| 1642 | 1654 |
| 1643 blink::WebContentDecryptionModule* | 1655 blink::WebContentDecryptionModule* |
| 1644 RenderFrameImpl::createContentDecryptionModule( | 1656 RenderFrameImpl::createContentDecryptionModule( |
| (...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3974 | 3986 |
| 3975 #if defined(ENABLE_BROWSER_CDMS) | 3987 #if defined(ENABLE_BROWSER_CDMS) |
| 3976 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3988 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 3977 if (!cdm_manager_) | 3989 if (!cdm_manager_) |
| 3978 cdm_manager_ = new RendererCdmManager(this); | 3990 cdm_manager_ = new RendererCdmManager(this); |
| 3979 return cdm_manager_; | 3991 return cdm_manager_; |
| 3980 } | 3992 } |
| 3981 #endif // defined(ENABLE_BROWSER_CDMS) | 3993 #endif // defined(ENABLE_BROWSER_CDMS) |
| 3982 | 3994 |
| 3983 } // namespace content | 3995 } // namespace content |
| OLD | NEW |