Chromium Code Reviews| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 145 |
| 146 #if defined(OS_ANDROID) | 146 #if defined(OS_ANDROID) |
| 147 #include <cpu-features.h> | 147 #include <cpu-features.h> |
| 148 | 148 |
| 149 #include "content/common/gpu/client/context_provider_command_buffer.h" | 149 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 150 #include "content/renderer/android/synchronous_compositor_factory.h" | 150 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 151 #include "content/renderer/java/gin_java_bridge_dispatcher.h" | 151 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
| 152 #include "content/renderer/media/android/renderer_media_player_manager.h" | 152 #include "content/renderer/media/android/renderer_media_player_manager.h" |
| 153 #include "content/renderer/media/android/stream_texture_factory_impl.h" | 153 #include "content/renderer/media/android/stream_texture_factory_impl.h" |
| 154 #include "content/renderer/media/android/webmediaplayer_android.h" | 154 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 155 #else | |
| 156 #include "webkit/common/gpu/context_provider_web_context.h" | |
| 155 #endif | 157 #endif |
| 156 | 158 |
| 157 #if defined(ENABLE_PEPPER_CDMS) | 159 #if defined(ENABLE_PEPPER_CDMS) |
| 158 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" | 160 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" |
| 159 #elif defined(ENABLE_BROWSER_CDMS) | 161 #elif defined(ENABLE_BROWSER_CDMS) |
| 160 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 162 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
| 161 #endif | 163 #endif |
| 162 | 164 |
| 163 using blink::WebContextMenuData; | 165 using blink::WebContextMenuData; |
| 164 using blink::WebData; | 166 using blink::WebData; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 if (urls[i] != GURL(kSwappedOutURL)) | 242 if (urls[i] != GURL(kSwappedOutURL)) |
| 241 result->push_back(urls[i]); | 243 result->push_back(urls[i]); |
| 242 else | 244 else |
| 243 result->push_back(blank_url); | 245 result->push_back(blank_url); |
| 244 } | 246 } |
| 245 } | 247 } |
| 246 | 248 |
| 247 // Returns the original request url. If there is no redirect, the original | 249 // Returns the original request url. If there is no redirect, the original |
| 248 // url is the same as ds->request()->url(). If the WebDataSource belongs to a | 250 // url is the same as ds->request()->url(). If the WebDataSource belongs to a |
| 249 // frame was loaded by loadData, the original url will be ds->unreachableURL() | 251 // frame was loaded by loadData, the original url will be ds->unreachableURL() |
| 250 static GURL GetOriginalRequestURL(WebDataSource* ds) { | 252 GURL GetOriginalRequestURL(WebDataSource* ds) { |
| 251 // WebDataSource has unreachable URL means that the frame is loaded through | 253 // WebDataSource has unreachable URL means that the frame is loaded through |
| 252 // blink::WebFrame::loadData(), and the base URL will be in the redirect | 254 // blink::WebFrame::loadData(), and the base URL will be in the redirect |
| 253 // chain. However, we never visited the baseURL. So in this case, we should | 255 // chain. However, we never visited the baseURL. So in this case, we should |
| 254 // use the unreachable URL as the original URL. | 256 // use the unreachable URL as the original URL. |
| 255 if (ds->hasUnreachableURL()) | 257 if (ds->hasUnreachableURL()) |
| 256 return ds->unreachableURL(); | 258 return ds->unreachableURL(); |
| 257 | 259 |
| 258 std::vector<GURL> redirects; | 260 std::vector<GURL> redirects; |
| 259 GetRedirectChain(ds, &redirects); | 261 GetRedirectChain(ds, &redirects); |
| 260 if (!redirects.empty()) | 262 if (!redirects.empty()) |
| 261 return redirects.at(0); | 263 return redirects.at(0); |
| 262 | 264 |
| 263 return ds->originalRequest().url(); | 265 return ds->originalRequest().url(); |
| 264 } | 266 } |
| 265 | 267 |
| 266 NOINLINE static void CrashIntentionally() { | 268 NOINLINE void CrashIntentionally() { |
| 267 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 269 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 268 // that the signature is easier to triage in crash reports. | 270 // that the signature is easier to triage in crash reports. |
| 269 volatile int* zero = NULL; | 271 volatile int* zero = NULL; |
| 270 *zero = 0; | 272 *zero = 0; |
| 271 } | 273 } |
| 272 | 274 |
| 273 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 275 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
| 274 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { | 276 NOINLINE void MaybeTriggerAsanError(const GURL& url) { |
| 275 // NOTE(rogerm): We intentionally perform an invalid heap access here in | 277 // NOTE(rogerm): We intentionally perform an invalid heap access here in |
| 276 // order to trigger an Address Sanitizer (ASAN) error report. | 278 // order to trigger an Address Sanitizer (ASAN) error report. |
| 277 const char kCrashDomain[] = "crash"; | 279 const char kCrashDomain[] = "crash"; |
| 278 const char kHeapOverflow[] = "/heap-overflow"; | 280 const char kHeapOverflow[] = "/heap-overflow"; |
| 279 const char kHeapUnderflow[] = "/heap-underflow"; | 281 const char kHeapUnderflow[] = "/heap-underflow"; |
| 280 const char kUseAfterFree[] = "/use-after-free"; | 282 const char kUseAfterFree[] = "/use-after-free"; |
| 281 #if defined(SYZYASAN) | 283 #if defined(SYZYASAN) |
| 282 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; | 284 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; |
| 283 const char kCorruptHeap[] = "/corrupt-heap"; | 285 const char kCorruptHeap[] = "/corrupt-heap"; |
| 284 #endif | 286 #endif |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 299 #if defined(SYZYASAN) | 301 #if defined(SYZYASAN) |
| 300 } else if (crash_type == kCorruptHeapBlock) { | 302 } else if (crash_type == kCorruptHeapBlock) { |
| 301 base::debug::AsanCorruptHeapBlock(); | 303 base::debug::AsanCorruptHeapBlock(); |
| 302 } else if (crash_type == kCorruptHeap) { | 304 } else if (crash_type == kCorruptHeap) { |
| 303 base::debug::AsanCorruptHeap(); | 305 base::debug::AsanCorruptHeap(); |
| 304 #endif | 306 #endif |
| 305 } | 307 } |
| 306 } | 308 } |
| 307 #endif // ADDRESS_SANITIZER || SYZYASAN | 309 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 308 | 310 |
| 309 static void MaybeHandleDebugURL(const GURL& url) { | 311 void MaybeHandleDebugURL(const GURL& url) { |
| 310 if (!url.SchemeIs(kChromeUIScheme)) | 312 if (!url.SchemeIs(kChromeUIScheme)) |
| 311 return; | 313 return; |
| 312 if (url == GURL(kChromeUICrashURL)) { | 314 if (url == GURL(kChromeUICrashURL)) { |
| 313 CrashIntentionally(); | 315 CrashIntentionally(); |
| 314 } else if (url == GURL(kChromeUIDumpURL)) { | 316 } else if (url == GURL(kChromeUIDumpURL)) { |
| 315 // This URL will only correctly create a crash dump file if content is | 317 // This URL will only correctly create a crash dump file if content is |
| 316 // hosted in a process that has correctly called | 318 // hosted in a process that has correctly called |
| 317 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation | 319 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation |
| 318 // of base::debug::DumpWithoutCrashing for more details. | 320 // of base::debug::DumpWithoutCrashing for more details. |
| 319 base::debug::DumpWithoutCrashing(); | 321 base::debug::DumpWithoutCrashing(); |
| 320 } else if (url == GURL(kChromeUIKillURL)) { | 322 } else if (url == GURL(kChromeUIKillURL)) { |
| 321 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); | 323 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
| 322 } else if (url == GURL(kChromeUIHangURL)) { | 324 } else if (url == GURL(kChromeUIHangURL)) { |
| 323 for (;;) { | 325 for (;;) { |
| 324 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 326 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 325 } | 327 } |
| 326 } else if (url == GURL(kChromeUIShorthangURL)) { | 328 } else if (url == GURL(kChromeUIShorthangURL)) { |
| 327 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 329 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 328 } | 330 } |
| 329 | 331 |
| 330 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 332 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
| 331 MaybeTriggerAsanError(url); | 333 MaybeTriggerAsanError(url); |
| 332 #endif // ADDRESS_SANITIZER || SYZYASAN | 334 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 333 } | 335 } |
| 334 | 336 |
| 335 // Returns false unless this is a top-level navigation. | 337 // Returns false unless this is a top-level navigation. |
| 336 static bool IsTopLevelNavigation(WebFrame* frame) { | 338 bool IsTopLevelNavigation(WebFrame* frame) { |
| 337 return frame->parent() == NULL; | 339 return frame->parent() == NULL; |
| 338 } | 340 } |
| 339 | 341 |
| 340 // Returns false unless this is a top-level navigation that crosses origins. | 342 // Returns false unless this is a top-level navigation that crosses origins. |
| 341 static bool IsNonLocalTopLevelNavigation(const GURL& url, | 343 bool IsNonLocalTopLevelNavigation(const GURL& url, |
| 342 WebFrame* frame, | 344 WebFrame* frame, |
| 343 WebNavigationType type, | 345 WebNavigationType type, |
| 344 bool is_form_post) { | 346 bool is_form_post) { |
| 345 if (!IsTopLevelNavigation(frame)) | 347 if (!IsTopLevelNavigation(frame)) |
| 346 return false; | 348 return false; |
| 347 | 349 |
| 348 // Navigations initiated within Webkit are not sent out to the external host | 350 // Navigations initiated within Webkit are not sent out to the external host |
| 349 // in the following cases. | 351 // in the following cases. |
| 350 // 1. The url scheme is not http/https | 352 // 1. The url scheme is not http/https |
| 351 // 2. The origin of the url and the opener is the same in which case the | 353 // 2. The origin of the url and the opener is the same in which case the |
| 352 // opener relationship is maintained. | 354 // opener relationship is maintained. |
| 353 // 3. Reloads/form submits/back forward navigations | 355 // 3. Reloads/form submits/back forward navigations |
| 354 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) | 356 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 extra_data = &kEmptyData; | 468 extra_data = &kEmptyData; |
| 467 CommonNavigationParams params; | 469 CommonNavigationParams params; |
| 468 params.url = request->url(); | 470 params.url = request->url(); |
| 469 params.referrer = Referrer( | 471 params.referrer = Referrer( |
| 470 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), | 472 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), |
| 471 request->referrerPolicy()); | 473 request->referrerPolicy()); |
| 472 params.transition = extra_data->transition_type(); | 474 params.transition = extra_data->transition_type(); |
| 473 return params; | 475 return params; |
| 474 } | 476 } |
| 475 | 477 |
| 478 #if !defined(OS_ANDROID) | |
| 479 media::Context3D GetSharedMainThreadContext3D() { | |
| 480 cc::ContextProvider* provider = | |
| 481 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | |
| 482 if (!provider) | |
| 483 return media::Context3D(); | |
| 484 return media::Context3D(provider->ContextGL(), provider->GrContext()); | |
| 485 } | |
| 486 #endif | |
| 487 | |
| 488 using CreateRenderFrameImpl = RenderFrameImpl* (*)(RenderViewImpl*, int32); | |
|
Charlie Reis
2014/12/09 22:08:23
Is there a reason for this to be in this CL? Clea
dshwang
2014/12/10 09:14:16
@jamesr requested it in https://codereview.chromiu
| |
| 489 CreateRenderFrameImpl g_create_render_frame_impl = nullptr; | |
| 490 | |
| 476 } // namespace | 491 } // namespace |
| 477 | 492 |
| 478 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) = | |
| 479 NULL; | |
| 480 | 493 |
| 481 // static | 494 // static |
| 482 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, | 495 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, |
| 483 int32 routing_id) { | 496 int32 routing_id) { |
| 484 DCHECK(routing_id != MSG_ROUTING_NONE); | 497 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 485 | 498 |
| 486 if (g_create_render_frame_impl) | 499 if (g_create_render_frame_impl) |
| 487 return g_create_render_frame_impl(render_view, routing_id); | 500 return g_create_render_frame_impl(render_view, routing_id); |
| 488 else | 501 else |
| 489 return new RenderFrameImpl(render_view, routing_id); | 502 return new RenderFrameImpl(render_view, routing_id); |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1749 #if defined(OS_ANDROID) | 1762 #if defined(OS_ANDROID) |
| 1750 return CreateAndroidWebMediaPlayer(url, client, initial_cdm); | 1763 return CreateAndroidWebMediaPlayer(url, client, initial_cdm); |
| 1751 #else | 1764 #else |
| 1752 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 1765 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1753 media::WebMediaPlayerParams params( | 1766 media::WebMediaPlayerParams params( |
| 1754 base::Bind(&ContentRendererClient::DeferMediaLoad, | 1767 base::Bind(&ContentRendererClient::DeferMediaLoad, |
| 1755 base::Unretained(GetContentClient()->renderer()), | 1768 base::Unretained(GetContentClient()->renderer()), |
| 1756 static_cast<RenderFrame*>(this)), | 1769 static_cast<RenderFrame*>(this)), |
| 1757 render_thread->GetAudioRendererMixerManager()->CreateInput( | 1770 render_thread->GetAudioRendererMixerManager()->CreateInput( |
| 1758 render_view_->routing_id_, routing_id_), | 1771 render_view_->routing_id_, routing_id_), |
| 1759 *render_thread->GetAudioHardwareConfig(), | 1772 *render_thread->GetAudioHardwareConfig(), new RenderMediaLog(), |
| 1760 new RenderMediaLog(), | |
| 1761 render_thread->GetGpuFactories(), | 1773 render_thread->GetGpuFactories(), |
| 1762 render_thread->GetMediaThreadTaskRunner(), | 1774 render_thread->GetMediaThreadTaskRunner(), |
| 1763 render_thread->compositor_message_loop_proxy(), | 1775 render_thread->compositor_message_loop_proxy(), |
| 1764 initial_cdm); | 1776 base::Bind(&GetSharedMainThreadContext3D), initial_cdm); |
| 1765 | 1777 |
| 1766 #if defined(ENABLE_PEPPER_CDMS) | 1778 #if defined(ENABLE_PEPPER_CDMS) |
| 1767 scoped_ptr<media::CdmFactory> cdm_factory( | 1779 scoped_ptr<media::CdmFactory> cdm_factory( |
| 1768 new RenderCdmFactory(base::Bind(&PepperCdmWrapperImpl::Create, frame))); | 1780 new RenderCdmFactory(base::Bind(&PepperCdmWrapperImpl::Create, frame))); |
| 1769 #else | 1781 #else |
| 1770 scoped_ptr<media::CdmFactory> cdm_factory(new RenderCdmFactory()); | 1782 scoped_ptr<media::CdmFactory> cdm_factory(new RenderCdmFactory()); |
| 1771 #endif | 1783 #endif |
| 1772 | 1784 |
| 1773 scoped_ptr<media::Renderer> media_renderer = | 1785 scoped_ptr<media::Renderer> media_renderer = |
| 1774 GetContentClient()->renderer()->CreateMediaRenderer( | 1786 GetContentClient()->renderer()->CreateMediaRenderer( |
| (...skipping 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4225 | 4237 |
| 4226 #if defined(ENABLE_BROWSER_CDMS) | 4238 #if defined(ENABLE_BROWSER_CDMS) |
| 4227 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4239 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 4228 if (!cdm_manager_) | 4240 if (!cdm_manager_) |
| 4229 cdm_manager_ = new RendererCdmManager(this); | 4241 cdm_manager_ = new RendererCdmManager(this); |
| 4230 return cdm_manager_; | 4242 return cdm_manager_; |
| 4231 } | 4243 } |
| 4232 #endif // defined(ENABLE_BROWSER_CDMS) | 4244 #endif // defined(ENABLE_BROWSER_CDMS) |
| 4233 | 4245 |
| 4234 } // namespace content | 4246 } // namespace content |
| OLD | NEW |