Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: chrome/renderer/extensions/css_native_handler.cc

Issue 23478003: Check and canonicalize CSS selectors before registering PageStateMatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix problems kalman noticed Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/extensions/css_native_handler.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/css_native_handler.cc
diff --git a/chrome/renderer/extensions/css_native_handler.cc b/chrome/renderer/extensions/css_native_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31f67c7824e9d9b2fc41f8cd80edd1863b36365e
--- /dev/null
+++ b/chrome/renderer/extensions/css_native_handler.cc
@@ -0,0 +1,35 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/css_native_handler.h"
+
+#include "chrome/renderer/extensions/chrome_v8_context.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "third_party/WebKit/public/web/WebScriptBindings.h"
+#include "third_party/WebKit/public/web/WebSelector.h"
+
+namespace extensions {
+
+using WebKit::WebString;
+
+CssNativeHandler::CssNativeHandler(ChromeV8Context* context)
+ : ObjectBackedNativeHandler(context) {
+ RouteFunction("CanonicalizeCompoundSelector",
+ base::Bind(&CssNativeHandler::CanonicalizeCompoundSelector,
+ base::Unretained(this)));
+}
+
+void CssNativeHandler::CanonicalizeCompoundSelector(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ CHECK_EQ(args.Length(), 1);
+ CHECK(args[0]->IsString());
+ WebString input_selector =
+ WebKit::WebScriptBindings::toWebString(args[0].As<v8::String>());
+ WebString output_selector = WebKit::canonicalizeSelector(
not at google - send to devlin 2013/08/29 22:24:04 I presume from reading the JS that this returns an
Jeffrey Yasskin 2013/08/29 23:18:49 It's commented in third_party/WebKit/public/web/We
not at google - send to devlin 2013/08/29 23:24:29 I didn't see it in the header file and :O webkit h
+ input_selector, WebKit::WebSelectorTypeCompound);
+ args.GetReturnValue().Set(WebKit::WebScriptBindings::toV8String(
+ output_selector, context()->v8_context()->GetIsolate()));
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/css_native_handler.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698