[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 117afcf | 2013-08-30 02:38:09 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 5 | #include "extensions/renderer/css_native_handler.h" |
[email protected] | 117afcf | 2013-08-30 02:38:09 | [diff] [blame] | 6 | |
[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 7 | #include "extensions/renderer/script_context.h" |
[email protected] | 117afcf | 2013-08-30 02:38:09 | [diff] [blame] | 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 | |||||
[email protected] | a1221aea | 2013-11-07 01:31:30 | [diff] [blame] | 14 | using blink::WebString; |
[email protected] | 117afcf | 2013-08-30 02:38:09 | [diff] [blame] | 15 | |
[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 16 | CssNativeHandler::CssNativeHandler(ScriptContext* context) |
[email protected] | 117afcf | 2013-08-30 02:38:09 | [diff] [blame] | 17 | : ObjectBackedNativeHandler(context) { |
18 | RouteFunction("CanonicalizeCompoundSelector", | ||||
19 | base::Bind(&CssNativeHandler::CanonicalizeCompoundSelector, | ||||
20 | base::Unretained(this))); | ||||
21 | } | ||||
22 | |||||
23 | void CssNativeHandler::CanonicalizeCompoundSelector( | ||||
24 | const v8::FunctionCallbackInfo<v8::Value>& args) { | ||||
25 | CHECK_EQ(args.Length(), 1); | ||||
26 | CHECK(args[0]->IsString()); | ||||
27 | WebString input_selector = | ||||
[email protected] | a1221aea | 2013-11-07 01:31:30 | [diff] [blame] | 28 | blink::WebScriptBindings::toWebString(args[0].As<v8::String>()); |
29 | WebString output_selector = blink::canonicalizeSelector( | ||||
30 | input_selector, blink::WebSelectorTypeCompound); | ||||
31 | args.GetReturnValue().Set(blink::WebScriptBindings::toV8String( | ||||
[email protected] | 117afcf | 2013-08-30 02:38:09 | [diff] [blame] | 32 | output_selector, context()->v8_context()->GetIsolate())); |
33 | } | ||||
34 | |||||
35 | } // namespace extensions |