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

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

Issue 293003008: Make ActiveScriptController use Active Tab-style permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest master for CQ 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/permissions/permissions_data_unittest.cc ('k') | no next file » | 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/user_script_slave.h" 5 #include "extensions/renderer/user_script_slave.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/pickle.h" 12 #include "base/pickle.h"
13 #include "base/timer/elapsed_timer.h" 13 #include "base/timer/elapsed_timer.h"
14 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
15 #include "content/public/renderer/render_view.h" 15 #include "content/public/renderer/render_view.h"
16 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
17 #include "extensions/common/extension_messages.h" 17 #include "extensions/common/extension_messages.h"
18 #include "extensions/common/extension_set.h" 18 #include "extensions/common/extension_set.h"
19 #include "extensions/common/manifest_handlers/csp_info.h" 19 #include "extensions/common/manifest_handlers/csp_info.h"
20 #include "extensions/common/permissions/permissions_data.h" 20 #include "extensions/common/permissions/permissions_data.h"
21 #include "extensions/renderer/extension_helper.h"
21 #include "extensions/renderer/extensions_renderer_client.h" 22 #include "extensions/renderer/extensions_renderer_client.h"
22 #include "extensions/renderer/script_context.h" 23 #include "extensions/renderer/script_context.h"
23 #include "third_party/WebKit/public/web/WebFrame.h" 24 #include "third_party/WebKit/public/web/WebFrame.h"
24 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 25 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
25 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 26 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
26 #include "third_party/WebKit/public/web/WebView.h" 27 #include "third_party/WebKit/public/web/WebView.h"
27 #include "url/gurl.h" 28 #include "url/gurl.h"
28 29
29 using blink::WebFrame; 30 using blink::WebFrame;
30 using blink::WebSecurityOrigin; 31 using blink::WebSecurityOrigin;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 script_injections_.begin(); 177 script_injections_.begin();
177 iter != script_injections_.end(); 178 iter != script_injections_.end();
178 ++iter) { 179 ++iter) {
179 ScriptInjection* injection = *iter; 180 ScriptInjection* injection = *iter;
180 if (!injection->WantsToRun(frame, location, document_url)) 181 if (!injection->WantsToRun(frame, location, document_url))
181 continue; 182 continue;
182 183
183 const Extension* extension = GetExtension(injection->extension_id()); 184 const Extension* extension = GetExtension(injection->extension_id());
184 DCHECK(extension); 185 DCHECK(extension);
185 186
186 if (PermissionsData::RequiresActionForScriptExecution(extension)) { 187 if (PermissionsData::RequiresActionForScriptExecution(
188 extension,
189 ExtensionHelper::Get(top_render_view)->tab_id(),
190 document_url)) {
187 // TODO(rdevlin.cronin): Right now, this is just a notification, but soon 191 // TODO(rdevlin.cronin): Right now, this is just a notification, but soon
188 // we should block without user consent. 192 // we should block without user consent.
189 top_render_view->Send( 193 top_render_view->Send(
190 new ExtensionHostMsg_NotifyExtensionScriptExecution( 194 new ExtensionHostMsg_NotifyExtensionScriptExecution(
191 top_render_view->GetRoutingID(), 195 top_render_view->GetRoutingID(),
192 extension->id(), 196 extension->id(),
193 top_render_view->GetPageId())); 197 top_render_view->GetPageId()));
194 } 198 }
195 199
196 injection->Inject(frame, location, &scripts_run_info); 200 injection->Inject(frame, location, &scripts_run_info);
(...skipping 30 matching lines...) Expand all
227 } else if (location == UserScript::DOCUMENT_IDLE) { 231 } else if (location == UserScript::DOCUMENT_IDLE) {
228 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", info.num_js); 232 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", info.num_js);
229 if (info.num_js) 233 if (info.num_js)
230 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", info.timer.Elapsed()); 234 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", info.timer.Elapsed());
231 } else { 235 } else {
232 NOTREACHED(); 236 NOTREACHED();
233 } 237 }
234 } 238 }
235 239
236 } // namespace extensions 240 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698