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

Side by Side Diff: chrome/renderer/extensions/user_script_idle_scheduler.cc

Issue 7727004: Initialize content scripts the same way extension scripts are. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_idle_scheduler.h" 5 #include "chrome/renderer/extensions/user_script_idle_scheduler.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/common/extensions/extension_error_utils.h" 8 #include "chrome/common/extensions/extension_error_utils.h"
9 #include "chrome/common/extensions/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
10 #include "chrome/renderer/extensions/extension_dispatcher.h" 10 #include "chrome/renderer/extensions/extension_dispatcher.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return; 139 return;
140 } 140 }
141 } 141 }
142 142
143 WebScriptSource source(WebString::fromUTF8(params.code)); 143 WebScriptSource source(WebString::fromUTF8(params.code));
144 if (params.in_main_world) { 144 if (params.in_main_world) {
145 frame->executeScript(source); 145 frame->executeScript(source);
146 } else { 146 } else {
147 std::vector<WebScriptSource> sources; 147 std::vector<WebScriptSource> sources;
148 sources.push_back(source); 148 sources.push_back(source);
149 UserScriptSlave::InsertInitExtensionCode(&sources, params.extension_id);
150 frame->executeScriptInIsolatedWorld( 149 frame->executeScriptInIsolatedWorld(
151 extension_dispatcher_->user_script_slave()-> 150 extension_dispatcher_->user_script_slave()->
152 GetIsolatedWorldIdForExtension(extension, frame), 151 GetIsolatedWorldIdForExtension(extension, frame),
153 &sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS); 152 &sources.front(), sources.size(), EXTENSION_GROUP_CONTENT_SCRIPTS);
154 } 153 }
155 } else { 154 } else {
156 frame->document().insertUserStyleSheet( 155 frame->document().insertUserStyleSheet(
157 WebString::fromUTF8(params.code), 156 WebString::fromUTF8(params.code),
158 // Author level is consistent with WebView::addUserStyleSheet. 157 // Author level is consistent with WebView::addUserStyleSheet.
159 WebDocument::UserStyleAuthorLevel); 158 WebDocument::UserStyleAuthorLevel);
(...skipping 10 matching lines...) Expand all
170 if (!parent_frame) 169 if (!parent_frame)
171 return false; 170 return false;
172 171
173 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; 172 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame;
174 child_frame = child_frame->nextSibling()) { 173 child_frame = child_frame->nextSibling()) {
175 frames_vector->push_back(child_frame); 174 frames_vector->push_back(child_frame);
176 GetAllChildFrames(child_frame, frames_vector); 175 GetAllChildFrames(child_frame, frames_vector);
177 } 176 }
178 return true; 177 return true;
179 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698