[Extensions] Don't send activation messages for themes

Renderer shouldn't know about themes. Don't send activation or unloaded
messages for them. Normally this wouldn't be a problem, but it can be
if someone chooses to load up a theme file (e.g. a manifest) in a tab.

BUG=528026

Review-Url: https://codereview.chromium.org/2214203002
Cr-Commit-Position: refs/heads/master@{#409936}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index e738185..53de0608 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1106,7 +1106,7 @@
       content::Source<Profile>(profile_),
       content::Details<UnloadedExtensionInfo>(&details));
 
-  renderer_helper_->OnExtensionUnloaded(extension->id());
+  renderer_helper_->OnExtensionUnloaded(*extension);
 
   system_->UnregisterExtensionWithRequestContexts(extension->id(), reason);
 
diff --git a/chrome/browser/extensions/renderer_initialization_browsertest.cc b/chrome/browser/extensions/renderer_initialization_browsertest.cc
index 4664435..63fbe88 100644
--- a/chrome/browser/extensions/renderer_initialization_browsertest.cc
+++ b/chrome/browser/extensions/renderer_initialization_browsertest.cc
@@ -37,4 +37,22 @@
   ASSERT_FALSE(web_contents->IsCrashed());
 }
 
+// Tests that loading a file from a theme in a tab doesn't crash anything.
+// Another part of crbug.com/528026 and related.
+IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest,
+                       TestRendererInitializationWithThemesTab) {
+  const Extension* extension = LoadExtensionWithFlags(
+      test_data_dir_.AppendASCII("theme"), kFlagAllowOldManifestVersions);
+  ASSERT_TRUE(extension);
+  ASSERT_TRUE(extension->is_theme());
+  GURL url = extension->GetResourceURL("manifest.json");
+  ui_test_utils::NavigateToURL(browser(), url);
+  content::WebContents* web_contents =
+      browser()->tab_strip_model()->GetActiveWebContents();
+  // Wait for the web contents to stop loading.
+  content::WaitForLoadStop(web_contents);
+  EXPECT_EQ(url, web_contents->GetLastCommittedURL());
+  ASSERT_FALSE(web_contents->IsCrashed());
+}
+
 }  // namespace extensions