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

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

Issue 1066563002: [Extensions] Don't pass empty value to V8Converter in OnJSInjectionCompleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/script_injection.h" 5 #include "extensions/renderer/script_injection.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 298
299 void ScriptInjection::OnJsInjectionCompleted( 299 void ScriptInjection::OnJsInjectionCompleted(
300 blink::WebLocalFrame* frame, 300 blink::WebLocalFrame* frame,
301 const blink::WebVector<v8::Local<v8::Value> >& results) { 301 const blink::WebVector<v8::Local<v8::Value> >& results) {
302 DCHECK(running_frames_ > 0); 302 DCHECK(running_frames_ > 0);
303 --running_frames_; 303 --running_frames_;
304 304
305 bool expects_results = injector_->ExpectsResults(); 305 bool expects_results = injector_->ExpectsResults();
306 if (expects_results) { 306 if (expects_results) {
307 scoped_ptr<base::Value> result; 307 scoped_ptr<base::Value> result;
308 if (!results.isEmpty()) { 308 if (!results.isEmpty() && !results[0].IsEmpty()) {
309 // Right now, we only support returning single results (per frame). 309 // Right now, we only support returning single results (per frame).
310 scoped_ptr<content::V8ValueConverter> v8_converter( 310 scoped_ptr<content::V8ValueConverter> v8_converter(
311 content::V8ValueConverter::create()); 311 content::V8ValueConverter::create());
312 // It's safe to always use the main world context when converting 312 // It's safe to always use the main world context when converting
313 // here. V8ValueConverterImpl shouldn't actually care about the 313 // here. V8ValueConverterImpl shouldn't actually care about the
314 // context scope, and it switches to v8::Object's creation context 314 // context scope, and it switches to v8::Object's creation context
315 // when encountered. 315 // when encountered.
316 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 316 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
317 result.reset(v8_converter->FromV8Value(results[0], context)); 317 result.reset(v8_converter->FromV8Value(results[0], context));
318 } 318 }
(...skipping 24 matching lines...) Expand all
343 std::vector<std::string> css_sources = 343 std::vector<std::string> css_sources =
344 injector_->GetCssSources(run_location_); 344 injector_->GetCssSources(run_location_);
345 for (std::vector<std::string>::const_iterator iter = css_sources.begin(); 345 for (std::vector<std::string>::const_iterator iter = css_sources.begin();
346 iter != css_sources.end(); 346 iter != css_sources.end();
347 ++iter) { 347 ++iter) {
348 frame->document().insertStyleSheet(blink::WebString::fromUTF8(*iter)); 348 frame->document().insertStyleSheet(blink::WebString::fromUTF8(*iter));
349 } 349 }
350 } 350 }
351 351
352 } // namespace extensions 352 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698