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

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

Issue 226663003: Allow content script insertion on about:-URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove permission warning for about:-scheme Created 6 years, 8 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_slave.h" 5 #include "chrome/renderer/extensions/user_script_slave.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (frame->parent() && !script->match_all_frames()) 217 if (frame->parent() && !script->match_all_frames())
218 continue; // Only match subframes if the script declared it wanted to. 218 continue; // Only match subframes if the script declared it wanted to.
219 219
220 const Extension* extension = extensions_->GetByID(script->extension_id()); 220 const Extension* extension = extensions_->GetByID(script->extension_id());
221 221
222 // Since extension info is sent separately from user script info, they can 222 // Since extension info is sent separately from user script info, they can
223 // be out of sync. We just ignore this situation. 223 // be out of sync. We just ignore this situation.
224 if (!extension) 224 if (!extension)
225 continue; 225 continue;
226 226
227 if (data_source_url.SchemeIs(content::kAboutScheme)) {
228 if (!script->MatchesURL(data_source_url))
229 continue;
230
231 // about:-documents can access their creator's document, so (dis)allow
232 // access to the frame based on the creator's URL.
233 GURL document_origin_url(frame->document().securityOrigin().toString());
234 if (document_origin_url.is_valid())
235 data_source_url = document_origin_url;
not at google - send to devlin 2014/04/18 16:04:55 pull this logic out into a helper function and use
236 }
237
227 // Content scripts are not tab-specific. 238 // Content scripts are not tab-specific.
228 const int kNoTabId = -1; 239 const int kNoTabId = -1;
229 // We don't have a process id in this context. 240 // We don't have a process id in this context.
230 const int kNoProcessId = -1; 241 const int kNoProcessId = -1;
231 if (!PermissionsData::CanExecuteScriptOnPage(extension, 242 if (!PermissionsData::CanExecuteScriptOnPage(extension,
232 data_source_url, 243 data_source_url,
233 frame->top()->document().url(), 244 frame->top()->document().url(),
234 kNoTabId, 245 kNoTabId,
235 script, 246 script,
236 kNoProcessId, 247 kNoProcessId,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } else if (location == UserScript::DOCUMENT_IDLE) { 329 } else if (location == UserScript::DOCUMENT_IDLE) {
319 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); 330 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts);
320 if (num_scripts) 331 if (num_scripts)
321 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); 332 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
322 } else { 333 } else {
323 NOTREACHED(); 334 NOTREACHED();
324 } 335 }
325 } 336 }
326 337
327 } // namespace extensions 338 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698