Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "components/copyless_paste/renderer/copyless_paste_agent.h" | |
| 6 | |
| 7 #include "content/public/renderer/render_frame.h" | |
| 8 #include "third_party/WebKit/public/web/WebDocument.h" | |
| 9 #include "third_party/WebKit/public/web/WebElement.h" | |
| 10 #include "third_party/WebKit/public/web/WebLocalFrame.h" | |
| 11 | |
| 12 namespace copyless_paste { | |
| 13 | |
| 14 using namespace blink; | |
|
dcheng
2017/04/02 05:50:34
Nit: forbidden by the Google C++ style guide
| |
| 15 | |
| 16 CopylessPasteAgent::CopylessPasteAgent(content::RenderFrame* render_frame) | |
| 17 : RenderFrameObserver(render_frame) {} | |
| 18 | |
| 19 void CopylessPasteAgent::DidMeaningfulLayout(WebMeaningfulLayout layout_type) { | |
| 20 if (layout_type != WebMeaningfulLayout::FinishedParsing) { | |
| 21 return; | |
| 22 } | |
| 23 DCHECK(render_frame()); | |
| 24 if (!render_frame()->IsMainFrame()) | |
|
dcheng
2017/04/02 05:50:34
Nit: we should just not install a RFO for a non-ma
| |
| 25 return; | |
| 26 DCHECK(render_frame()->GetWebFrame()); | |
| 27 WebDocument doc = render_frame()->GetWebFrame()->document(); | |
| 28 if (doc.isNull() || doc.body().isNull()) | |
|
dcheng
2017/04/02 05:50:34
If we're attached, WebDocument should never be nul
| |
| 29 return; | |
| 30 if (!GURL(doc.url()).SchemeIsHTTPOrHTTPS()) | |
| 31 return; | |
| 32 | |
| 33 doc.extractMetadata(); | |
| 34 } | |
| 35 | |
| 36 CopylessPasteAgent::~CopylessPasteAgent() {} | |
| 37 | |
| 38 void CopylessPasteAgent::OnDestruct() { | |
| 39 delete this; | |
| 40 } | |
| 41 | |
| 42 } // namespace copyless_paste | |
| OLD | NEW |