Extensions: Ensure Devtools frames are correctly tracked by ExtensionWebContentsObserver.

Currently ExtensionWebContentsObserver(EWCO) does not get RenderFrameCreated
notification for the Devtools main frame. This happens because the frame is
created before the EWCO construction. Also, at the time of
ExtensionWebContentsObserver construction, this frame happens to be the
speculative RenderFrameHost of the root FrameTreeNode and hence is not
enumerated via WebContents::ForEachFrame. To fix this, also track the new hosts
seen through the WebContentsObserver::RenderFrameHostChanged method. Add a
browser test for the same.

Also, rename ExtensionAPIFrameIdMap::OnRenderFrameCreated to
InitializeRenderFrameHost to clarify the new usage.

BUG=817075

Change-Id: I81213f0441162a483fda9191991763a3fee65905
Reviewed-on: https://chromium-review.googlesource.com/942684
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540978}
5 files changed