OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/extension_messages.h" | 5 #include "chrome/common/extensions/extension_messages.h" |
6 #include "chrome/renderer/extensions/chrome_v8_context.h" | 6 #include "chrome/renderer/extensions/chrome_v8_context.h" |
7 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 7 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
8 #include "chrome/renderer/extensions/content_watcher.h" | 8 #include "chrome/renderer/extensions/content_watcher.h" |
9 #include "chrome/renderer/extensions/dispatcher.h" | 9 #include "chrome/renderer/extensions/dispatcher.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 // Make sure to replace the contents of it->second because it contains | 69 // Make sure to replace the contents of it->second because it contains |
70 // dangling StringPieces that referred into the old css_selectors_ content. | 70 // dangling StringPieces that referred into the old css_selectors_ content. |
71 it->second = FindMatchingSelectors(frame); | 71 it->second = FindMatchingSelectors(frame); |
72 } | 72 } |
73 | 73 |
74 // For each top-level frame, inform the browser about its new matching set of | 74 // For each top-level frame, inform the browser about its new matching set of |
75 // selectors. | 75 // selectors. |
76 struct NotifyVisitor : public content::RenderViewVisitor { | 76 struct NotifyVisitor : public content::RenderViewVisitor { |
77 explicit NotifyVisitor(ContentWatcher* watcher) : watcher_(watcher) {} | 77 explicit NotifyVisitor(ContentWatcher* watcher) : watcher_(watcher) {} |
78 virtual bool Visit(content::RenderView* view) { | 78 virtual bool Visit(content::RenderView* view) OVERRIDE { |
79 watcher_->NotifyBrowserOfChange(view->GetWebView()->mainFrame()); | 79 watcher_->NotifyBrowserOfChange(view->GetWebView()->mainFrame()); |
80 return true; // Continue visiting. | 80 return true; // Continue visiting. |
81 } | 81 } |
82 ContentWatcher* watcher_; | 82 ContentWatcher* watcher_; |
83 }; | 83 }; |
84 NotifyVisitor visitor(this); | 84 NotifyVisitor visitor(this); |
85 content::RenderView::ForEach(&visitor); | 85 content::RenderView::ForEach(&visitor); |
86 } | 86 } |
87 | 87 |
88 void ContentWatcher::DidCreateDocumentElement(WebKit::WebFrame* frame) { | 88 void ContentWatcher::DidCreateDocumentElement(WebKit::WebFrame* frame) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 it = transitive_selectors.begin(); | 200 it = transitive_selectors.begin(); |
201 it != transitive_selectors.end(); ++it) | 201 it != transitive_selectors.end(); ++it) |
202 selector_strings.push_back(it->as_string()); | 202 selector_strings.push_back(it->as_string()); |
203 content::RenderView* view = | 203 content::RenderView* view = |
204 content::RenderView::FromWebView(top_frame->view()); | 204 content::RenderView::FromWebView(top_frame->view()); |
205 view->Send(new ExtensionHostMsg_OnWatchedPageChange( | 205 view->Send(new ExtensionHostMsg_OnWatchedPageChange( |
206 view->GetRoutingID(), selector_strings)); | 206 view->GetRoutingID(), selector_strings)); |
207 } | 207 } |
208 | 208 |
209 } // namespace extensions | 209 } // namespace extensions |
OLD | NEW |