| 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_context.h" | 5 #include "extensions/renderer/script_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 Feature::Context context_type) | 35 Feature::Context context_type) |
| 36 : v8_context_(v8_context), | 36 : v8_context_(v8_context), |
| 37 web_frame_(web_frame), | 37 web_frame_(web_frame), |
| 38 extension_(extension), | 38 extension_(extension), |
| 39 context_type_(context_type), | 39 context_type_(context_type), |
| 40 safe_builtins_(this), | 40 safe_builtins_(this), |
| 41 isolate_(v8_context->GetIsolate()) { | 41 isolate_(v8_context->GetIsolate()) { |
| 42 VLOG(1) << "Created context:\n" | 42 VLOG(1) << "Created context:\n" |
| 43 << " extension id: " << GetExtensionID() << "\n" | 43 << " extension id: " << GetExtensionID() << "\n" |
| 44 << " frame: " << web_frame_ << "\n" | 44 << " frame: " << web_frame_ << "\n" |
| 45 << " URL: " << GetURL() << "\n" |
| 45 << " context type: " << GetContextTypeDescription(); | 46 << " context type: " << GetContextTypeDescription(); |
| 46 gin::PerContextData::From(v8_context)->set_runner(this); | 47 gin::PerContextData::From(v8_context)->set_runner(this); |
| 47 } | 48 } |
| 48 | 49 |
| 49 ScriptContext::~ScriptContext() { | 50 ScriptContext::~ScriptContext() { |
| 50 VLOG(1) << "Destroyed context for extension\n" | 51 VLOG(1) << "Destroyed context for extension\n" |
| 51 << " extension id: " << GetExtensionID(); | 52 << " extension id: " << GetExtensionID(); |
| 52 Invalidate(); | 53 Invalidate(); |
| 53 } | 54 } |
| 54 | 55 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 case Feature::BLESSED_EXTENSION_CONTEXT: | 131 case Feature::BLESSED_EXTENSION_CONTEXT: |
| 131 return "BLESSED_EXTENSION"; | 132 return "BLESSED_EXTENSION"; |
| 132 case Feature::UNBLESSED_EXTENSION_CONTEXT: | 133 case Feature::UNBLESSED_EXTENSION_CONTEXT: |
| 133 return "UNBLESSED_EXTENSION"; | 134 return "UNBLESSED_EXTENSION"; |
| 134 case Feature::CONTENT_SCRIPT_CONTEXT: | 135 case Feature::CONTENT_SCRIPT_CONTEXT: |
| 135 return "CONTENT_SCRIPT"; | 136 return "CONTENT_SCRIPT"; |
| 136 case Feature::WEB_PAGE_CONTEXT: | 137 case Feature::WEB_PAGE_CONTEXT: |
| 137 return "WEB_PAGE"; | 138 return "WEB_PAGE"; |
| 138 case Feature::BLESSED_WEB_PAGE_CONTEXT: | 139 case Feature::BLESSED_WEB_PAGE_CONTEXT: |
| 139 return "BLESSED_WEB_PAGE"; | 140 return "BLESSED_WEB_PAGE"; |
| 141 case Feature::WEBUI_CONTEXT: |
| 142 return "WEBUI"; |
| 140 } | 143 } |
| 141 NOTREACHED(); | 144 NOTREACHED(); |
| 142 return std::string(); | 145 return std::string(); |
| 143 } | 146 } |
| 144 | 147 |
| 145 GURL ScriptContext::GetURL() const { | 148 GURL ScriptContext::GetURL() const { |
| 146 return web_frame() ? GetDataSourceURLForFrame(web_frame()) : GURL(); | 149 return web_frame() ? GetDataSourceURLForFrame(web_frame()) : GURL(); |
| 147 } | 150 } |
| 148 | 151 |
| 149 bool ScriptContext::IsAnyFeatureAvailableToContext(const Feature& api) { | 152 bool ScriptContext::IsAnyFeatureAvailableToContext(const Feature& api) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 v8::Handle<v8::Value> argv[]) { | 237 v8::Handle<v8::Value> argv[]) { |
| 235 return CallFunction(function, argc, argv); | 238 return CallFunction(function, argc, argv); |
| 236 } | 239 } |
| 237 | 240 |
| 238 gin::ContextHolder* ScriptContext::GetContextHolder() { | 241 gin::ContextHolder* ScriptContext::GetContextHolder() { |
| 239 v8::HandleScope handle_scope(isolate()); | 242 v8::HandleScope handle_scope(isolate()); |
| 240 return gin::PerContextData::From(v8_context())->context_holder(); | 243 return gin::PerContextData::From(v8_context())->context_holder(); |
| 241 } | 244 } |
| 242 | 245 |
| 243 } // namespace extensions | 246 } // namespace extensions |
| OLD | NEW |