| 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
|
|
|