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

Side by Side Diff: extensions/renderer/programmatic_script_injector.cc

Issue 2116613002: Prevent duplicate content script injection defined in manifest.json (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed code review on patch 8 Created 4 years, 5 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/renderer/programmatic_script_injector.h" 5 #include "extensions/renderer/programmatic_script_injector.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DCHECK_EQ(injection_host->id().type(), HostID::EXTENSIONS); 87 DCHECK_EQ(injection_host->id().type(), HostID::EXTENSIONS);
88 88
89 return injection_host->CanExecuteOnFrame( 89 return injection_host->CanExecuteOnFrame(
90 effective_document_url, 90 effective_document_url,
91 content::RenderFrame::FromWebFrame(frame), 91 content::RenderFrame::FromWebFrame(frame),
92 tab_id, 92 tab_id,
93 true /* is_declarative */); 93 true /* is_declarative */);
94 } 94 }
95 95
96 std::vector<blink::WebScriptSource> ProgrammaticScriptInjector::GetJsSources( 96 std::vector<blink::WebScriptSource> ProgrammaticScriptInjector::GetJsSources(
97 UserScript::RunLocation run_location) const { 97 UserScript::RunLocation run_location,
98 ScriptsRunInfo* scripts_run_info) const {
98 DCHECK_EQ(GetRunLocation(), run_location); 99 DCHECK_EQ(GetRunLocation(), run_location);
99 DCHECK(params_->is_javascript); 100 DCHECK(params_->is_javascript);
100 101
101 return std::vector<blink::WebScriptSource>( 102 return std::vector<blink::WebScriptSource>(
102 1, 103 1,
103 blink::WebScriptSource( 104 blink::WebScriptSource(
104 blink::WebString::fromUTF8(params_->code), params_->file_url)); 105 blink::WebString::fromUTF8(params_->code), params_->file_url));
105 } 106 }
106 107
107 std::vector<std::string> ProgrammaticScriptInjector::GetCssSources( 108 std::vector<std::string> ProgrammaticScriptInjector::GetCssSources(
108 UserScript::RunLocation run_location) const { 109 UserScript::RunLocation run_location,
110 ScriptsRunInfo* scripts_run_info) const {
109 DCHECK_EQ(GetRunLocation(), run_location); 111 DCHECK_EQ(GetRunLocation(), run_location);
110 DCHECK(!params_->is_javascript); 112 DCHECK(!params_->is_javascript);
111 113
112 return std::vector<std::string>(1, params_->code); 114 return std::vector<std::string>(1, params_->code);
113 } 115 }
114 116
115 void ProgrammaticScriptInjector::GetRunInfo( 117 void ProgrammaticScriptInjector::GetRunInfo(
116 ScriptsRunInfo* scripts_run_info, 118 ScriptsRunInfo* scripts_run_info,
117 UserScript::RunLocation run_location) const { 119 UserScript::RunLocation run_location) const {
118 } 120 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // frame deletions so nothing is left hanging). 178 // frame deletions so nothing is left hanging).
177 if (render_frame) { 179 if (render_frame) {
178 render_frame->Send( 180 render_frame->Send(
179 new ExtensionHostMsg_ExecuteCodeFinished( 181 new ExtensionHostMsg_ExecuteCodeFinished(
180 render_frame->GetRoutingID(), params_->request_id, 182 render_frame->GetRoutingID(), params_->request_id,
181 error, url_, results_)); 183 error, url_, results_));
182 } 184 }
183 } 185 }
184 186
185 } // namespace extensions 187 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/programmatic_script_injector.h ('k') | extensions/renderer/script_injection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698