| 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 <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 Loading... |
| 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 |
| OLD | NEW |