| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // V8ValueConverterImpl shouldn't actually care about the context scope, | 231 // V8ValueConverterImpl shouldn't actually care about the context scope, |
| 232 // and it switches to v8::Object's creation context when encountered. | 232 // and it switches to v8::Object's creation context when encountered. |
| 233 v8::Local<v8::Context> context = child_frame->mainWorldScriptContext(); | 233 v8::Local<v8::Context> context = child_frame->mainWorldScriptContext(); |
| 234 base::Value* result = v8_converter->FromV8Value(script_value, context); | 234 base::Value* result = v8_converter->FromV8Value(script_value, context); |
| 235 // Always append an execution result (i.e. no result == null result) so | 235 // Always append an execution result (i.e. no result == null result) so |
| 236 // that |execution_results| lines up with the frames. | 236 // that |execution_results| lines up with the frames. |
| 237 execution_results.Append( | 237 execution_results.Append( |
| 238 result ? result : base::Value::CreateNullValue()); | 238 result ? result : base::Value::CreateNullValue()); |
| 239 } | 239 } |
| 240 } else { | 240 } else { |
| 241 child_frame->document().insertUserStyleSheet( | 241 child_frame->document().insertStyleSheet( |
| 242 WebString::fromUTF8(params.code), | 242 WebString::fromUTF8(params.code)); |
| 243 // Author level is consistent with WebView::injectStyleSheet. | |
| 244 WebDocument::UserStyleAuthorLevel); | |
| 245 } | 243 } |
| 246 } | 244 } |
| 247 | 245 |
| 248 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( | 246 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( |
| 249 render_view->GetRoutingID(), | 247 render_view->GetRoutingID(), |
| 250 params.request_id, | 248 params.request_id, |
| 251 error, | 249 error, |
| 252 render_view->GetPageId(), | 250 render_view->GetPageId(), |
| 253 UserScriptSlave::GetDataSourceURLForFrame(frame_), | 251 UserScriptSlave::GetDataSourceURLForFrame(frame_), |
| 254 execution_results)); | 252 execution_results)); |
| 255 } | 253 } |
| 256 | 254 |
| 257 bool UserScriptScheduler::GetAllChildFrames( | 255 bool UserScriptScheduler::GetAllChildFrames( |
| 258 WebFrame* parent_frame, | 256 WebFrame* parent_frame, |
| 259 std::vector<WebFrame*>* frames_vector) const { | 257 std::vector<WebFrame*>* frames_vector) const { |
| 260 if (!parent_frame) | 258 if (!parent_frame) |
| 261 return false; | 259 return false; |
| 262 | 260 |
| 263 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; | 261 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; |
| 264 child_frame = child_frame->nextSibling()) { | 262 child_frame = child_frame->nextSibling()) { |
| 265 frames_vector->push_back(child_frame); | 263 frames_vector->push_back(child_frame); |
| 266 GetAllChildFrames(child_frame, frames_vector); | 264 GetAllChildFrames(child_frame, frames_vector); |
| 267 } | 265 } |
| 268 return true; | 266 return true; |
| 269 } | 267 } |
| 270 | 268 |
| 271 } // namespace extensions | 269 } // namespace extensions |
| OLD | NEW |