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

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

Issue 1634203002: Fix remote frame origin access in ContentWatcher::NotifyBrowserOfChange. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "content/public/renderer/render_view_visitor.h" 10 #include "content/public/renderer/render_view_visitor.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // extension with access to top_origin could run on the frame. 90 // extension with access to top_origin could run on the frame.
91 if (!top_origin.canAccess(changed_frame->document().securityOrigin())) { 91 if (!top_origin.canAccess(changed_frame->document().securityOrigin())) {
92 // If the changed frame can't be accessed by the top frame, then 92 // If the changed frame can't be accessed by the top frame, then
93 // no change in it could affect the set of selectors we'd send back. 93 // no change in it could affect the set of selectors we'd send back.
94 return; 94 return;
95 } 95 }
96 96
97 std::set<base::StringPiece> transitive_selectors; 97 std::set<base::StringPiece> transitive_selectors;
98 for (blink::WebFrame* frame = top_frame; frame; 98 for (blink::WebFrame* frame = top_frame; frame;
99 frame = frame->traverseNext(/*wrap=*/false)) { 99 frame = frame->traverseNext(/*wrap=*/false)) {
100 if (top_origin.canAccess(frame->document().securityOrigin())) { 100 if (top_origin.canAccess(frame->securityOrigin())) {
101 std::map<blink::WebFrame*, std::set<std::string> >::const_iterator 101 std::map<blink::WebFrame*, std::set<std::string> >::const_iterator
102 frame_selectors = matching_selectors_.find(frame); 102 frame_selectors = matching_selectors_.find(frame);
103 if (frame_selectors != matching_selectors_.end()) { 103 if (frame_selectors != matching_selectors_.end()) {
104 transitive_selectors.insert(frame_selectors->second.begin(), 104 transitive_selectors.insert(frame_selectors->second.begin(),
105 frame_selectors->second.end()); 105 frame_selectors->second.end());
106 } 106 }
107 } 107 }
108 } 108 }
109 std::vector<std::string> selector_strings; 109 std::vector<std::string> selector_strings;
110 for (std::set<base::StringPiece>::const_iterator it = 110 for (std::set<base::StringPiece>::const_iterator it =
111 transitive_selectors.begin(); 111 transitive_selectors.begin();
112 it != transitive_selectors.end(); 112 it != transitive_selectors.end();
113 ++it) 113 ++it)
114 selector_strings.push_back(it->as_string()); 114 selector_strings.push_back(it->as_string());
115 content::RenderView* view = 115 content::RenderView* view =
116 content::RenderView::FromWebView(top_frame->view()); 116 content::RenderView::FromWebView(top_frame->view());
117 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(), 117 view->Send(new ExtensionHostMsg_OnWatchedPageChange(view->GetRoutingID(),
118 selector_strings)); 118 selector_strings));
119 } 119 }
120 120
121 } // namespace extensions 121 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698