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

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

Issue 2819683002: [Extenisons Bindings] Don't throw unchecked errors; add console errors (Closed)
Patch Set: . Created 3 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
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_context.h" 5 #include "extensions/renderer/script_context.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 Feature::Availability availability = GetAvailability(name); 429 Feature::Availability availability = GetAvailability(name);
430 if (!availability.is_available()) { 430 if (!availability.is_available()) {
431 isolate()->ThrowException(v8::Exception::Error( 431 isolate()->ThrowException(v8::Exception::Error(
432 v8::String::NewFromUtf8(isolate(), availability.message().c_str()))); 432 v8::String::NewFromUtf8(isolate(), availability.message().c_str())));
433 return false; 433 return false;
434 } 434 }
435 435
436 return true; 436 return true;
437 } 437 }
438 438
439 void ScriptContext::AddMessageToConsole(content::ConsoleMessageLevel level,
jbroman 2017/04/19 17:45:05 Why have both this and extensions::console::AddMes
Devlin 2017/04/19 19:45:33 Good question. Removed.
440 const std::string& message) {
441 content::RenderFrame* render_frame = GetRenderFrame();
442 if (render_frame) {
443 render_frame->AddMessageToConsole(level, message);
444 } else {
445 // TODO(lazyboy/devlin): This can happen when this is the context for a
446 // service worker. blink::WebEmbeddedWorker has an AddMessageToConsole
447 // method that we could theoretically hook into.
448 LOG(WARNING) << "Could not log \"" << message
449 << "\": no render frame found";
450 }
451 }
452
439 std::string ScriptContext::GetDebugString() const { 453 std::string ScriptContext::GetDebugString() const {
440 DCHECK(thread_checker_.CalledOnValidThread()); 454 DCHECK(thread_checker_.CalledOnValidThread());
441 return base::StringPrintf( 455 return base::StringPrintf(
442 " extension id: %s\n" 456 " extension id: %s\n"
443 " frame: %p\n" 457 " frame: %p\n"
444 " URL: %s\n" 458 " URL: %s\n"
445 " context_type: %s\n" 459 " context_type: %s\n"
446 " effective extension id: %s\n" 460 " effective extension id: %s\n"
447 " effective context type: %s", 461 " effective context type: %s",
448 extension_.get() ? extension_->id().c_str() : "(none)", web_frame_, 462 extension_.get() ? extension_->id().c_str() : "(none)", web_frame_,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 v8::Local<v8::Value> argv[]) { 540 v8::Local<v8::Value> argv[]) {
527 return context_->CallFunction(function, argc, argv); 541 return context_->CallFunction(function, argc, argv);
528 } 542 }
529 543
530 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { 544 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() {
531 v8::HandleScope handle_scope(context_->isolate()); 545 v8::HandleScope handle_scope(context_->isolate());
532 return gin::PerContextData::From(context_->v8_context())->context_holder(); 546 return gin::PerContextData::From(context_->v8_context())->context_holder();
533 } 547 }
534 548
535 } // namespace extensions 549 } // namespace extensions
OLDNEW
« extensions/renderer/console.cc ('K') | « extensions/renderer/script_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698