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

Side by Side Diff: extensions/renderer/content_watcher.cc

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add note about what it means to revert RequestContentScript Created 6 years, 6 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
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 WatchedPagesRecipient watched_pages_recipient) :
24 event_name_(event_name),
25 watched_pages_recipient_(watched_pages_recipient) {}
23 ContentWatcher::~ContentWatcher() {} 26 ContentWatcher::~ContentWatcher() {}
24 27
25 void ContentWatcher::OnWatchPages( 28 void ContentWatcher::OnWatchPages(
26 const std::vector<std::string>& new_css_selectors_utf8) { 29 const std::vector<std::string>& new_css_selectors_utf8) {
27 blink::WebVector<blink::WebString> new_css_selectors( 30 blink::WebVector<blink::WebString> new_css_selectors(
28 new_css_selectors_utf8.size()); 31 new_css_selectors_utf8.size());
29 bool changed = new_css_selectors.size() != css_selectors_.size(); 32 bool changed = new_css_selectors.size() != css_selectors_.size();
30 for (size_t i = 0; i < new_css_selectors.size(); ++i) { 33 for (size_t i = 0; i < new_css_selectors.size(); ++i) {
31 new_css_selectors[i] = 34 new_css_selectors[i] =
32 blink::WebString::fromUTF8(new_css_selectors_utf8[i]); 35 blink::WebString::fromUTF8(new_css_selectors_utf8[i]);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 109 }
107 } 110 }
108 std::vector<std::string> selector_strings; 111 std::vector<std::string> selector_strings;
109 for (std::set<base::StringPiece>::const_iterator it = 112 for (std::set<base::StringPiece>::const_iterator it =
110 transitive_selectors.begin(); 113 transitive_selectors.begin();
111 it != transitive_selectors.end(); 114 it != transitive_selectors.end();
112 ++it) 115 ++it)
113 selector_strings.push_back(it->as_string()); 116 selector_strings.push_back(it->as_string());
114 content::RenderView* view = 117 content::RenderView* view =
115 content::RenderView::FromWebView(top_frame->view()); 118 content::RenderView::FromWebView(top_frame->view());
116 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(), 119 switch (watched_pages_recipient_) {
117 selector_strings)); 120 case CONTENT_RULES_REGISTRY: {
121 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(),
122 event_name_,
123 selector_strings));
124 break;
125 }
126 case USER_SCRIPT_MANAGER: {
127 // TODO(markdittmer): Notify renderer-side script manager of
128 // selector_strings.
129 break;
130 }
131 }
118 } 132 }
119 133
120 } // namespace extensions 134 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698