| 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/renderer/extensions/user_script_scheduler.h" | 5 #include "chrome/renderer/extensions/user_script_scheduler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "third_party/WebKit/public/web/WebFrame.h" | 26 #include "third_party/WebKit/public/web/WebFrame.h" |
| 27 #include "third_party/WebKit/public/web/WebView.h" | 27 #include "third_party/WebKit/public/web/WebView.h" |
| 28 #include "v8/include/v8.h" | 28 #include "v8/include/v8.h" |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 // The length of time to wait after the DOM is complete to try and run user | 31 // The length of time to wait after the DOM is complete to try and run user |
| 32 // scripts. | 32 // scripts. |
| 33 const int kUserScriptIdleTimeoutMs = 200; | 33 const int kUserScriptIdleTimeoutMs = 200; |
| 34 } | 34 } |
| 35 | 35 |
| 36 using WebKit::WebDocument; | 36 using blink::WebDocument; |
| 37 using WebKit::WebFrame; | 37 using blink::WebFrame; |
| 38 using WebKit::WebString; | 38 using blink::WebString; |
| 39 using WebKit::WebVector; | 39 using blink::WebVector; |
| 40 using WebKit::WebView; | 40 using blink::WebView; |
| 41 | 41 |
| 42 namespace extensions { | 42 namespace extensions { |
| 43 | 43 |
| 44 UserScriptScheduler::UserScriptScheduler(WebFrame* frame, | 44 UserScriptScheduler::UserScriptScheduler(WebFrame* frame, |
| 45 Dispatcher* dispatcher) | 45 Dispatcher* dispatcher) |
| 46 : weak_factory_(this), | 46 : weak_factory_(this), |
| 47 frame_(frame), | 47 frame_(frame), |
| 48 current_location_(UserScript::UNDEFINED), | 48 current_location_(UserScript::UNDEFINED), |
| 49 has_run_idle_(false), | 49 has_run_idle_(false), |
| 50 dispatcher_(dispatcher) { | 50 dispatcher_(dispatcher) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 scoped_ptr<content::V8ValueConverter> v8_converter( | 205 scoped_ptr<content::V8ValueConverter> v8_converter( |
| 206 content::V8ValueConverter::create()); | 206 content::V8ValueConverter::create()); |
| 207 v8::Local<v8::Value> script_value; | 207 v8::Local<v8::Value> script_value; |
| 208 | 208 |
| 209 if (params.in_main_world) { | 209 if (params.in_main_world) { |
| 210 DOMActivityLogger::AttachToWorld(DOMActivityLogger::kMainWorldId, | 210 DOMActivityLogger::AttachToWorld(DOMActivityLogger::kMainWorldId, |
| 211 extension->id()); | 211 extension->id()); |
| 212 script_value = child_frame->executeScriptAndReturnValue(source); | 212 script_value = child_frame->executeScriptAndReturnValue(source); |
| 213 } else { | 213 } else { |
| 214 WebKit::WebVector<v8::Local<v8::Value> > results; | 214 blink::WebVector<v8::Local<v8::Value> > results; |
| 215 std::vector<WebScriptSource> sources; | 215 std::vector<WebScriptSource> sources; |
| 216 sources.push_back(source); | 216 sources.push_back(source); |
| 217 int isolated_world_id = | 217 int isolated_world_id = |
| 218 dispatcher_->user_script_slave()->GetIsolatedWorldIdForExtension( | 218 dispatcher_->user_script_slave()->GetIsolatedWorldIdForExtension( |
| 219 extension, child_frame); | 219 extension, child_frame); |
| 220 DOMActivityLogger::AttachToWorld(isolated_world_id, extension->id()); | 220 DOMActivityLogger::AttachToWorld(isolated_world_id, extension->id()); |
| 221 child_frame->executeScriptInIsolatedWorld( | 221 child_frame->executeScriptInIsolatedWorld( |
| 222 isolated_world_id, &sources.front(), | 222 isolated_world_id, &sources.front(), |
| 223 sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS, &results); | 223 sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS, &results); |
| 224 // We only expect one value back since we only pushed one source | 224 // We only expect one value back since we only pushed one source |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 263 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
| 264 child_frame = child_frame->nextSibling()) { | 264 child_frame = child_frame->nextSibling()) { |
| 265 frames_vector->push_back(child_frame); | 265 frames_vector->push_back(child_frame); |
| 266 GetAllChildFrames(child_frame, frames_vector); | 266 GetAllChildFrames(child_frame, frames_vector); |
| 267 } | 267 } |
| 268 return true; | 268 return true; |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace extensions | 271 } // namespace extensions |
| OLD | NEW |