[Extensions] Call ActivateExtensionInProcess for all frames.

Previously, only extension main frames sent
ExtensionMsg_ActivateExtension, which led to extension OOPIFs missing
proper JS bindings in some cases, depending on whether the extension
was or was not previously activated by, for example, a background
page.  Now that --isolate-extensions is shipped, and extension
subframes always run in the extension process, we can activate all
extension frames, not just main frames.  This will ensure that
extension OOPIFs are always getting proper JS bindings.

Bug: 760341
Change-Id: If9d071e07672f9463d5725ef6e38cc076b188534
Reviewed-on: https://chromium-review.googlesource.com/709937
Reviewed-by: Devlin <[email protected]>
Commit-Queue: Alex Moshchuk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#508890}
diff --git a/chrome/browser/extensions/extension_bindings_apitest.cc b/chrome/browser/extensions/extension_bindings_apitest.cc
index 92d12e7..f1eae8c 100644
--- a/chrome/browser/extensions/extension_bindings_apitest.cc
+++ b/chrome/browser/extensions/extension_bindings_apitest.cc
@@ -331,6 +331,32 @@
       << message_;
 }
 
+// Verify that when a web frame embeds an extension subframe, and that subframe
+// is the only active portion of the extension, the subframe gets proper JS
+// bindings. See https://crbug.com/760341.
+IN_PROC_BROWSER_TEST_P(ExtensionBindingsApiTest,
+                       ExtensionSubframeGetsBindings) {
+  // Load an extension that does not have a background page or popup, so it
+  // won't be activated just yet.
+  const extensions::Extension* extension =
+      LoadExtension(test_data_dir_.AppendASCII("bindings")
+                        .AppendASCII("extension_subframe_gets_bindings"));
+  ASSERT_TRUE(extension);
+
+  // Navigate current tab to a web URL with a subframe.
+  content::WebContents* web_contents =
+      browser()->tab_strip_model()->GetActiveWebContents();
+  ui_test_utils::NavigateToURL(browser(),
+                               embedded_test_server()->GetURL("/iframe.html"));
+
+  // Navigate the subframe to the extension URL, which should activate the
+  // extension.
+  GURL extension_url(extension->GetResourceURL("page.html"));
+  ResultCatcher catcher;
+  content::NavigateIframeToURL(web_contents, "test", extension_url);
+  ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
+}
+
 // Run core bindings API tests with both native and JS-based bindings. This
 // ensures we have some minimum level of coverage while in the experimental
 // phase, when native bindings may be enabled on trunk but not at 100% stable.