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

Side by Side Diff: extensions/renderer/programmatic_script_injector.cc

Issue 1030323003: [Extensions] Don't inject scripts into remote frames, null documents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | extensions/renderer/user_script_set.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/programmatic_script_injector.h" 5 #include "extensions/renderer/programmatic_script_injector.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 bool ProgrammaticScriptInjector::ShouldInjectCss( 63 bool ProgrammaticScriptInjector::ShouldInjectCss(
64 UserScript::RunLocation run_location) const { 64 UserScript::RunLocation run_location) const {
65 return GetRunLocation() == run_location && !params_->is_javascript; 65 return GetRunLocation() == run_location && !params_->is_javascript;
66 } 66 }
67 67
68 PermissionsData::AccessType ProgrammaticScriptInjector::CanExecuteOnFrame( 68 PermissionsData::AccessType ProgrammaticScriptInjector::CanExecuteOnFrame(
69 const InjectionHost* injection_host, 69 const InjectionHost* injection_host,
70 blink::WebFrame* frame, 70 blink::WebFrame* frame,
71 int tab_id, 71 int tab_id,
72 const GURL& top_url) const { 72 const GURL& top_url) const {
73 // It doesn't make sense to inject a script into a remote frame or a frame
74 // with a null document.
75 if (frame->isWebRemoteFrame() || frame->document().isNull())
76 return PermissionsData::ACCESS_DENIED;
73 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( 77 GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL(
74 frame, frame->document().url(), params_->match_about_blank); 78 frame, frame->document().url(), params_->match_about_blank);
75 if (params_->is_web_view) { 79 if (params_->is_web_view) {
76 if (frame->parent()) { 80 if (frame->parent()) {
77 // This is a subframe inside <webview>, so allow it. 81 // This is a subframe inside <webview>, so allow it.
78 return PermissionsData::ACCESS_ALLOWED; 82 return PermissionsData::ACCESS_ALLOWED;
79 } 83 }
80 84
81 return effective_document_url == params_->webview_src 85 return effective_document_url == params_->webview_src
82 ? PermissionsData::ACCESS_ALLOWED 86 ? PermissionsData::ACCESS_ALLOWED
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 147
144 render_view_->Send(new ExtensionHostMsg_ExecuteCodeFinished( 148 render_view_->Send(new ExtensionHostMsg_ExecuteCodeFinished(
145 render_view_->GetRoutingID(), 149 render_view_->GetRoutingID(),
146 params_->request_id, 150 params_->request_id,
147 error, 151 error,
148 url_, 152 url_,
149 *results_)); 153 *results_));
150 } 154 }
151 155
152 } // namespace extensions 156 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/user_script_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698