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

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: 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 is_within_platform_app = extension && extension->is_platform_app();
261
262 // If we are navigating to a platform app URL, the extension must first have
263 // been activated. If not, IsWithinPlatformApp will incorrectly return false,
264 // and we will be missing information about what features the app has.
265 // (Note: This DCHECK is invalid for non-app extensions, which do not get
266 // activated in "unblessed" contexts such as content scripts and iframes.)
267 if (is_within_platform_app)
268 DCHECK(IsExtensionActive(extension_id));
not at google - send to devlin 2014/07/07 14:45:55 Good idea. A slightly stronger check would be to m
Matt Giuca 2014/07/10 08:04:56 Done.
269
260 Feature::Context context_type = 270 Feature::Context context_type =
261 ClassifyJavaScriptContext(extension, 271 ClassifyJavaScriptContext(extension,
262 extension_group, 272 extension_group,
263 ScriptContext::GetDataSourceURLForFrame(frame), 273 ScriptContext::GetDataSourceURLForFrame(frame),
264 frame->document().securityOrigin()); 274 frame->document().securityOrigin());
265 275
266 ScriptContext* context = 276 ScriptContext* context =
267 delegate_->CreateScriptContext(v8_context, frame, extension, context_type) 277 delegate_->CreateScriptContext(v8_context, frame, extension, context_type)
268 .release(); 278 .release();
269 script_context_set_.Add(context); 279 script_context_set_.Add(context);
(...skipping 19 matching lines...) Expand all
289 // lazily evalulate to Event from event_bindings.js. For extensions only 299 // lazily evalulate to Event from event_bindings.js. For extensions only
290 // though, not all webpages! 300 // though, not all webpages!
291 if (context->extension()) { 301 if (context->extension()) {
292 v8::Handle<v8::Object> chrome = AsObjectOrEmpty(GetOrCreateChrome(context)); 302 v8::Handle<v8::Object> chrome = AsObjectOrEmpty(GetOrCreateChrome(context));
293 if (!chrome.IsEmpty()) 303 if (!chrome.IsEmpty())
294 module_system->SetLazyField(chrome, "Event", kEventBindings, "Event"); 304 module_system->SetLazyField(chrome, "Event", kEventBindings, "Event");
295 } 305 }
296 306
297 UpdateBindingsForContext(context); 307 UpdateBindingsForContext(context);
298 308
299 bool is_within_platform_app = IsWithinPlatformApp();
300 // Inject custom JS into the platform app context. 309 // Inject custom JS into the platform app context.
301 if (is_within_platform_app) { 310 if (is_within_platform_app) {
302 module_system->Require("platformApp"); 311 module_system->Require("platformApp");
303 } 312 }
304 313
305 delegate_->RequireAdditionalModules( 314 delegate_->RequireAdditionalModules(
306 module_system, extension, context_type, is_within_platform_app); 315 module_system, extension, context_type, is_within_platform_app);
307 316
308 VLOG(1) << "Num tracked contexts: " << script_context_set_.size(); 317 VLOG(1) << "Num tracked contexts: " << script_context_set_.size();
309 } 318 }
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 return v8::Handle<v8::Object>(); 1234 return v8::Handle<v8::Object>();
1226 1235
1227 if (bind_name) 1236 if (bind_name)
1228 *bind_name = split.back(); 1237 *bind_name = split.back();
1229 1238
1230 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1239 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1231 : bind_object; 1240 : bind_object;
1232 } 1241 }
1233 1242
1234 } // namespace extensions 1243 } // 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