Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: extensions/browser/script_executor.cc

Issue 952473002: Add frameId to executeScript/insertCSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert change to error message, moved to https://codereview.chromium.org/945743003/ Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/script_executor.h" 5 #include "extensions/browser/script_executor.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 CHECK(web_contents_); 110 CHECK(web_contents_);
111 } 111 }
112 112
113 ScriptExecutor::~ScriptExecutor() { 113 ScriptExecutor::~ScriptExecutor() {
114 } 114 }
115 115
116 void ScriptExecutor::ExecuteScript(const std::string& extension_id, 116 void ScriptExecutor::ExecuteScript(const std::string& extension_id,
117 ScriptExecutor::ScriptType script_type, 117 ScriptExecutor::ScriptType script_type,
118 const std::string& code, 118 const std::string& code,
119 ScriptExecutor::FrameScope frame_scope, 119 ScriptExecutor::FrameScope frame_scope,
120 int frame_id,
120 ScriptExecutor::MatchAboutBlank about_blank, 121 ScriptExecutor::MatchAboutBlank about_blank,
121 UserScript::RunLocation run_at, 122 UserScript::RunLocation run_at,
122 ScriptExecutor::WorldType world_type, 123 ScriptExecutor::WorldType world_type,
123 ScriptExecutor::ProcessType process_type, 124 ScriptExecutor::ProcessType process_type,
124 const GURL& webview_src, 125 const GURL& webview_src,
125 const GURL& file_url, 126 const GURL& file_url,
126 bool user_gesture, 127 bool user_gesture,
127 ScriptExecutor::ResultType result_type, 128 ScriptExecutor::ResultType result_type,
128 const ExecuteScriptCallback& callback) { 129 const ExecuteScriptCallback& callback) {
129 // Don't execute if the extension has been unloaded. 130 // Don't execute if the extension has been unloaded.
130 const Extension* extension = 131 const Extension* extension =
131 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) 132 ExtensionRegistry::Get(web_contents_->GetBrowserContext())
132 ->enabled_extensions().GetByID(extension_id); 133 ->enabled_extensions().GetByID(extension_id);
133 if (!extension) 134 if (!extension)
134 return; 135 return;
135 136
136 ExtensionMsg_ExecuteCode_Params params; 137 ExtensionMsg_ExecuteCode_Params params;
137 params.request_id = next_request_id_++; 138 params.request_id = next_request_id_++;
138 params.extension_id = extension_id; 139 params.extension_id = extension_id;
139 params.is_javascript = (script_type == JAVASCRIPT); 140 params.is_javascript = (script_type == JAVASCRIPT);
140 params.code = code; 141 params.code = code;
141 params.all_frames = (frame_scope == ALL_FRAMES); 142 params.all_frames = (frame_scope == ALL_FRAMES);
143 params.frame_id = frame_id;
142 params.match_about_blank = (about_blank == MATCH_ABOUT_BLANK); 144 params.match_about_blank = (about_blank == MATCH_ABOUT_BLANK);
143 params.run_at = static_cast<int>(run_at); 145 params.run_at = static_cast<int>(run_at);
144 params.in_main_world = (world_type == MAIN_WORLD); 146 params.in_main_world = (world_type == MAIN_WORLD);
145 params.is_web_view = (process_type == WEB_VIEW_PROCESS); 147 params.is_web_view = (process_type == WEB_VIEW_PROCESS);
146 params.webview_src = webview_src; 148 params.webview_src = webview_src;
147 params.file_url = file_url; 149 params.file_url = file_url;
148 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); 150 params.wants_result = (result_type == JSON_SERIALIZED_RESULT);
149 params.user_gesture = user_gesture; 151 params.user_gesture = user_gesture;
150 152
151 // Handler handles IPCs and deletes itself on completion. 153 // Handler handles IPCs and deletes itself on completion.
152 new Handler(script_observers_, web_contents_, params, callback); 154 new Handler(script_observers_, web_contents_, params, callback);
153 } 155 }
154 156
155 } // namespace extensions 157 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698