OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/dispatcher.h" | 5 #include "chrome/renderer/extensions/dispatcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 } | 700 } |
701 | 701 |
702 void Dispatcher::AddOrRemoveBindingsForContext(ChromeV8Context* context) { | 702 void Dispatcher::AddOrRemoveBindingsForContext(ChromeV8Context* context) { |
703 v8::HandleScope handle_scope(context->isolate()); | 703 v8::HandleScope handle_scope(context->isolate()); |
704 v8::Context::Scope context_scope(context->v8_context()); | 704 v8::Context::Scope context_scope(context->v8_context()); |
705 | 705 |
706 // TODO(kalman): Make the bindings registration have zero overhead then run | 706 // TODO(kalman): Make the bindings registration have zero overhead then run |
707 // the same code regardless of context type. | 707 // the same code regardless of context type. |
708 switch (context->context_type()) { | 708 switch (context->context_type()) { |
709 case Feature::UNSPECIFIED_CONTEXT: | 709 case Feature::UNSPECIFIED_CONTEXT: |
710 case Feature::WEB_PAGE_CONTEXT: { | 710 case Feature::WEB_PAGE_CONTEXT: |
711 case Feature::BLESSED_WEB_PAGE_CONTEXT: { | |
Jeffrey Yasskin
2014/01/08 23:42:03
Add a comment to https://code.google.com/p/chromiu
not at google - send to devlin
2014/01/09 00:56:16
Done.
| |
711 // Web page context; it's too expensive to run the full bindings code. | 712 // Web page context; it's too expensive to run the full bindings code. |
712 // Hard-code that the app and webstore APIs are available... | 713 // Hard-code that the app and webstore APIs are available... |
713 RegisterBinding("app", context); | 714 RegisterBinding("app", context); |
714 RegisterBinding("webstore", context); | 715 RegisterBinding("webstore", context); |
715 | 716 |
716 // ... and that the runtime API might be available if any extension can | 717 // ... and that the runtime API might be available if any extension can |
717 // connect to it. | 718 // connect to it. |
718 bool runtime_is_available = false; | 719 bool runtime_is_available = false; |
719 for (ExtensionSet::const_iterator it = extensions_.begin(); | 720 for (ExtensionSet::const_iterator it = extensions_.begin(); |
720 it != extensions_.end(); ++it) { | 721 it != extensions_.end(); ++it) { |
721 ExternallyConnectableInfo* info = | 722 ExternallyConnectableInfo* info = |
722 static_cast<ExternallyConnectableInfo*>((*it)->GetManifestData( | 723 static_cast<ExternallyConnectableInfo*>((*it)->GetManifestData( |
723 manifest_keys::kExternallyConnectable)); | 724 manifest_keys::kExternallyConnectable)); |
724 if (info && info->matches.MatchesURL(context->GetURL())) { | 725 if (info && info->matches.MatchesURL(context->GetURL())) { |
725 runtime_is_available = true; | 726 runtime_is_available = true; |
726 break; | 727 break; |
727 } | 728 } |
728 } | 729 } |
729 if (runtime_is_available) | 730 if (runtime_is_available) |
730 RegisterBinding("runtime", context); | 731 RegisterBinding("runtime", context); |
731 break; | 732 break; |
732 } | 733 } |
733 | 734 |
734 case Feature::BLESSED_EXTENSION_CONTEXT: | 735 case Feature::BLESSED_EXTENSION_CONTEXT: |
735 case Feature::BLESSED_WEB_PAGE_CONTEXT: | |
736 case Feature::UNBLESSED_EXTENSION_CONTEXT: | 736 case Feature::UNBLESSED_EXTENSION_CONTEXT: |
737 case Feature::CONTENT_SCRIPT_CONTEXT: { | 737 case Feature::CONTENT_SCRIPT_CONTEXT: { |
738 // Extension context; iterate through all the APIs and bind the available | 738 // Extension context; iterate through all the APIs and bind the available |
739 // ones. | 739 // ones. |
740 FeatureProvider* api_feature_provider = FeatureProvider::GetAPIFeatures(); | 740 FeatureProvider* api_feature_provider = FeatureProvider::GetAPIFeatures(); |
741 const std::vector<std::string>& apis = | 741 const std::vector<std::string>& apis = |
742 api_feature_provider->GetAllFeatureNames(); | 742 api_feature_provider->GetAllFeatureNames(); |
743 for (std::vector<std::string>::const_iterator it = apis.begin(); | 743 for (std::vector<std::string>::const_iterator it = apis.begin(); |
744 it != apis.end(); ++it) { | 744 it != apis.end(); ++it) { |
745 const std::string& api_name = *it; | 745 const std::string& api_name = *it; |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1661 RenderView* background_view = | 1661 RenderView* background_view = |
1662 ExtensionHelper::GetBackgroundPage(extension_id); | 1662 ExtensionHelper::GetBackgroundPage(extension_id); |
1663 if (background_view) { | 1663 if (background_view) { |
1664 background_view->Send(new ExtensionHostMsg_EventAck( | 1664 background_view->Send(new ExtensionHostMsg_EventAck( |
1665 background_view->GetRoutingID())); | 1665 background_view->GetRoutingID())); |
1666 } | 1666 } |
1667 } | 1667 } |
1668 } | 1668 } |
1669 | 1669 |
1670 } // namespace extensions | 1670 } // namespace extensions |
OLD | NEW |