OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/renderer/content_watcher.h" | 5 #include "extensions/renderer/content_watcher.h" |
6 | 6 |
7 #include "content/public/renderer/render_view.h" | 7 #include "content/public/renderer/render_view.h" |
8 #include "content/public/renderer/render_view_visitor.h" | 8 #include "content/public/renderer/render_view_visitor.h" |
9 #include "extensions/common/extension_messages.h" | 9 #include "extensions/common/extension_messages.h" |
10 #include "third_party/WebKit/public/web/WebDocument.h" | 10 #include "third_party/WebKit/public/web/WebDocument.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 css_selectors_.swap(new_css_selectors); | 40 css_selectors_.swap(new_css_selectors); |
41 | 41 |
42 // Tell each frame's document about the new set of watched selectors. These | 42 // Tell each frame's document about the new set of watched selectors. These |
43 // will trigger calls to DidMatchCSS after Blink has a chance to apply the new | 43 // will trigger calls to DidMatchCSS after Blink has a chance to apply the new |
44 // style, which will in turn notify the browser about the changes. | 44 // style, which will in turn notify the browser about the changes. |
45 struct WatchSelectors : public content::RenderViewVisitor { | 45 struct WatchSelectors : public content::RenderViewVisitor { |
46 explicit WatchSelectors(const WebVector<WebString>& css_selectors) | 46 explicit WatchSelectors(const WebVector<WebString>& css_selectors) |
47 : css_selectors_(css_selectors) {} | 47 : css_selectors_(css_selectors) {} |
48 | 48 |
49 virtual bool Visit(content::RenderView* view) OVERRIDE { | 49 virtual bool Visit(content::RenderView* view) override { |
50 for (blink::WebFrame* frame = view->GetWebView()->mainFrame(); frame; | 50 for (blink::WebFrame* frame = view->GetWebView()->mainFrame(); frame; |
51 frame = frame->traverseNext(/*wrap=*/false)) | 51 frame = frame->traverseNext(/*wrap=*/false)) |
52 frame->document().watchCSSSelectors(css_selectors_); | 52 frame->document().watchCSSSelectors(css_selectors_); |
53 | 53 |
54 return true; // Continue visiting. | 54 return true; // Continue visiting. |
55 } | 55 } |
56 | 56 |
57 const WebVector<WebString>& css_selectors_; | 57 const WebVector<WebString>& css_selectors_; |
58 }; | 58 }; |
59 WatchSelectors visitor(css_selectors_); | 59 WatchSelectors visitor(css_selectors_); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 it != transitive_selectors.end(); | 111 it != transitive_selectors.end(); |
112 ++it) | 112 ++it) |
113 selector_strings.push_back(it->as_string()); | 113 selector_strings.push_back(it->as_string()); |
114 content::RenderView* view = | 114 content::RenderView* view = |
115 content::RenderView::FromWebView(top_frame->view()); | 115 content::RenderView::FromWebView(top_frame->view()); |
116 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(), | 116 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(), |
117 selector_strings)); | 117 selector_strings)); |
118 } | 118 } |
119 | 119 |
120 } // namespace extensions | 120 } // namespace extensions |
OLD | NEW |