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

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

Powered by Google App Engine
This is Rietveld 408576698