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

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

Issue 10826141: Formalise a CHECK for the NULL NavigationEntry in ScriptBadgeController, and (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: win compile fix Created 8 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
OLDNEW
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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/common/extensions/extension_error_utils.h" 9 #include "chrome/common/extensions/extension_error_utils.h"
10 #include "chrome/common/extensions/extension_manifest_constants.h" 10 #include "chrome/common/extensions/extension_manifest_constants.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 params.extension_id); 138 params.extension_id);
139 content::RenderView* render_view = 139 content::RenderView* render_view =
140 content::RenderView::FromWebView(frame_->view()); 140 content::RenderView::FromWebView(frame_->view());
141 ExtensionHelper* extension_helper = ExtensionHelper::Get(render_view); 141 ExtensionHelper* extension_helper = ExtensionHelper::Get(render_view);
142 base::ListValue execution_results; 142 base::ListValue execution_results;
143 143
144 // Since extension info is sent separately from user script info, they can 144 // Since extension info is sent separately from user script info, they can
145 // be out of sync. We just ignore this situation. 145 // be out of sync. We just ignore this situation.
146 if (!extension) { 146 if (!extension) {
147 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( 147 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished(
148 render_view->GetRoutingID(), params.request_id, true, -1, "", 148 render_view->GetRoutingID(),
149 params.request_id,
150 "", // no error
151 -1,
152 GURL(""),
149 execution_results)); 153 execution_results));
150 return; 154 return;
151 } 155 }
152 156
153 std::vector<WebFrame*> frame_vector; 157 std::vector<WebFrame*> frame_vector;
154 frame_vector.push_back(frame_); 158 frame_vector.push_back(frame_);
155 if (params.all_frames) 159 if (params.all_frames)
156 GetAllChildFrames(frame_, &frame_vector); 160 GetAllChildFrames(frame_, &frame_vector);
157 161
158 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin(); 162 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin();
(...skipping 13 matching lines...) Expand all
172 if (!extension->CanExecuteScriptOnPage(frame->document().url(), 176 if (!extension->CanExecuteScriptOnPage(frame->document().url(),
173 extension_helper->tab_id(), 177 extension_helper->tab_id(),
174 NULL, 178 NULL,
175 NULL)) { 179 NULL)) {
176 if (frame->parent()) { 180 if (frame->parent()) {
177 continue; 181 continue;
178 } else { 182 } else {
179 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( 183 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished(
180 render_view->GetRoutingID(), 184 render_view->GetRoutingID(),
181 params.request_id, 185 params.request_id,
182 false,
183 -1,
184 ExtensionErrorUtils::FormatErrorMessage( 186 ExtensionErrorUtils::FormatErrorMessage(
185 extension_manifest_errors::kCannotAccessPage, 187 extension_manifest_errors::kCannotAccessPage,
186 frame->document().url().spec()), 188 frame->document().url().spec()),
189 -1,
190 GURL(""),
187 execution_results)); 191 execution_results));
188 return; 192 return;
189 } 193 }
190 } 194 }
191 195
192 WebScriptSource source(WebString::fromUTF8(params.code)); 196 WebScriptSource source(WebString::fromUTF8(params.code));
193 v8::HandleScope scope; 197 v8::HandleScope scope;
194 v8::Persistent<v8::Context> persistent_context = v8::Context::New(); 198 v8::Persistent<v8::Context> persistent_context = v8::Context::New();
195 v8::Local<v8::Context> context = 199 v8::Local<v8::Context> context =
196 v8::Local<v8::Context>::New(persistent_context); 200 v8::Local<v8::Context>::New(persistent_context);
(...skipping 28 matching lines...) Expand all
225 frame->document().insertUserStyleSheet( 229 frame->document().insertUserStyleSheet(
226 WebString::fromUTF8(params.code), 230 WebString::fromUTF8(params.code),
227 // Author level is consistent with WebView::addUserStyleSheet. 231 // Author level is consistent with WebView::addUserStyleSheet.
228 WebDocument::UserStyleAuthorLevel); 232 WebDocument::UserStyleAuthorLevel);
229 } 233 }
230 } 234 }
231 235
232 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( 236 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished(
233 render_view->GetRoutingID(), 237 render_view->GetRoutingID(),
234 params.request_id, 238 params.request_id,
235 true, 239 "", // no error
236 render_view->GetPageId(), 240 render_view->GetPageId(),
237 "", 241 UserScriptSlave::GetDataSourceURLForFrame(frame_),
238 execution_results)); 242 execution_results));
239 } 243 }
240 244
241 bool UserScriptScheduler::GetAllChildFrames( 245 bool UserScriptScheduler::GetAllChildFrames(
242 WebFrame* parent_frame, 246 WebFrame* parent_frame,
243 std::vector<WebFrame*>* frames_vector) const { 247 std::vector<WebFrame*>* frames_vector) const {
244 if (!parent_frame) 248 if (!parent_frame)
245 return false; 249 return false;
246 250
247 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; 251 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame;
248 child_frame = child_frame->nextSibling()) { 252 child_frame = child_frame->nextSibling()) {
249 frames_vector->push_back(child_frame); 253 frames_vector->push_back(child_frame);
250 GetAllChildFrames(child_frame, frames_vector); 254 GetAllChildFrames(child_frame, frames_vector);
251 } 255 }
252 return true; 256 return true;
253 } 257 }
254 258
255 } // namespace extensions 259 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_helper.cc ('k') | chrome/renderer/extensions/user_script_slave.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698