Fix Fullscreen Flash for out-of-process iframes.

This CL:
- fixes routing ID mismatch when sending ViewHostMsg_ShowFullscreenWidget
- fixes main frame URL access in CreatePepperFullscreenContainer
- allows swapped-out RVH to process OnShowFullscreenWidget
- fixes WebContentsImpl to track the fullscreen RenderWidgetHostView
using a {process_id, routing_id} pair, rather than just the widget
routing_id.

See https://crbug.com/593522#c3 for a slightly more detailed summary.

BUG=593522

Review-Url: https://codereview.chromium.org/1973813002
Cr-Commit-Position: refs/heads/master@{#393965}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 42e9847..801de04 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -105,6 +105,7 @@
 #include "content/public/common/bindings_policy.h"
 #include "content/public/common/browser_plugin_guest_mode.h"
 #include "content/public/common/browser_side_navigation_policy.h"
+#include "content/public/common/child_process_host.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/page_zoom.h"
@@ -404,6 +405,7 @@
       zoom_scroll_remainder_(0),
       render_view_message_source_(NULL),
       render_frame_message_source_(NULL),
+      fullscreen_widget_process_id_(ChildProcessHost::kInvalidUniqueID),
       fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
       fullscreen_widget_had_focus_at_shutdown_(false),
       is_subframe_(false),
@@ -855,10 +857,6 @@
     browser_plugin_embedder_->CancelGuestDialogs();
 }
 
-int WebContentsImpl::GetFullscreenWidgetRoutingID() const {
-  return fullscreen_widget_routing_id_;
-}
-
 void WebContentsImpl::ClosePage() {
   GetRenderViewHost()->ClosePage();
 }
@@ -876,8 +874,8 @@
 RenderWidgetHostView* WebContentsImpl::GetFullscreenRenderWidgetHostView()
     const {
   RenderWidgetHost* const widget_host =
-      RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(),
-                                   GetFullscreenWidgetRoutingID());
+      RenderWidgetHostImpl::FromID(fullscreen_widget_process_id_,
+                                   fullscreen_widget_routing_id_);
   return widget_host ? widget_host->GetView() : NULL;
 }
 
@@ -1679,12 +1677,15 @@
     return;
 
   if (render_widget_host &&
-      render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_) {
+      render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_ &&
+      render_widget_host->GetProcess()->GetID() ==
+          fullscreen_widget_process_id_) {
     if (delegate_ && delegate_->EmbedsFullscreenWidget())
       delegate_->ExitFullscreenModeForTab(this);
     FOR_EACH_OBSERVER(WebContentsObserver,
                       observers_,
                       DidDestroyFullscreenWidget());
+    fullscreen_widget_process_id_ = ChildProcessHost::kInvalidUniqueID;
     fullscreen_widget_routing_id_ = MSG_ROUTING_NONE;
     if (fullscreen_widget_had_focus_at_shutdown_)
       view_->RestoreFocus();
@@ -2176,6 +2177,8 @@
   if (is_fullscreen) {
     DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
     view_->StoreFocus();
+    fullscreen_widget_process_id_ =
+        widget_host_view->GetRenderWidgetHost()->GetProcess()->GetID();
     fullscreen_widget_routing_id_ = route_id;
     if (delegate_ && delegate_->EmbedsFullscreenWidget()) {
       widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView());