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" |
11 #include "third_party/WebKit/public/web/WebElement.h" | 11 #include "third_party/WebKit/public/web/WebElement.h" |
12 #include "third_party/WebKit/public/web/WebFrame.h" | 12 #include "third_party/WebKit/public/web/WebFrame.h" |
13 #include "third_party/WebKit/public/web/WebScriptBindings.h" | 13 #include "third_party/WebKit/public/web/WebScriptBindings.h" |
14 #include "third_party/WebKit/public/web/WebView.h" | 14 #include "third_party/WebKit/public/web/WebView.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 using blink::WebString; | 18 using blink::WebString; |
19 using blink::WebVector; | 19 using blink::WebVector; |
20 using blink::WebView; | 20 using blink::WebView; |
21 | 21 |
22 ContentWatcher::ContentWatcher() {} | 22 ContentWatcher::ContentWatcher(const std::string& event_name) : |
| 23 event_name_(event_name) {} |
23 ContentWatcher::~ContentWatcher() {} | 24 ContentWatcher::~ContentWatcher() {} |
24 | 25 |
25 void ContentWatcher::OnWatchPages( | 26 void ContentWatcher::OnWatchPages( |
26 const std::vector<std::string>& new_css_selectors_utf8) { | 27 const std::vector<std::string>& new_css_selectors_utf8) { |
27 blink::WebVector<blink::WebString> new_css_selectors( | 28 blink::WebVector<blink::WebString> new_css_selectors( |
28 new_css_selectors_utf8.size()); | 29 new_css_selectors_utf8.size()); |
29 bool changed = new_css_selectors.size() != css_selectors_.size(); | 30 bool changed = new_css_selectors.size() != css_selectors_.size(); |
30 for (size_t i = 0; i < new_css_selectors.size(); ++i) { | 31 for (size_t i = 0; i < new_css_selectors.size(); ++i) { |
31 new_css_selectors[i] = | 32 new_css_selectors[i] = |
32 blink::WebString::fromUTF8(new_css_selectors_utf8[i]); | 33 blink::WebString::fromUTF8(new_css_selectors_utf8[i]); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 108 } |
108 std::vector<std::string> selector_strings; | 109 std::vector<std::string> selector_strings; |
109 for (std::set<base::StringPiece>::const_iterator it = | 110 for (std::set<base::StringPiece>::const_iterator it = |
110 transitive_selectors.begin(); | 111 transitive_selectors.begin(); |
111 it != transitive_selectors.end(); | 112 it != transitive_selectors.end(); |
112 ++it) | 113 ++it) |
113 selector_strings.push_back(it->as_string()); | 114 selector_strings.push_back(it->as_string()); |
114 content::RenderView* view = | 115 content::RenderView* view = |
115 content::RenderView::FromWebView(top_frame->view()); | 116 content::RenderView::FromWebView(top_frame->view()); |
116 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(), | 117 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(), |
| 118 event_name_, |
117 selector_strings)); | 119 selector_strings)); |
118 } | 120 } |
119 | 121 |
120 } // namespace extensions | 122 } // namespace extensions |
OLD | NEW |