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/chrome_v8_context.h" | 5 #include "chrome/renderer/extensions/chrome_v8_context.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void ChromeV8Context::Invalidate() { | 57 void ChromeV8Context::Invalidate() { |
58 if (v8_context_.get().IsEmpty()) | 58 if (v8_context_.get().IsEmpty()) |
59 return; | 59 return; |
60 if (module_system_) | 60 if (module_system_) |
61 module_system_->Invalidate(); | 61 module_system_->Invalidate(); |
62 web_frame_ = NULL; | 62 web_frame_ = NULL; |
63 v8_context_.reset(); | 63 v8_context_.reset(); |
64 } | 64 } |
65 | 65 |
66 std::string ChromeV8Context::GetExtensionID() { | 66 std::string ChromeV8Context::GetExtensionID() { |
67 return extension_ ? extension_->id() : std::string(); | 67 return extension_.get() ? extension_->id() : std::string(); |
68 } | 68 } |
69 | 69 |
70 // static | 70 // static |
71 v8::Handle<v8::Value> ChromeV8Context::GetOrCreateChromeHidden( | 71 v8::Handle<v8::Value> ChromeV8Context::GetOrCreateChromeHidden( |
72 v8::Handle<v8::Context> context) { | 72 v8::Handle<v8::Context> context) { |
73 v8::Local<v8::Object> global = context->Global(); | 73 v8::Local<v8::Object> global = context->Global(); |
74 v8::Local<v8::Value> hidden = global->GetHiddenValue( | 74 v8::Local<v8::Value> hidden = global->GetHiddenValue( |
75 v8::String::New(kChromeHidden)); | 75 v8::String::New(kChromeHidden)); |
76 | 76 |
77 if (hidden.IsEmpty() || hidden->IsUndefined()) { | 77 if (hidden.IsEmpty() || hidden->IsUndefined()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return ExtensionAPI::GetSharedInstance()->IsAnyFeatureAvailableToContext( | 158 return ExtensionAPI::GetSharedInstance()->IsAnyFeatureAvailableToContext( |
159 api_name, | 159 api_name, |
160 context_type_, | 160 context_type_, |
161 UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); | 161 UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); |
162 } | 162 } |
163 | 163 |
164 Feature::Availability ChromeV8Context::GetAvailability( | 164 Feature::Availability ChromeV8Context::GetAvailability( |
165 const std::string& api_name) { | 165 const std::string& api_name) { |
166 return ExtensionAPI::GetSharedInstance()->IsAvailable( | 166 return ExtensionAPI::GetSharedInstance()->IsAvailable( |
167 api_name, | 167 api_name, |
168 extension_, | 168 extension_.get(), |
169 context_type_, | 169 context_type_, |
170 UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); | 170 UserScriptSlave::GetDataSourceURLForFrame(web_frame_)); |
171 } | 171 } |
172 | 172 |
173 void ChromeV8Context::DispatchOnUnloadEvent() { | 173 void ChromeV8Context::DispatchOnUnloadEvent() { |
174 v8::HandleScope handle_scope; | 174 v8::HandleScope handle_scope; |
175 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); | 175 CallChromeHiddenMethod("dispatchOnUnload", 0, NULL, NULL); |
176 } | 176 } |
177 | 177 |
178 std::string ChromeV8Context::GetContextTypeDescription() { | 178 std::string ChromeV8Context::GetContextTypeDescription() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // string if a validation error has occured. | 214 // string if a validation error has occured. |
215 if (DCHECK_IS_ON()) { | 215 if (DCHECK_IS_ON()) { |
216 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 216 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
217 std::string error = *v8::String::AsciiValue(retval); | 217 std::string error = *v8::String::AsciiValue(retval); |
218 DCHECK(false) << error; | 218 DCHECK(false) << error; |
219 } | 219 } |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 } // namespace extensions | 223 } // namespace extensions |
OLD | NEW |