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

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

Issue 443723003: extensions: Register 'app' and 'webstore' bindings only if they are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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.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/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 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 v8::Context::Scope context_scope(context->v8_context()); 996 v8::Context::Scope context_scope(context->v8_context());
997 997
998 // TODO(kalman): Make the bindings registration have zero overhead then run 998 // TODO(kalman): Make the bindings registration have zero overhead then run
999 // the same code regardless of context type. 999 // the same code regardless of context type.
1000 switch (context->context_type()) { 1000 switch (context->context_type()) {
1001 case Feature::UNSPECIFIED_CONTEXT: 1001 case Feature::UNSPECIFIED_CONTEXT:
1002 case Feature::WEB_PAGE_CONTEXT: 1002 case Feature::WEB_PAGE_CONTEXT:
1003 case Feature::BLESSED_WEB_PAGE_CONTEXT: { 1003 case Feature::BLESSED_WEB_PAGE_CONTEXT: {
1004 // Web page context; it's too expensive to run the full bindings code. 1004 // Web page context; it's too expensive to run the full bindings code.
1005 // Hard-code that the app and webstore APIs are available... 1005 // Hard-code that the app and webstore APIs are available...
1006 RegisterBinding("app", context); 1006 if (context->GetAvailability("app").is_available())
1007 RegisterBinding("webstore", context); 1007 RegisterBinding("app", context);
1008
1009 if (context->GetAvailability("webstore").is_available())
1010 RegisterBinding("webstore", context);
1008 1011
1009 // ... and that the runtime API might be available if any extension can 1012 // ... and that the runtime API might be available if any extension can
1010 // connect to it. 1013 // connect to it.
1011 bool runtime_is_available = false; 1014 bool runtime_is_available = false;
1012 for (ExtensionSet::const_iterator it = extensions_.begin(); 1015 for (ExtensionSet::const_iterator it = extensions_.begin();
1013 it != extensions_.end(); 1016 it != extensions_.end();
1014 ++it) { 1017 ++it) {
1015 ExternallyConnectableInfo* info = 1018 ExternallyConnectableInfo* info =
1016 static_cast<ExternallyConnectableInfo*>( 1019 static_cast<ExternallyConnectableInfo*>(
1017 (*it)->GetManifestData(manifest_keys::kExternallyConnectable)); 1020 (*it)->GetManifestData(manifest_keys::kExternallyConnectable));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 return v8::Handle<v8::Object>(); 1288 return v8::Handle<v8::Object>();
1286 1289
1287 if (bind_name) 1290 if (bind_name)
1288 *bind_name = split.back(); 1291 *bind_name = split.back();
1289 1292
1290 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1293 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1291 : bind_object; 1294 : bind_object;
1292 } 1295 }
1293 1296
1294 } // namespace extensions 1297 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698