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

Unified Diff: third_party/WebKit/Source/web/agent/sample/sample_agent.cc

Issue 2591803002: NOT FOR LANDING: Thread the needle through all webmodules.
Patch Set: AddEventListener sketched out. Created 3 years, 10 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
Index: third_party/WebKit/Source/web/agent/sample/sample_agent.cc
diff --git a/third_party/WebKit/Source/web/agent/sample/sample_agent.cc b/third_party/WebKit/Source/web/agent/sample/sample_agent.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3c6d0ac67a741512ce0e46d8fe3514cb82ef1065
--- /dev/null
+++ b/third_party/WebKit/Source/web/agent/sample/sample_agent.cc
@@ -0,0 +1,41 @@
+// Copyright 2017 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 "web/agent/sample/sample_agent.h"
+
+#include "web/api/document.h"
+#include "web/api/element.h"
+
+namespace web {
+
+SampleAgent::SampleAgent(Frame* frame) : Agent(frame) {
+ Element* element = frame->GetFunkyElement();
+ if (!element)
+ return;
+ element->AddEventListener(
+ "load", WTF::bind(&SampleAgent::Load, wrapPersistent(this)));
+ element->SetId("FUNKY!");
+ element->Before("YESS", "AWESOME!");
+ Document* document = frame->GetDocument();
+ if (!document)
+ return;
+ document->Write("THIS", "IS", "VARIADIC");
+
+ // Example of what you can do with the Variant.
+ auto current_script = document->GetCurrentScript();
+ if (!current_script)
+ return;
+
+ if (WTF::holds_alternative<blink::Member<SVGScriptElement>>(
+ current_script.value()))
+ return;
+
+ HTMLScriptElement* script =
+ WTF::get<blink::Member<HTMLScriptElement>>(current_script.value());
+ script->DoDummyThing();
+}
+
+void SampleAgent::Load(Event*) {}
+
+} // namespace web
« no previous file with comments | « third_party/WebKit/Source/web/agent/sample/sample_agent.h ('k') | third_party/WebKit/Source/web/api/frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698