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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void ChromeV8Context::Invalidate() { | 56 void ChromeV8Context::Invalidate() { |
57 if (v8_context_.get().IsEmpty()) | 57 if (v8_context_.get().IsEmpty()) |
58 return; | 58 return; |
59 if (module_system_) | 59 if (module_system_) |
60 module_system_->Invalidate(); | 60 module_system_->Invalidate(); |
61 web_frame_ = NULL; | 61 web_frame_ = NULL; |
62 v8_context_.reset(); | 62 v8_context_.reset(); |
63 } | 63 } |
64 | 64 |
65 std::string ChromeV8Context::GetExtensionID() { | 65 std::string ChromeV8Context::GetExtensionID() { |
66 return extension_ ? extension_->id() : ""; | 66 return extension_ ? extension_->id() : std::string(); |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 v8::Handle<v8::Value> ChromeV8Context::GetOrCreateChromeHidden( | 70 v8::Handle<v8::Value> ChromeV8Context::GetOrCreateChromeHidden( |
71 v8::Handle<v8::Context> context) { | 71 v8::Handle<v8::Context> context) { |
72 v8::Local<v8::Object> global = context->Global(); | 72 v8::Local<v8::Object> global = context->Global(); |
73 v8::Local<v8::Value> hidden = global->GetHiddenValue( | 73 v8::Local<v8::Value> hidden = global->GetHiddenValue( |
74 v8::String::New(kChromeHidden)); | 74 v8::String::New(kChromeHidden)); |
75 | 75 |
76 if (hidden.IsEmpty() || hidden->IsUndefined()) { | 76 if (hidden.IsEmpty() || hidden->IsUndefined()) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 std::string ChromeV8Context::GetContextTypeDescription() { | 181 std::string ChromeV8Context::GetContextTypeDescription() { |
182 switch (context_type_) { | 182 switch (context_type_) { |
183 case Feature::UNSPECIFIED_CONTEXT: return "UNSPECIFIED"; | 183 case Feature::UNSPECIFIED_CONTEXT: return "UNSPECIFIED"; |
184 case Feature::BLESSED_EXTENSION_CONTEXT: return "BLESSED_EXTENSION"; | 184 case Feature::BLESSED_EXTENSION_CONTEXT: return "BLESSED_EXTENSION"; |
185 case Feature::UNBLESSED_EXTENSION_CONTEXT: return "UNBLESSED_EXTENSION"; | 185 case Feature::UNBLESSED_EXTENSION_CONTEXT: return "UNBLESSED_EXTENSION"; |
186 case Feature::CONTENT_SCRIPT_CONTEXT: return "CONTENT_SCRIPT"; | 186 case Feature::CONTENT_SCRIPT_CONTEXT: return "CONTENT_SCRIPT"; |
187 case Feature::WEB_PAGE_CONTEXT: return "WEB_PAGE"; | 187 case Feature::WEB_PAGE_CONTEXT: return "WEB_PAGE"; |
188 } | 188 } |
189 NOTREACHED(); | 189 NOTREACHED(); |
190 return ""; | 190 return std::string(); |
191 } | 191 } |
192 | 192 |
193 ChromeV8Context* ChromeV8Context::GetContext() { | 193 ChromeV8Context* ChromeV8Context::GetContext() { |
194 return this; | 194 return this; |
195 } | 195 } |
196 | 196 |
197 void ChromeV8Context::OnResponseReceived(const std::string& name, | 197 void ChromeV8Context::OnResponseReceived(const std::string& name, |
198 int request_id, | 198 int request_id, |
199 bool success, | 199 bool success, |
200 const base::ListValue& response, | 200 const base::ListValue& response, |
(...skipping 16 matching lines...) Expand all Loading... |
217 // string if a validation error has occured. | 217 // string if a validation error has occured. |
218 if (DCHECK_IS_ON()) { | 218 if (DCHECK_IS_ON()) { |
219 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 219 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
220 std::string error = *v8::String::AsciiValue(retval); | 220 std::string error = *v8::String::AsciiValue(retval); |
221 DCHECK(false) << error; | 221 DCHECK(false) << error; |
222 } | 222 } |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 } // namespace extensions | 226 } // namespace extensions |
OLD | NEW |