Add frameId to chrome.tabs.executeScript/insertCSS

- Re-implemented https://codereview.chromium.org/952473002/, with all
  checks at the browser side instead of just the renderer.

- Use the last committed URL for checking permissions instead of the
  visible URL. As a result, executeScript/insertCSS will now succeed in
  frames where the currently committed page is scriptable by extensions,
  but the target of the pending navigation is is not.

- ExecuteScript: Do not send IPC to non-live frames (they're not going
  to reply anyway).

- Include URL in the error if the extension has the tabs permission
  (follow-up to TODO from https://codereview.chromium.org/1414223005).

BUG=63979,551626
TEST=./browser_tests --gtest_filter=ExecuteScriptApiTest.*
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation

Review URL: https://codereview.chromium.org/1628423002

Cr-Commit-Position: refs/heads/master@{#374057}
diff --git a/extensions/browser/script_executor.h b/extensions/browser/script_executor.h
index 4f81b78f..25e6c54 100644
--- a/extensions/browser/script_executor.h
+++ b/extensions/browser/script_executor.h
@@ -44,8 +44,8 @@
 
   // The scope of the script injection across the frames.
   enum FrameScope {
-    TOP_FRAME,
-    ALL_FRAMES,
+    SINGLE_FRAME,
+    INCLUDE_SUB_FRAMES,
   };
 
   // Whether to insert the script in about: frames when its origin matches
@@ -82,6 +82,10 @@
   // Executes a script. The arguments match ExtensionMsg_ExecuteCode_Params in
   // extension_messages.h (request_id is populated automatically).
   //
+  // The script will be executed in the frame identified by |frame_id| (which is
+  // an extension API frame ID). If |frame_scope| is INCLUDE_SUB_FRAMES, then
+  // the script will also be executed in all descendants of the frame.
+  //
   // |callback| will always be called even if the IPC'd renderer is destroyed
   // before a response is received (in this case the callback will be with a
   // failure and appropriate error message).
@@ -89,6 +93,7 @@
                      ScriptType script_type,
                      const std::string& code,
                      FrameScope frame_scope,
+                     int frame_id,
                      MatchAboutBlank match_about_blank,
                      UserScript::RunLocation run_at,
                      WorldType world_type,