Chromium Code Reviews| 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/object_backed_native_handler.h" | 5 #include "extensions/renderer/object_backed_native_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 // don't inject many bindings into worker threads. | 66 // don't inject many bindings into worker threads. |
| 67 // TODO(devlin): Figure out a way around this. | 67 // TODO(devlin): Figure out a way around this. |
| 68 if (content::WorkerThread::GetCurrentId() == 0) { | 68 if (content::WorkerThread::GetCurrentId() == 0) { |
| 69 ScriptContext* script_context = | 69 ScriptContext* script_context = |
| 70 ScriptContextSet::GetContextByV8Context(context); | 70 ScriptContextSet::GetContextByV8Context(context); |
| 71 v8::Local<v8::String> feature_name_string = | 71 v8::Local<v8::String> feature_name_string = |
| 72 feature_name_value->ToString(context).ToLocalChecked(); | 72 feature_name_value->ToString(context).ToLocalChecked(); |
| 73 std::string feature_name = *v8::String::Utf8Value(feature_name_string); | 73 std::string feature_name = *v8::String::Utf8Value(feature_name_string); |
| 74 // TODO(devlin): Eventually, we should fail if either script_context is null | 74 // TODO(devlin): Eventually, we should fail if either script_context is null |
| 75 // or feature_name is empty. | 75 // or feature_name is empty. |
| 76 if (script_context && | 76 if (script_context && !feature_name.empty()) { |
| 77 !feature_name.empty() && | 77 Feature::Availability availability = |
| 78 !script_context->GetAvailability(feature_name).is_available()) { | 78 script_context->GetAvailability(feature_name); |
| 79 return; | 79 if (!availability.is_available()) { |
| 80 DVLOG(1) << feature_name | |
| 81 << " is not available: " << availability.message(); | |
| 82 return; | |
| 83 } | |
|
asargent_no_longer_on_chrome
2016/04/11 17:30:14
Did you intend for this to get checked in or were
Devlin
2016/04/13 19:51:26
I wanted to check this one in (I think DVLOG is ok
asargent_no_longer_on_chrome
2016/04/13 23:02:40
Ok, just wasn't sure since a checked-in DVLOG is m
| |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 // This CHECK is *important*. Otherwise, we'll go around happily executing | 86 // This CHECK is *important*. Otherwise, we'll go around happily executing |
| 83 // something random. See crbug.com/548273. | 87 // something random. See crbug.com/548273. |
| 84 CHECK(handler_function_value->IsExternal()); | 88 CHECK(handler_function_value->IsExternal()); |
| 85 static_cast<HandlerFunction*>( | 89 static_cast<HandlerFunction*>( |
| 86 handler_function_value.As<v8::External>()->Value())->Run(args); | 90 handler_function_value.As<v8::External>()->Value())->Run(args); |
| 87 } | 91 } |
| 88 | 92 |
| 89 void ObjectBackedNativeHandler::RouteFunction( | 93 void ObjectBackedNativeHandler::RouteFunction( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 v8::Local<v8::Object> obj, | 189 v8::Local<v8::Object> obj, |
| 186 const char* key) { | 190 const char* key) { |
| 187 obj->DeletePrivate(context, | 191 obj->DeletePrivate(context, |
| 188 v8::Private::ForApi( | 192 v8::Private::ForApi( |
| 189 context->GetIsolate(), | 193 context->GetIsolate(), |
| 190 v8::String::NewFromUtf8(context->GetIsolate(), key))) | 194 v8::String::NewFromUtf8(context->GetIsolate(), key))) |
| 191 .FromJust(); | 195 .FromJust(); |
| 192 } | 196 } |
| 193 | 197 |
| 194 } // namespace extensions | 198 } // namespace extensions |
| OLD | NEW |