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

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: Rebase. Created 6 years, 3 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 int world_id) { 261 int world_id) {
262 #if !defined(ENABLE_EXTENSIONS) 262 #if !defined(ENABLE_EXTENSIONS)
263 return; 263 return;
264 #endif 264 #endif
265 265
266 const Extension* extension = 266 const Extension* extension =
267 GetExtensionFromFrameAndWorld(frame, world_id, false); 267 GetExtensionFromFrameAndWorld(frame, world_id, false);
268 const Extension* effective_extension = 268 const Extension* effective_extension =
269 GetExtensionFromFrameAndWorld(frame, world_id, true); 269 GetExtensionFromFrameAndWorld(frame, world_id, true);
270 270
271 bool extension_is_platform_app = extension && extension->is_platform_app();
272
273 // If we are navigating to a platform app URL, the extension must first have
274 // been activated. If not, IsWithinPlatformApp will incorrectly return false,
275 // and we will be missing information about what features the app has.
276 // (Note: This DCHECK is invalid for non-app extensions, which do not get
277 // activated in "unblessed" contexts such as content scripts and iframes.)
278 if (extension_is_platform_app)
279 DCHECK(IsExtensionActive(extension_id));
280
271 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); 281 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame);
272 Feature::Context context_type = 282 Feature::Context context_type =
273 ClassifyJavaScriptContext(extension, 283 ClassifyJavaScriptContext(extension,
274 extension_group, 284 extension_group,
275 frame_url, 285 frame_url,
276 frame->document().securityOrigin()); 286 frame->document().securityOrigin());
277 Feature::Context effective_context_type = ClassifyJavaScriptContext( 287 Feature::Context effective_context_type = ClassifyJavaScriptContext(
278 effective_extension, 288 effective_extension,
279 extension_group, 289 extension_group,
280 ScriptContext::GetEffectiveDocumentURL(frame, frame_url, true), 290 ScriptContext::GetEffectiveDocumentURL(frame, frame_url, true),
(...skipping 29 matching lines...) Expand all
310 // lazily evalulate to Event from event_bindings.js. For extensions only 320 // lazily evalulate to Event from event_bindings.js. For extensions only
311 // though, not all webpages! 321 // though, not all webpages!
312 if (context->extension()) { 322 if (context->extension()) {
313 v8::Handle<v8::Object> chrome = AsObjectOrEmpty(GetOrCreateChrome(context)); 323 v8::Handle<v8::Object> chrome = AsObjectOrEmpty(GetOrCreateChrome(context));
314 if (!chrome.IsEmpty()) 324 if (!chrome.IsEmpty())
315 module_system->SetLazyField(chrome, "Event", kEventBindings, "Event"); 325 module_system->SetLazyField(chrome, "Event", kEventBindings, "Event");
316 } 326 }
317 327
318 UpdateBindingsForContext(context); 328 UpdateBindingsForContext(context);
319 329
320 bool is_within_platform_app = IsWithinPlatformApp();
321 // Inject custom JS into the platform app context. 330 // Inject custom JS into the platform app context.
322 if (is_within_platform_app) { 331 if (extension_is_platform_app) {
323 module_system->Require("platformApp"); 332 module_system->Require("platformApp");
324 } 333 }
325 334
326 delegate_->RequireAdditionalModules(context, is_within_platform_app); 335 delegate_->RequireAdditionalModules(context, extension_is_platform_app);
327 336
328 VLOG(1) << "Num tracked contexts: " << script_context_set_.size(); 337 VLOG(1) << "Num tracked contexts: " << script_context_set_.size();
329 } 338 }
330 339
331 void Dispatcher::WillReleaseScriptContext( 340 void Dispatcher::WillReleaseScriptContext(
332 WebFrame* frame, 341 WebFrame* frame,
333 const v8::Handle<v8::Context>& v8_context, 342 const v8::Handle<v8::Context>& v8_context,
334 int world_id) { 343 int world_id) {
335 ScriptContext* context = script_context_set_.GetByV8Context(v8_context); 344 ScriptContext* context = script_context_set_.GetByV8Context(v8_context);
336 if (!context) 345 if (!context)
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 return v8::Handle<v8::Object>(); 1354 return v8::Handle<v8::Object>();
1346 1355
1347 if (bind_name) 1356 if (bind_name)
1348 *bind_name = split.back(); 1357 *bind_name = split.back();
1349 1358
1350 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1359 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1351 : bind_object; 1360 : bind_object;
1352 } 1361 }
1353 1362
1354 } // namespace extensions 1363 } // 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