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

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

Issue 2250263004: [Extensions] Reduce string copy in renderer/ UserScript. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments 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 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 UserScript::RunLocation run_location) const { 97 UserScript::RunLocation run_location) const {
98 DCHECK_EQ(GetRunLocation(), run_location); 98 DCHECK_EQ(GetRunLocation(), run_location);
99 DCHECK(params_->is_javascript); 99 DCHECK(params_->is_javascript);
100 100
101 return std::vector<blink::WebScriptSource>( 101 return std::vector<blink::WebScriptSource>(
102 1, 102 1,
103 blink::WebScriptSource( 103 blink::WebScriptSource(
104 blink::WebString::fromUTF8(params_->code), params_->file_url)); 104 blink::WebString::fromUTF8(params_->code), params_->file_url));
105 } 105 }
106 106
107 std::vector<std::string> ProgrammaticScriptInjector::GetCssSources( 107 std::vector<blink::WebString> ProgrammaticScriptInjector::GetCssSources(
108 UserScript::RunLocation run_location) const { 108 UserScript::RunLocation run_location) const {
109 DCHECK_EQ(GetRunLocation(), run_location); 109 DCHECK_EQ(GetRunLocation(), run_location);
110 DCHECK(!params_->is_javascript); 110 DCHECK(!params_->is_javascript);
111 111
112 return std::vector<std::string>(1, params_->code); 112 return std::vector<blink::WebString>(
113 1, blink::WebString::fromUTF8(params_->code));
113 } 114 }
114 115
115 void ProgrammaticScriptInjector::GetRunInfo( 116 void ProgrammaticScriptInjector::GetRunInfo(
116 ScriptsRunInfo* scripts_run_info, 117 ScriptsRunInfo* scripts_run_info,
117 UserScript::RunLocation run_location) const { 118 UserScript::RunLocation run_location) const {
118 } 119 }
119 120
120 void ProgrammaticScriptInjector::OnInjectionComplete( 121 void ProgrammaticScriptInjector::OnInjectionComplete(
121 std::unique_ptr<base::Value> execution_result, 122 std::unique_ptr<base::Value> execution_result,
122 UserScript::RunLocation run_location, 123 UserScript::RunLocation run_location,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // frame deletions so nothing is left hanging). 177 // frame deletions so nothing is left hanging).
177 if (render_frame) { 178 if (render_frame) {
178 render_frame->Send( 179 render_frame->Send(
179 new ExtensionHostMsg_ExecuteCodeFinished( 180 new ExtensionHostMsg_ExecuteCodeFinished(
180 render_frame->GetRoutingID(), params_->request_id, 181 render_frame->GetRoutingID(), params_->request_id,
181 error, url_, results_)); 182 error, url_, results_));
182 } 183 }
183 } 184 }
184 185
185 } // namespace extensions 186 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/programmatic_script_injector.h ('k') | extensions/renderer/script_injection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698