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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.cc

Issue 10598006: Browser tag shim (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 8 years, 6 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
OLDNEW
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/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 source_map_.RegisterSource("fileSystem", 588 source_map_.RegisterSource("fileSystem",
589 IDR_FILE_SYSTEM_CUSTOM_BINDINGS_JS); 589 IDR_FILE_SYSTEM_CUSTOM_BINDINGS_JS);
590 source_map_.RegisterSource("i18n", IDR_I18N_CUSTOM_BINDINGS_JS); 590 source_map_.RegisterSource("i18n", IDR_I18N_CUSTOM_BINDINGS_JS);
591 source_map_.RegisterSource("input.ime", IDR_INPUT_IME_CUSTOM_BINDINGS_JS); 591 source_map_.RegisterSource("input.ime", IDR_INPUT_IME_CUSTOM_BINDINGS_JS);
592 source_map_.RegisterSource("omnibox", IDR_OMNIBOX_CUSTOM_BINDINGS_JS); 592 source_map_.RegisterSource("omnibox", IDR_OMNIBOX_CUSTOM_BINDINGS_JS);
593 source_map_.RegisterSource("pageActions", 593 source_map_.RegisterSource("pageActions",
594 IDR_PAGE_ACTIONS_CUSTOM_BINDINGS_JS); 594 IDR_PAGE_ACTIONS_CUSTOM_BINDINGS_JS);
595 source_map_.RegisterSource("pageAction", IDR_PAGE_ACTION_CUSTOM_BINDINGS_JS); 595 source_map_.RegisterSource("pageAction", IDR_PAGE_ACTION_CUSTOM_BINDINGS_JS);
596 source_map_.RegisterSource("pageCapture", 596 source_map_.RegisterSource("pageCapture",
597 IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS); 597 IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS);
598 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS);
599 source_map_.RegisterSource("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS); 598 source_map_.RegisterSource("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS);
600 source_map_.RegisterSource("storage", IDR_STORAGE_CUSTOM_BINDINGS_JS); 599 source_map_.RegisterSource("storage", IDR_STORAGE_CUSTOM_BINDINGS_JS);
601 source_map_.RegisterSource("tabs", IDR_TABS_CUSTOM_BINDINGS_JS); 600 source_map_.RegisterSource("tabs", IDR_TABS_CUSTOM_BINDINGS_JS);
602 source_map_.RegisterSource("tts", IDR_TTS_CUSTOM_BINDINGS_JS); 601 source_map_.RegisterSource("tts", IDR_TTS_CUSTOM_BINDINGS_JS);
603 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); 602 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS);
604 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); 603 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS);
605 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); 604 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS);
606 source_map_.RegisterSource("webRequestInternal", 605 source_map_.RegisterSource("webRequestInternal",
607 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); 606 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS);
608 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); 607 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS);
608
609 // Platform app sources that are not API-specific..
610 source_map_.RegisterSource("browserTag", IDR_BROWSER_TAG_JS);
611 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS);
609 } 612 }
610 613
611 void ExtensionDispatcher::PopulateLazyBindingsMap() { 614 void ExtensionDispatcher::PopulateLazyBindingsMap() {
612 lazy_bindings_map_["app"] = InstallAppBindings; 615 lazy_bindings_map_["app"] = InstallAppBindings;
613 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; 616 lazy_bindings_map_["webstore"] = InstallWebstoreBindings;
614 } 617 }
615 618
616 void ExtensionDispatcher::InstallBindings(ModuleSystem* module_system, 619 void ExtensionDispatcher::InstallBindings(ModuleSystem* module_system,
617 v8::Handle<v8::Context> v8_context, 620 v8::Handle<v8::Context> v8_context,
618 const std::string& api) { 621 const std::string& api) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 const std::set<std::string>& apis = context->GetAvailableExtensionAPIs(); 715 const std::set<std::string>& apis = context->GetAvailableExtensionAPIs();
713 for (std::set<std::string>::const_iterator i = apis.begin(); 716 for (std::set<std::string>::const_iterator i = apis.begin();
714 i != apis.end(); ++i) { 717 i != apis.end(); ++i) {
715 InstallBindings(module_system.get(), v8_context, *i); 718 InstallBindings(module_system.get(), v8_context, *i);
716 } 719 }
717 720
718 break; 721 break;
719 } 722 }
720 } 723 }
721 724
722 // Inject custom JS into the platform app context to block certain features 725 if (IsWithinPlatformApp(frame)) {
723 // of the document and window. 726 // Inject custom JS into the platform app context to block certain features
724 if (IsWithinPlatformApp(frame)) 727 // of the document and window.
725 module_system->Require("platformApp"); 728 module_system->Require("platformApp");
726 729
730 if (extension &&
731 extension->HasAPIPermission(ExtensionAPIPermission::kBrowserTag)) {
732 module_system->Require("browserTag");
733 }
734 }
735
727 context->set_module_system(module_system.Pass()); 736 context->set_module_system(module_system.Pass());
728 737
729 int manifest_version = 1; 738 int manifest_version = 1;
730 if (extension) 739 if (extension)
731 manifest_version = extension->manifest_version(); 740 manifest_version = extension->manifest_version();
732 context->DispatchOnLoadEvent( 741 context->DispatchOnLoadEvent(
733 is_extension_process_, 742 is_extension_process_,
734 ChromeRenderProcessObserver::is_incognito_process(), 743 ChromeRenderProcessObserver::is_incognito_process(),
735 manifest_version); 744 manifest_version);
736 745
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // APIs, they don't get extension bindings injected. If we end up here it 1024 // APIs, they don't get extension bindings injected. If we end up here it
1016 // means that a sandboxed page somehow managed to invoke an API anyway, so 1025 // means that a sandboxed page somehow managed to invoke an API anyway, so
1017 // we should abort. 1026 // we should abort.
1018 WebKit::WebFrame* frame = context->web_frame(); 1027 WebKit::WebFrame* frame = context->web_frame();
1019 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1028 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1020 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1029 UserScriptSlave::GetDataSourceURLForFrame(frame));
1021 CHECK(!extensions_.IsSandboxedPage(url_info)); 1030 CHECK(!extensions_.IsSandboxedPage(url_info));
1022 1031
1023 return true; 1032 return true;
1024 } 1033 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698