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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index 10b26c595f7f4aebfae5ee5c4f6e88605ab35dd3..b65dc2a0834be6e5cc96046c9a6b6decb1b8d3bd 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -268,6 +268,16 @@ void Dispatcher::DidCreateScriptContext(
const Extension* effective_extension =
GetExtensionFromFrameAndWorld(frame, world_id, true);
+ bool extension_is_platform_app = extension && extension->is_platform_app();
+
+ // If we are navigating to a platform app URL, the extension must first have
+ // been activated. If not, IsWithinPlatformApp will incorrectly return false,
+ // and we will be missing information about what features the app has.
+ // (Note: This DCHECK is invalid for non-app extensions, which do not get
+ // activated in "unblessed" contexts such as content scripts and iframes.)
+ if (extension_is_platform_app)
+ DCHECK(IsExtensionActive(extension_id));
+
GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame);
Feature::Context context_type =
ClassifyJavaScriptContext(extension,
@@ -317,13 +327,12 @@ void Dispatcher::DidCreateScriptContext(
UpdateBindingsForContext(context);
- bool is_within_platform_app = IsWithinPlatformApp();
// Inject custom JS into the platform app context.
- if (is_within_platform_app) {
+ if (extension_is_platform_app) {
module_system->Require("platformApp");
}
- delegate_->RequireAdditionalModules(context, is_within_platform_app);
+ delegate_->RequireAdditionalModules(context, extension_is_platform_app);
VLOG(1) << "Num tracked contexts: " << script_context_set_.size();
}
« 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