Implement app process model isolation.

The process grouping logic is unfortunately duplicated in SiteInstance and
RenderView. URLs that are part of extension X's web extent get converted into
a pseudo URL of the form chrome-extension://X/path. This groups pages from an
extension app and its offline resources into the same process.

The rest is mostly plumbing and passing data around.

BUG=41273

Review URL: http://codereview.chromium.org/1735004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45384 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 38e068a..b7fb2af 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -474,6 +474,15 @@
   ExtensionProcessBindings::SetFunctionNames(names);
 }
 
+void RenderThread::OnExtensionExtentsUpdated(
+    const ViewMsg_ExtensionExtentsUpdated_Params& params) {
+  extension_extents_.resize(params.extension_apps.size());
+  for (size_t i = 0; i < params.extension_apps.size(); ++i) {
+    extension_extents_[i].extension_id = params.extension_apps[i].first;
+    extension_extents_[i].web_extent = params.extension_apps[i].second;
+  }
+}
+
 void RenderThread::OnPageActionsUpdated(
     const std::string& extension_id,
     const std::vector<std::string>& page_actions) {
@@ -548,6 +557,8 @@
                         OnExtensionMessageInvoke)
     IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames,
                         OnSetExtensionFunctionNames)
+    IPC_MESSAGE_HANDLER(ViewMsg_ExtensionExtentsUpdated,
+                        OnExtensionExtentsUpdated)
     IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
     IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache,
                         OnPurgePluginListCache)
@@ -1012,3 +1023,15 @@
     gpu_channel_ = NULL;
   }
 }
+
+std::string RenderThread::GetExtensionIdForURL(const GURL& url) {
+  if (url.SchemeIs(chrome::kExtensionScheme))
+    return url.host();
+
+  for (size_t i = 0; i < extension_extents_.size(); ++i) {
+    if (extension_extents_[i].web_extent.ContainsURL(url))
+      return extension_extents_[i].extension_id;
+  }
+
+  return std::string();
+}