| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/module_system.h" | 5 #include "chrome/renderer/extensions/module_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup
pression.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedMicrotaskSup
pression.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 ModuleSystem::NativesEnabledScope::~NativesEnabledScope() { | 51 ModuleSystem::NativesEnabledScope::~NativesEnabledScope() { |
| 52 module_system_->natives_enabled_--; | 52 module_system_->natives_enabled_--; |
| 53 CHECK_GE(module_system_->natives_enabled_, 0); | 53 CHECK_GE(module_system_->natives_enabled_, 0); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 bool ModuleSystem::IsPresentInCurrentContext() { | 57 bool ModuleSystem::IsPresentInCurrentContext() { |
| 58 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); | 58 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); |
| 59 if (global.IsEmpty()) |
| 60 return false; |
| 59 v8::Handle<v8::Value> module_system = | 61 v8::Handle<v8::Value> module_system = |
| 60 global->GetHiddenValue(v8::String::New(kModuleSystem)); | 62 global->GetHiddenValue(v8::String::New(kModuleSystem)); |
| 61 return !module_system.IsEmpty() && !module_system->IsUndefined(); | 63 return !module_system.IsEmpty() && !module_system->IsUndefined(); |
| 62 } | 64 } |
| 63 | 65 |
| 64 // static | 66 // static |
| 65 void ModuleSystem::DumpException(const v8::TryCatch& try_catch) { | 67 void ModuleSystem::DumpException(const v8::TryCatch& try_catch) { |
| 66 v8::HandleScope handle_scope; | 68 v8::HandleScope handle_scope; |
| 67 | 69 |
| 68 v8::Handle<v8::Message> message(try_catch.Message()); | 70 v8::Handle<v8::Message> message(try_catch.Message()); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 v8::Handle<v8::String> right = v8::String::New("\n})"); | 291 v8::Handle<v8::String> right = v8::String::New("\n})"); |
| 290 return handle_scope.Close( | 292 return handle_scope.Close( |
| 291 v8::String::Concat(left, v8::String::Concat(source, right))); | 293 v8::String::Concat(left, v8::String::Concat(source, right))); |
| 292 } | 294 } |
| 293 | 295 |
| 294 v8::Handle<v8::Value> ModuleSystem::ThrowException(const std::string& message) { | 296 v8::Handle<v8::Value> ModuleSystem::ThrowException(const std::string& message) { |
| 295 return v8::ThrowException(v8::String::New(message.c_str())); | 297 return v8::ThrowException(v8::String::New(message.c_str())); |
| 296 } | 298 } |
| 297 | 299 |
| 298 } // extensions | 300 } // extensions |
| OLD | NEW |