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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void ContentWatcher::DidCreateDocumentElement(WebKit::WebFrame* frame) { | 91 void ContentWatcher::DidCreateDocumentElement(WebKit::WebFrame* frame) { |
92 // Make sure the frame is represented in the matching_selectors_ map. | 92 // Make sure the frame is represented in the matching_selectors_ map. |
93 matching_selectors_[frame]; | 93 matching_selectors_[frame]; |
94 | 94 |
95 if (!css_selectors_.empty()) { | 95 if (!css_selectors_.empty()) { |
96 EnsureWatchingMutations(frame); | 96 EnsureWatchingMutations(frame); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void ContentWatcher::EnsureWatchingMutations(WebKit::WebFrame* frame) { | 100 void ContentWatcher::EnsureWatchingMutations(WebKit::WebFrame* frame) { |
101 v8::HandleScope scope; | 101 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
102 v8::Context::Scope context_scope(frame->mainWorldScriptContext()); | 102 v8::Context::Scope context_scope(frame->mainWorldScriptContext()); |
103 if (ModuleSystem* module_system = GetModuleSystem(frame)) { | 103 if (ModuleSystem* module_system = GetModuleSystem(frame)) { |
104 ModuleSystem::NativesEnabledScope scope(module_system); | 104 ModuleSystem::NativesEnabledScope scope(module_system); |
105 module_system->Require("contentWatcher"); | 105 module_system->Require("contentWatcher"); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 ModuleSystem* ContentWatcher::GetModuleSystem(WebKit::WebFrame* frame) const { | 109 ModuleSystem* ContentWatcher::GetModuleSystem(WebKit::WebFrame* frame) const { |
110 ChromeV8Context* v8_context = | 110 ChromeV8Context* v8_context = |
111 dispatcher_->v8_context_set().GetByV8Context( | 111 dispatcher_->v8_context_set().GetByV8Context( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 it = transitive_selectors.begin(); | 173 it = transitive_selectors.begin(); |
174 it != transitive_selectors.end(); ++it) | 174 it != transitive_selectors.end(); ++it) |
175 selector_strings.push_back(it->as_string()); | 175 selector_strings.push_back(it->as_string()); |
176 content::RenderView* view = | 176 content::RenderView* view = |
177 content::RenderView::FromWebView(top_frame->view()); | 177 content::RenderView::FromWebView(top_frame->view()); |
178 view->Send(new ExtensionHostMsg_OnWatchedPageChange( | 178 view->Send(new ExtensionHostMsg_OnWatchedPageChange( |
179 view->GetRoutingID(), selector_strings)); | 179 view->GetRoutingID(), selector_strings)); |
180 } | 180 } |
181 | 181 |
182 } // namespace extensions | 182 } // namespace extensions |
OLD | NEW |