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

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: add URL parameter 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(), params.request_id, "", -1, GURL(""),
Aaron Boodman 2012/08/07 02:08:54 This is kinda a weird response. Looks like half-su
not at google - send to devlin 2012/08/07 02:16:23 It was equivalently weird before; success (true) b
149 execution_results)); 149 execution_results));
150 return; 150 return;
151 } 151 }
152 152
153 std::vector<WebFrame*> frame_vector; 153 std::vector<WebFrame*> frame_vector;
154 frame_vector.push_back(frame_); 154 frame_vector.push_back(frame_);
155 if (params.all_frames) 155 if (params.all_frames)
156 GetAllChildFrames(frame_, &frame_vector); 156 GetAllChildFrames(frame_, &frame_vector);
157 157
158 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin(); 158 for (std::vector<WebFrame*>::iterator frame_it = frame_vector.begin();
(...skipping 13 matching lines...) Expand all
172 if (!extension->CanExecuteScriptOnPage(frame->document().url(), 172 if (!extension->CanExecuteScriptOnPage(frame->document().url(),
173 extension_helper->tab_id(), 173 extension_helper->tab_id(),
174 NULL, 174 NULL,
175 NULL)) { 175 NULL)) {
176 if (frame->parent()) { 176 if (frame->parent()) {
177 continue; 177 continue;
178 } else { 178 } else {
179 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( 179 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished(
180 render_view->GetRoutingID(), 180 render_view->GetRoutingID(),
181 params.request_id, 181 params.request_id,
182 false,
183 -1,
184 ExtensionErrorUtils::FormatErrorMessage( 182 ExtensionErrorUtils::FormatErrorMessage(
185 extension_manifest_errors::kCannotAccessPage, 183 extension_manifest_errors::kCannotAccessPage,
186 frame->document().url().spec()), 184 frame->document().url().spec()),
185 -1,
186 GURL(""),
187 execution_results)); 187 execution_results));
188 return; 188 return;
189 } 189 }
190 } 190 }
191 191
192 WebScriptSource source(WebString::fromUTF8(params.code)); 192 WebScriptSource source(WebString::fromUTF8(params.code));
193 v8::HandleScope scope; 193 v8::HandleScope scope;
194 v8::Persistent<v8::Context> persistent_context = v8::Context::New(); 194 v8::Persistent<v8::Context> persistent_context = v8::Context::New();
195 v8::Local<v8::Context> context = 195 v8::Local<v8::Context> context =
196 v8::Local<v8::Context>::New(persistent_context); 196 v8::Local<v8::Context>::New(persistent_context);
(...skipping 28 matching lines...) Expand all
225 frame->document().insertUserStyleSheet( 225 frame->document().insertUserStyleSheet(
226 WebString::fromUTF8(params.code), 226 WebString::fromUTF8(params.code),
227 // Author level is consistent with WebView::addUserStyleSheet. 227 // Author level is consistent with WebView::addUserStyleSheet.
228 WebDocument::UserStyleAuthorLevel); 228 WebDocument::UserStyleAuthorLevel);
229 } 229 }
230 } 230 }
231 231
232 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished( 232 render_view->Send(new ExtensionHostMsg_ExecuteCodeFinished(
233 render_view->GetRoutingID(), 233 render_view->GetRoutingID(),
234 params.request_id, 234 params.request_id,
235 true, 235 "", // no error
236 render_view->GetPageId(), 236 render_view->GetPageId(),
237 "", 237 UserScriptSlave::GetDataSourceURLForFrame(frame_),
238 execution_results)); 238 execution_results));
239 } 239 }
240 240
241 bool UserScriptScheduler::GetAllChildFrames( 241 bool UserScriptScheduler::GetAllChildFrames(
242 WebFrame* parent_frame, 242 WebFrame* parent_frame,
243 std::vector<WebFrame*>* frames_vector) const { 243 std::vector<WebFrame*>* frames_vector) const {
244 if (!parent_frame) 244 if (!parent_frame)
245 return false; 245 return false;
246 246
247 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; 247 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame;
248 child_frame = child_frame->nextSibling()) { 248 child_frame = child_frame->nextSibling()) {
249 frames_vector->push_back(child_frame); 249 frames_vector->push_back(child_frame);
250 GetAllChildFrames(child_frame, frames_vector); 250 GetAllChildFrames(child_frame, frames_vector);
251 } 251 }
252 return true; 252 return true;
253 } 253 }
254 254
255 } // namespace extensions 255 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698