Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/renderer/extensions/schema_utils_native_handler.h" | |
| 6 | |
| 7 #include "chrome/renderer/extensions/chrome_v8_context.h" | |
| 8 #include "third_party/WebKit/public/platform/WebString.h" | |
| 9 #include "third_party/WebKit/public/web/WebScriptBindings.h" | |
| 10 #include "third_party/WebKit/public/web/WebSelector.h" | |
| 11 | |
| 12 namespace extensions { | |
| 13 | |
| 14 using WebKit::WebString; | |
| 15 | |
| 16 SchemaUtilsNativeHandler::SchemaUtilsNativeHandler(ChromeV8Context* context) | |
| 17 : ObjectBackedNativeHandler(context) { | |
| 18 RouteFunction( | |
| 19 "CanonicalizeCompoundSelector", | |
| 20 base::Bind(&SchemaUtilsNativeHandler::CanonicalizeCompoundSelector, | |
| 21 base::Unretained(this))); | |
| 22 } | |
| 23 | |
| 24 void SchemaUtilsNativeHandler::CanonicalizeCompoundSelector( | |
| 25 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 26 CHECK_EQ(args.Length(), 1); | |
| 27 v8::Local<v8::Value> arg_string; | |
|
Jeffrey Yasskin
2013/08/29 03:39:39
There's an implicit HandleScope around native func
not at google - send to devlin
2013/08/29 15:20:25
Yep.
| |
| 28 { | |
| 29 v8::TryCatch block; | |
| 30 arg_string = args[0]->ToString(); | |
| 31 if (block.HasCaught()){ | |
| 32 block.ReThrow(); | |
| 33 args.GetReturnValue().Set(v8::Undefined()); | |
|
not at google - send to devlin
2013/08/29 15:20:25
I imagine that setting a return value after throwi
Jeffrey Yasskin
2013/08/29 21:46:43
Yeah, must be, since forgetting to return didn't b
| |
| 34 } | |
|
not at google - send to devlin
2013/08/29 15:20:25
I would think that you'd rather throw a schema val
Jeffrey Yasskin
2013/08/29 21:46:43
Sure, done. The schema validator seems to check al
| |
| 35 } | |
| 36 WebString input_selector = | |
| 37 WebKit::WebScriptBindings::toWebString(arg_string.As<v8::String>()); | |
| 38 WebString output_selector = WebKit::canonicalizeSelector( | |
| 39 input_selector, WebKit::WebSelectorTypeCompound); | |
| 40 args.GetReturnValue().Set(WebKit::WebScriptBindings::toV8String( | |
| 41 output_selector, context()->v8_context()->GetIsolate())); | |
| 42 } | |
| 43 | |
| 44 } // namespace extensions | |
| OLD | NEW |