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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 "web/agent/sample/sample_agent.h"
6
7 #include "web/api/document.h"
8 #include "web/api/element.h"
9
10 namespace web {
11
12 SampleAgent::SampleAgent(Frame* frame) : Agent(frame) {
13 Element* element = frame->GetFunkyElement();
14 if (!element)
15 return;
16 element->AddEventListener(
17 "load", WTF::bind(&SampleAgent::Load, wrapPersistent(this)));
18 element->SetId("FUNKY!");
19 element->Before("YESS", "AWESOME!");
20 Document* document = frame->GetDocument();
21 if (!document)
22 return;
23 document->Write("THIS", "IS", "VARIADIC");
24
25 // Example of what you can do with the Variant.
26 auto current_script = document->GetCurrentScript();
27 if (!current_script)
28 return;
29
30 if (WTF::holds_alternative<blink::Member<SVGScriptElement>>(
31 current_script.value()))
32 return;
33
34 HTMLScriptElement* script =
35 WTF::get<blink::Member<HTMLScriptElement>>(current_script.value());
36 script->DoDummyThing();
37 }
38
39 void SampleAgent::Load(Event*) {}
40
41 } // namespace web
OLDNEW
« 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