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

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

Issue 226663003: Allow content script insertion on about:-URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use url of parent(s) instead of origin, more tests Created 6 years, 7 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/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/renderer/chrome_render_process_observer.h" 10 #include "chrome/renderer/chrome_render_process_observer.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // We recheck access here in the renderer for extra safety against races 177 // We recheck access here in the renderer for extra safety against races
178 // with navigation. 178 // with navigation.
179 // 179 //
180 // But different frames can have different URLs, and the extension might 180 // But different frames can have different URLs, and the extension might
181 // only have access to a subset of them. For the top frame, we can 181 // only have access to a subset of them. For the top frame, we can
182 // immediately send an error and stop because the browser process 182 // immediately send an error and stop because the browser process
183 // considers that an error too. 183 // considers that an error too.
184 // 184 //
185 // For child frames, we just skip ones the extension doesn't have access 185 // For child frames, we just skip ones the extension doesn't have access
186 // to and carry on. 186 // to and carry on.
187 if (!params.is_web_view && 187 if (!params.is_web_view) {
188 !PermissionsData::CanExecuteScriptOnPage(extension, 188 GURL document_url = UserScriptSlave::GetEffectiveDocumentURL(
189 child_frame->document().url(), 189 child_frame, child_frame->document().url(), params.match_about_blank);
190 frame_->document().url(), 190
191 extension_helper->tab_id(), 191 if (!PermissionsData::CanExecuteScriptOnPage(extension,
192 NULL, 192 document_url,
193 -1, 193 frame_->document().url(),
194 NULL)) { 194 extension_helper->tab_id(),
195 if (child_frame->parent()) { 195 NULL,
196 continue; 196 -1,
197 } else { 197 NULL)) {
198 error = ErrorUtils::FormatErrorMessage( 198 if (child_frame->parent()) {
199 manifest_errors::kCannotAccessPage, 199 continue;
200 child_frame->document().url().spec()); 200 } else {
201 break; 201 error = ErrorUtils::FormatErrorMessage(
202 manifest_errors::kCannotAccessPage, document_url.spec());
203 break;
204 }
202 } 205 }
203 } 206 }
204 207
205 if (params.is_javascript) { 208 if (params.is_javascript) {
206 WebScriptSource source(WebString::fromUTF8(params.code), params.file_url); 209 WebScriptSource source(WebString::fromUTF8(params.code), params.file_url);
207 v8::HandleScope scope(v8::Isolate::GetCurrent()); 210 v8::HandleScope scope(v8::Isolate::GetCurrent());
208 211
209 scoped_ptr<content::V8ValueConverter> v8_converter( 212 scoped_ptr<content::V8ValueConverter> v8_converter(
210 content::V8ValueConverter::create()); 213 content::V8ValueConverter::create());
211 v8::Local<v8::Value> script_value; 214 v8::Local<v8::Value> script_value;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 267
265 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame; 268 for (WebFrame* child_frame = parent_frame->firstChild(); child_frame;
266 child_frame = child_frame->nextSibling()) { 269 child_frame = child_frame->nextSibling()) {
267 frames_vector->push_back(child_frame); 270 frames_vector->push_back(child_frame);
268 GetAllChildFrames(child_frame, frames_vector); 271 GetAllChildFrames(child_frame, frames_vector);
269 } 272 }
270 return true; 273 return true;
271 } 274 }
272 275
273 } // namespace extensions 276 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698