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

Unified Diff: extensions/renderer/user_script_injector.cc

Issue 2227193002: Make UserScript non-copyable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove browser/renderer specific file impl as it is not helping much Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: extensions/renderer/user_script_injector.cc
diff --git a/extensions/renderer/user_script_injector.cc b/extensions/renderer/user_script_injector.cc
index 21a59eac30fa4bd3e03c928090db5f13e6189ed9..0a13e2283aaa6830eac1d1ce9688d2c19881c313 100644
--- a/extensions/renderer/user_script_injector.cc
+++ b/extensions/renderer/user_script_injector.cc
@@ -101,7 +101,7 @@ UserScriptInjector::~UserScriptInjector() {
void UserScriptInjector::OnUserScriptsUpdated(
const std::set<HostID>& changed_hosts,
- const std::vector<std::unique_ptr<UserScript>>& scripts) {
+ const UserScriptList& scripts) {
// If the host causing this injection changed, then this injection
// will be removed, and there's no guarantee the backing script still exists.
if (changed_hosts.count(host_id_) > 0) {
@@ -202,13 +202,8 @@ std::vector<blink::WebScriptSource> UserScriptInjector::GetJsSources(
DCHECK_EQ(script_->run_location(), run_location);
- const UserScript::FileList& js_scripts = script_->js_scripts();
-
- for (UserScript::FileList::const_iterator iter = js_scripts.begin();
- iter != js_scripts.end();
- ++iter) {
+ for (const std::unique_ptr<UserScript::File>& iter : script_->js_scripts()) {
Devlin 2016/08/17 16:39:31 s/iter/file
lazyboy 2016/08/17 18:55:52 Done.
std::string content = iter->GetContent().as_string();
Devlin 2016/08/17 16:39:31 wait. Doesn't this mean that we're performing *an
lazyboy 2016/08/17 18:55:52 As discussed offline, there're actually two copies
-
// We add this dumb function wrapper for user scripts to emulate what
// Greasemonkey does.
if (script_->emulate_greasemonkey()) {
@@ -235,12 +230,8 @@ std::vector<std::string> UserScriptInjector::GetCssSources(
if (!script_)
return sources;
- const UserScript::FileList& css_scripts = script_->css_scripts();
- for (UserScript::FileList::const_iterator iter = css_scripts.begin();
- iter != css_scripts.end();
- ++iter) {
+ for (const std::unique_ptr<UserScript::File>& iter : script_->css_scripts())
sources.push_back(iter->GetContent().as_string());
Devlin 2016/08/17 16:39:31 ditto :(
lazyboy 2016/08/17 18:55:52 Added TODO
- }
return sources;
}
@@ -253,9 +244,7 @@ void UserScriptInjector::GetRunInfo(
if (ShouldInjectJs(run_location)) {
const UserScript::FileList& js_scripts = script_->js_scripts();
scripts_run_info->num_js += js_scripts.size();
- for (UserScript::FileList::const_iterator iter = js_scripts.begin();
- iter != js_scripts.end();
- ++iter) {
+ for (const std::unique_ptr<UserScript::File>& iter : js_scripts) {
scripts_run_info->executing_scripts[host_id_.id()].insert(
iter->url().path());
}

Powered by Google App Engine
This is Rietveld 408576698