summaryrefslogtreecommitdiffstats
path: root/extensions/browser/api
diff options
context:
space:
mode:
authorrob <rob@robwu.nl>2016-02-07 09:28:57 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-07 17:30:20 +0000
commit52277c872b368db45bc6d2f2bd9a4b7a0eb2ce8d (patch)
tree98016ba6f92be725a32ab1d8b773781441548753 /extensions/browser/api
parent057f009b6b02d1e94409a6d88702f37a07598de0 (diff)
downloadchromium_src-52277c872b368db45bc6d2f2bd9a4b7a0eb2ce8d.zip
chromium_src-52277c872b368db45bc6d2f2bd9a4b7a0eb2ce8d.tar.gz
chromium_src-52277c872b368db45bc6d2f2bd9a4b7a0eb2ce8d.tar.bz2
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}
Diffstat (limited to 'extensions/browser/api')
-rw-r--r--extensions/browser/api/execute_code_function.cc21
1 files changed, 9 insertions, 12 deletions
diff --git a/extensions/browser/api/execute_code_function.cc b/extensions/browser/api/execute_code_function.cc
index 0f98df3..53fcb44 100644
--- a/extensions/browser/api/execute_code_function.cc
+++ b/extensions/browser/api/execute_code_function.cc
@@ -8,6 +8,7 @@
#include "extensions/browser/api/execute_code_function.h"
#include "extensions/browser/component_extension_resource_manager.h"
+#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/file_reader.h"
#include "extensions/common/error_utils.h"
@@ -139,8 +140,11 @@ bool ExecuteCodeFunction::Execute(const std::string& code_string) {
ScriptExecutor::FrameScope frame_scope =
details_->all_frames.get() && *details_->all_frames
- ? ScriptExecutor::ALL_FRAMES
- : ScriptExecutor::TOP_FRAME;
+ ? ScriptExecutor::INCLUDE_SUB_FRAMES
+ : ScriptExecutor::SINGLE_FRAME;
+
+ int frame_id = details_->frame_id.get() ? *details_->frame_id
+ : ExtensionApiFrameIdMap::kTopFrameId;
ScriptExecutor::MatchAboutBlank match_about_blank =
details_->match_about_blank.get() && *details_->match_about_blank
@@ -163,18 +167,11 @@ bool ExecuteCodeFunction::Execute(const std::string& code_string) {
CHECK_NE(UserScript::UNDEFINED, run_at);
executor->ExecuteScript(
- host_id_,
- script_type,
- code_string,
- frame_scope,
- match_about_blank,
- run_at,
- ScriptExecutor::ISOLATED_WORLD,
+ host_id_, script_type, code_string, frame_scope, frame_id,
+ match_about_blank, run_at, ScriptExecutor::ISOLATED_WORLD,
IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS
: ScriptExecutor::DEFAULT_PROCESS,
- GetWebViewSrc(),
- file_url_,
- user_gesture_,
+ GetWebViewSrc(), file_url_, user_gesture_,
has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT
: ScriptExecutor::NO_RESULT,
base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this));