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

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

Issue 371563005: Extensions: DCHECK that all app pages are blessed before use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address kalman's comments. Created 6 years, 5 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 | « no previous file | 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/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // "invalid". This isn't interesting. 250 // "invalid". This isn't interesting.
251 if (extension_id != "invalid") { 251 if (extension_id != "invalid") {
252 LOG(ERROR) << "Extension \"" << extension_id << "\" not found"; 252 LOG(ERROR) << "Extension \"" << extension_id << "\" not found";
253 RenderThread::Get()->RecordAction( 253 RenderThread::Get()->RecordAction(
254 UserMetricsAction("ExtensionNotFound_ED")); 254 UserMetricsAction("ExtensionNotFound_ED"));
255 } 255 }
256 256
257 extension_id = ""; 257 extension_id = "";
258 } 258 }
259 259
260 bool extension_is_platform_app = extension && extension->is_platform_app();
261
260 Feature::Context context_type = 262 Feature::Context context_type =
261 ClassifyJavaScriptContext(extension, 263 ClassifyJavaScriptContext(extension,
262 extension_group, 264 extension_group,
263 ScriptContext::GetDataSourceURLForFrame(frame), 265 ScriptContext::GetDataSourceURLForFrame(frame),
264 frame->document().securityOrigin()); 266 frame->document().securityOrigin());
265 267
268 // Sanity check that all platform app URLs are given a blessed extension
269 // context. If not, the app page would be missing features such as APIs.
270 if (extension_is_platform_app)
271 DCHECK_EQ(Feature::BLESSED_EXTENSION_CONTEXT, context_type);
lazyboy 2014/07/21 20:24:50 @kalman, so you're suggesting to add if (!extensio
not at google - send to devlin 2014/07/21 20:34:09 That would work, or a check like isWebviewProcess(
lazyboy 2014/07/21 22:03:20 The process itself doesn't know much about he webv
272
266 ScriptContext* context = 273 ScriptContext* context =
267 delegate_->CreateScriptContext(v8_context, frame, extension, context_type) 274 delegate_->CreateScriptContext(v8_context, frame, extension, context_type)
268 .release(); 275 .release();
269 script_context_set_.Add(context); 276 script_context_set_.Add(context);
270 277
271 // Initialize origin permissions for content scripts, which can't be 278 // Initialize origin permissions for content scripts, which can't be
272 // initialized in |OnActivateExtension|. 279 // initialized in |OnActivateExtension|.
273 if (context_type == Feature::CONTENT_SCRIPT_CONTEXT) 280 if (context_type == Feature::CONTENT_SCRIPT_CONTEXT)
274 InitOriginPermissions(extension); 281 InitOriginPermissions(extension);
275 282
(...skipping 13 matching lines...) Expand all
289 // lazily evalulate to Event from event_bindings.js. For extensions only 296 // lazily evalulate to Event from event_bindings.js. For extensions only
290 // though, not all webpages! 297 // though, not all webpages!
291 if (context->extension()) { 298 if (context->extension()) {
292 v8::Handle<v8::Object> chrome = AsObjectOrEmpty(GetOrCreateChrome(context)); 299 v8::Handle<v8::Object> chrome = AsObjectOrEmpty(GetOrCreateChrome(context));
293 if (!chrome.IsEmpty()) 300 if (!chrome.IsEmpty())
294 module_system->SetLazyField(chrome, "Event", kEventBindings, "Event"); 301 module_system->SetLazyField(chrome, "Event", kEventBindings, "Event");
295 } 302 }
296 303
297 UpdateBindingsForContext(context); 304 UpdateBindingsForContext(context);
298 305
299 bool is_within_platform_app = IsWithinPlatformApp();
300 // Inject custom JS into the platform app context. 306 // Inject custom JS into the platform app context.
301 if (is_within_platform_app) { 307 if (extension_is_platform_app) {
302 module_system->Require("platformApp"); 308 module_system->Require("platformApp");
303 } 309 }
304 310
305 delegate_->RequireAdditionalModules( 311 delegate_->RequireAdditionalModules(
306 module_system, extension, context_type, is_within_platform_app); 312 module_system, extension, context_type, extension_is_platform_app);
307 313
308 VLOG(1) << "Num tracked contexts: " << script_context_set_.size(); 314 VLOG(1) << "Num tracked contexts: " << script_context_set_.size();
309 } 315 }
310 316
311 void Dispatcher::WillReleaseScriptContext( 317 void Dispatcher::WillReleaseScriptContext(
312 WebFrame* frame, 318 WebFrame* frame,
313 const v8::Handle<v8::Context>& v8_context, 319 const v8::Handle<v8::Context>& v8_context,
314 int world_id) { 320 int world_id) {
315 ScriptContext* context = script_context_set_.GetByV8Context(v8_context); 321 ScriptContext* context = script_context_set_.GetByV8Context(v8_context);
316 if (!context) 322 if (!context)
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 return v8::Handle<v8::Object>(); 1231 return v8::Handle<v8::Object>();
1226 1232
1227 if (bind_name) 1233 if (bind_name)
1228 *bind_name = split.back(); 1234 *bind_name = split.back();
1229 1235
1230 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1236 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1231 : bind_object; 1237 : bind_object;
1232 } 1238 }
1233 1239
1234 } // namespace extensions 1240 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698