OLD | NEW |
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
319 if (!result.get()) | 319 if (!result.get()) |
320 result.reset(base::Value::CreateNullValue()); | 320 result = base::Value::CreateNullValue(); |
321 // We guarantee that the main frame's result is at the first index, but | 321 // We guarantee that the main frame's result is at the first index, but |
322 // any sub frames results do not have guaranteed order. | 322 // any sub frames results do not have guaranteed order. |
323 execution_results_->Insert( | 323 execution_results_->Insert( |
324 frame == web_frame_ ? 0 : execution_results_->GetSize(), | 324 frame == web_frame_ ? 0 : execution_results_->GetSize(), |
325 result.release()); | 325 result.release()); |
326 } | 326 } |
327 TryToFinish(); | 327 TryToFinish(); |
328 } | 328 } |
329 | 329 |
330 void ScriptInjection::TryToFinish() { | 330 void ScriptInjection::TryToFinish() { |
(...skipping 12 matching lines...) Expand all Loading... |
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 |
OLD | NEW |