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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 | 144 |
145 #if defined(OS_ANDROID) | 145 #if defined(OS_ANDROID) |
146 #include <cpu-features.h> | 146 #include <cpu-features.h> |
147 | 147 |
148 #include "content/common/gpu/client/context_provider_command_buffer.h" | 148 #include "content/common/gpu/client/context_provider_command_buffer.h" |
149 #include "content/renderer/android/synchronous_compositor_factory.h" | 149 #include "content/renderer/android/synchronous_compositor_factory.h" |
150 #include "content/renderer/java/gin_java_bridge_dispatcher.h" | 150 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
151 #include "content/renderer/media/android/renderer_media_player_manager.h" | 151 #include "content/renderer/media/android/renderer_media_player_manager.h" |
152 #include "content/renderer/media/android/stream_texture_factory_impl.h" | 152 #include "content/renderer/media/android/stream_texture_factory_impl.h" |
153 #include "content/renderer/media/android/webmediaplayer_android.h" | 153 #include "content/renderer/media/android/webmediaplayer_android.h" |
154 #else | |
155 #include "webkit/common/gpu/context_provider_web_context.h" | |
154 #endif | 156 #endif |
155 | 157 |
156 #if defined(ENABLE_PEPPER_CDMS) | 158 #if defined(ENABLE_PEPPER_CDMS) |
157 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" | 159 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" |
158 #elif defined(ENABLE_BROWSER_CDMS) | 160 #elif defined(ENABLE_BROWSER_CDMS) |
159 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 161 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
160 #endif | 162 #endif |
161 | 163 |
162 using blink::WebContextMenuData; | 164 using blink::WebContextMenuData; |
163 using blink::WebData; | 165 using blink::WebData; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 if (urls[i] != GURL(kSwappedOutURL)) | 241 if (urls[i] != GURL(kSwappedOutURL)) |
240 result->push_back(urls[i]); | 242 result->push_back(urls[i]); |
241 else | 243 else |
242 result->push_back(blank_url); | 244 result->push_back(blank_url); |
243 } | 245 } |
244 } | 246 } |
245 | 247 |
246 // Returns the original request url. If there is no redirect, the original | 248 // Returns the original request url. If there is no redirect, the original |
247 // url is the same as ds->request()->url(). If the WebDataSource belongs to a | 249 // url is the same as ds->request()->url(). If the WebDataSource belongs to a |
248 // frame was loaded by loadData, the original url will be ds->unreachableURL() | 250 // frame was loaded by loadData, the original url will be ds->unreachableURL() |
249 static GURL GetOriginalRequestURL(WebDataSource* ds) { | 251 GURL GetOriginalRequestURL(WebDataSource* ds) { |
250 // WebDataSource has unreachable URL means that the frame is loaded through | 252 // WebDataSource has unreachable URL means that the frame is loaded through |
251 // blink::WebFrame::loadData(), and the base URL will be in the redirect | 253 // blink::WebFrame::loadData(), and the base URL will be in the redirect |
252 // chain. However, we never visited the baseURL. So in this case, we should | 254 // chain. However, we never visited the baseURL. So in this case, we should |
253 // use the unreachable URL as the original URL. | 255 // use the unreachable URL as the original URL. |
254 if (ds->hasUnreachableURL()) | 256 if (ds->hasUnreachableURL()) |
255 return ds->unreachableURL(); | 257 return ds->unreachableURL(); |
256 | 258 |
257 std::vector<GURL> redirects; | 259 std::vector<GURL> redirects; |
258 GetRedirectChain(ds, &redirects); | 260 GetRedirectChain(ds, &redirects); |
259 if (!redirects.empty()) | 261 if (!redirects.empty()) |
260 return redirects.at(0); | 262 return redirects.at(0); |
261 | 263 |
262 return ds->originalRequest().url(); | 264 return ds->originalRequest().url(); |
263 } | 265 } |
264 | 266 |
265 NOINLINE static void CrashIntentionally() { | 267 NOINLINE void CrashIntentionally() { |
266 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 268 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
267 // that the signature is easier to triage in crash reports. | 269 // that the signature is easier to triage in crash reports. |
268 volatile int* zero = NULL; | 270 volatile int* zero = NULL; |
269 *zero = 0; | 271 *zero = 0; |
270 } | 272 } |
271 | 273 |
272 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 274 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
273 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 275 NOINLINE void MaybeTriggerAsanError(const GURL& url) { |
274 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 276 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
275 // order to trigger an Address Sanitizer (ASAN) error report. | 277 // order to trigger an Address Sanitizer (ASAN) error report. |
276 const char kCrashDomain[] = "crash"; | 278 const char kCrashDomain[] = "crash"; |
277 const char kHeapOverflow[] = "/heap-overflow"; | 279 const char kHeapOverflow[] = "/heap-overflow"; |
278 const char kHeapUnderflow[] = "/heap-underflow"; | 280 const char kHeapUnderflow[] = "/heap-underflow"; |
279 const char kUseAfterFree[] = "/use-after-free"; | 281 const char kUseAfterFree[] = "/use-after-free"; |
280 #if defined(SYZYASAN) | 282 #if defined(SYZYASAN) |
281 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; | 283 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; |
282 const char kCorruptHeap[] = "/corrupt-heap"; | 284 const char kCorruptHeap[] = "/corrupt-heap"; |
283 #endif | 285 #endif |
(...skipping 14 matching lines...) Expand all Loading... | |
298 #if defined(SYZYASAN) | 300 #if defined(SYZYASAN) |
299 } else if (crash_type == kCorruptHeapBlock) { | 301 } else if (crash_type == kCorruptHeapBlock) { |
300 base::debug::AsanCorruptHeapBlock(); | 302 base::debug::AsanCorruptHeapBlock(); |
301 } else if (crash_type == kCorruptHeap) { | 303 } else if (crash_type == kCorruptHeap) { |
302 base::debug::AsanCorruptHeap(); | 304 base::debug::AsanCorruptHeap(); |
303 #endif | 305 #endif |
304 } | 306 } |
305 } | 307 } |
306 #endif // ADDRESS_SANITIZER || SYZYASAN | 308 #endif // ADDRESS_SANITIZER || SYZYASAN |
307 | 309 |
308 static void MaybeHandleDebugURL(const GURL& url) { | 310 void MaybeHandleDebugURL(const GURL& url) { |
309 if (!url.SchemeIs(kChromeUIScheme)) | 311 if (!url.SchemeIs(kChromeUIScheme)) |
310 return; | 312 return; |
311 if (url == GURL(kChromeUICrashURL)) { | 313 if (url == GURL(kChromeUICrashURL)) { |
312 CrashIntentionally(); | 314 CrashIntentionally(); |
313 } else if (url == GURL(kChromeUIDumpURL)) { | 315 } else if (url == GURL(kChromeUIDumpURL)) { |
314 // This URL will only correctly create a crash dump file if content is | 316 // This URL will only correctly create a crash dump file if content is |
315 // hosted in a process that has correctly called | 317 // hosted in a process that has correctly called |
316 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation | 318 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation |
317 // of base::debug::DumpWithoutCrashing for more details. | 319 // of base::debug::DumpWithoutCrashing for more details. |
318 base::debug::DumpWithoutCrashing(); | 320 base::debug::DumpWithoutCrashing(); |
319 } else if (url == GURL(kChromeUIKillURL)) { | 321 } else if (url == GURL(kChromeUIKillURL)) { |
320 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); | 322 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
321 } else if (url == GURL(kChromeUIHangURL)) { | 323 } else if (url == GURL(kChromeUIHangURL)) { |
322 for (;;) { | 324 for (;;) { |
323 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 325 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
324 } | 326 } |
325 } else if (url == GURL(kChromeUIShorthangURL)) { | 327 } else if (url == GURL(kChromeUIShorthangURL)) { |
326 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 328 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
327 } | 329 } |
328 | 330 |
329 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 331 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
330 MaybeTriggerAsanError(url); | 332 MaybeTriggerAsanError(url); |
331 #endif // ADDRESS_SANITIZER || SYZYASAN | 333 #endif // ADDRESS_SANITIZER || SYZYASAN |
332 } | 334 } |
333 | 335 |
334 // Returns false unless this is a top-level navigation. | 336 // Returns false unless this is a top-level navigation. |
335 static bool IsTopLevelNavigation(WebFrame* frame) { | 337 bool IsTopLevelNavigation(WebFrame* frame) { |
336 return frame->parent() == NULL; | 338 return frame->parent() == NULL; |
337 } | 339 } |
338 | 340 |
339 // Returns false unless this is a top-level navigation that crosses origins. | 341 // Returns false unless this is a top-level navigation that crosses origins. |
340 static bool IsNonLocalTopLevelNavigation(const GURL& url, | 342 bool IsNonLocalTopLevelNavigation(const GURL& url, |
341 WebFrame* frame, | 343 WebFrame* frame, |
342 WebNavigationType type, | 344 WebNavigationType type, |
343 bool is_form_post) { | 345 bool is_form_post) { |
344 if (!IsTopLevelNavigation(frame)) | 346 if (!IsTopLevelNavigation(frame)) |
345 return false; | 347 return false; |
346 | 348 |
347 // Navigations initiated within Webkit are not sent out to the external host | 349 // Navigations initiated within Webkit are not sent out to the external host |
348 // in the following cases. | 350 // in the following cases. |
349 // 1. The url scheme is not http/https | 351 // 1. The url scheme is not http/https |
350 // 2. The origin of the url and the opener is the same in which case the | 352 // 2. The origin of the url and the opener is the same in which case the |
351 // opener relationship is maintained. | 353 // opener relationship is maintained. |
352 // 3. Reloads/form submits/back forward navigations | 354 // 3. Reloads/form submits/back forward navigations |
353 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) | 355 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 extra_data = &kEmptyData; | 467 extra_data = &kEmptyData; |
466 CommonNavigationParams params; | 468 CommonNavigationParams params; |
467 params.url = request.url(); | 469 params.url = request.url(); |
468 params.referrer = Referrer( | 470 params.referrer = Referrer( |
469 GURL(request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()), | 471 GURL(request.httpHeaderField(WebString::fromUTF8("Referer")).latin1()), |
470 request.referrerPolicy()); | 472 request.referrerPolicy()); |
471 params.transition = extra_data->transition_type(); | 473 params.transition = extra_data->transition_type(); |
472 return params; | 474 return params; |
473 } | 475 } |
474 | 476 |
477 #if !defined(OS_ANDROID) | |
478 media::Context3DProvider GetSharedMainThreadContext3DProvider() { | |
479 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | |
480 DCHECK(render_thread); | |
scherkus (not reviewing)
2014/10/30 20:40:11
nit: I'm not sure how useful these DCHECKs are in
dshwang
2014/10/31 09:29:16
I agree. I removed DCHECKs.
| |
481 DCHECK(render_thread->message_loop() == base::MessageLoop::current()); | |
482 cc::ContextProvider* provider = | |
483 render_thread->SharedMainThreadContextProvider().get(); | |
484 if (!provider) | |
485 return {nullptr, nullptr}; | |
486 return {provider->ContextGL(), provider->GrContext()}; | |
487 } | |
488 #endif | |
489 | |
490 RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, | |
491 int32) = nullptr; | |
492 | |
475 } // namespace | 493 } // namespace |
476 | 494 |
477 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) = | |
478 NULL; | |
479 | 495 |
480 // static | 496 // static |
481 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 497 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
482 int32 routing_id) { | 498 int32 routing_id) { |
483 DCHECK(routing_id != MSG_ROUTING_NONE); | 499 DCHECK(routing_id != MSG_ROUTING_NONE); |
484 | 500 |
485 if (g_create_render_frame_impl) | 501 if (g_create_render_frame_impl) |
486 return g_create_render_frame_impl(render_view, routing_id); | 502 return g_create_render_frame_impl(render_view, routing_id); |
487 else | 503 else |
488 return new RenderFrameImpl(render_view, routing_id); | 504 return new RenderFrameImpl(render_view, routing_id); |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1695 base::Unretained(GetContentClient()->renderer()), | 1711 base::Unretained(GetContentClient()->renderer()), |
1696 static_cast<RenderFrame*>(this)), | 1712 static_cast<RenderFrame*>(this)), |
1697 render_thread->GetAudioRendererMixerManager()->CreateInput( | 1713 render_thread->GetAudioRendererMixerManager()->CreateInput( |
1698 render_view_->routing_id_, routing_id_), | 1714 render_view_->routing_id_, routing_id_), |
1699 *render_thread->GetAudioHardwareConfig(), | 1715 *render_thread->GetAudioHardwareConfig(), |
1700 new RenderMediaLog(), | 1716 new RenderMediaLog(), |
1701 render_thread->GetGpuFactories(), | 1717 render_thread->GetGpuFactories(), |
1702 render_thread->GetMediaThreadTaskRunner(), | 1718 render_thread->GetMediaThreadTaskRunner(), |
1703 render_thread->compositor_message_loop_proxy(), | 1719 render_thread->compositor_message_loop_proxy(), |
1704 base::Bind(&EncryptedMediaPlayerSupportImpl::Create), | 1720 base::Bind(&EncryptedMediaPlayerSupportImpl::Create), |
1721 base::Bind(&GetSharedMainThreadContext3DProvider), | |
1705 initial_cdm); | 1722 initial_cdm); |
1706 return new media::WebMediaPlayerImpl( | 1723 return new media::WebMediaPlayerImpl( |
1707 frame, client, weak_factory_.GetWeakPtr(), nullptr, params); | 1724 frame, client, weak_factory_.GetWeakPtr(), nullptr, params); |
1708 #endif // defined(OS_ANDROID) | 1725 #endif // defined(OS_ANDROID) |
1709 } | 1726 } |
1710 | 1727 |
1711 blink::WebContentDecryptionModule* | 1728 blink::WebContentDecryptionModule* |
1712 RenderFrameImpl::createContentDecryptionModule( | 1729 RenderFrameImpl::createContentDecryptionModule( |
1713 blink::WebLocalFrame* frame, | 1730 blink::WebLocalFrame* frame, |
1714 const blink::WebSecurityOrigin& security_origin, | 1731 const blink::WebSecurityOrigin& security_origin, |
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4126 | 4143 |
4127 #if defined(ENABLE_BROWSER_CDMS) | 4144 #if defined(ENABLE_BROWSER_CDMS) |
4128 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4145 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
4129 if (!cdm_manager_) | 4146 if (!cdm_manager_) |
4130 cdm_manager_ = new RendererCdmManager(this); | 4147 cdm_manager_ = new RendererCdmManager(this); |
4131 return cdm_manager_; | 4148 return cdm_manager_; |
4132 } | 4149 } |
4133 #endif // defined(ENABLE_BROWSER_CDMS) | 4150 #endif // defined(ENABLE_BROWSER_CDMS) |
4134 | 4151 |
4135 } // namespace content | 4152 } // namespace content |
OLD | NEW |