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

Unified Diff: chrome/renderer/extensions/extension_dispatcher.cc

Issue 10698163: Make miscellaneous_bindings.js not depend on onLoad(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/extension_dispatcher.cc
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc
index 362517c656f90ffc4c98db22fdb38303407d5e82..b8aa0335998de883d9dfccfb124e75702bbf22d4 100644
--- a/chrome/renderer/extensions/extension_dispatcher.cc
+++ b/chrome/renderer/extensions/extension_dispatcher.cc
@@ -196,6 +196,56 @@ class LazyBackgroundPageNativeHandler : public ChromeV8Extension {
}
};
+class ProcessInfoNativeHandler : public ChromeV8Extension {
+ public:
+ explicit ProcessInfoNativeHandler(
+ ExtensionDispatcher* dispatcher,
+ const std::string& extension_id,
+ const std::string& context_type,
+ bool is_incognito_context,
+ int manifest_version)
+ : ChromeV8Extension(dispatcher),
+ extension_id_(extension_id),
+ context_type_(context_type),
+ is_incognito_context_(is_incognito_context),
+ manifest_version_(manifest_version) {
+ RouteFunction("GetExtensionId",
+ base::Bind(&ProcessInfoNativeHandler::GetExtensionId,
+ base::Unretained(this)));
+ RouteFunction("GetContextType",
+ base::Bind(&ProcessInfoNativeHandler::GetContextType,
+ base::Unretained(this)));
+ RouteFunction("InIncognitoContext",
+ base::Bind(&ProcessInfoNativeHandler::InIncognitoContext,
+ base::Unretained(this)));
+ RouteFunction("GetManifestVersion",
+ base::Bind(&ProcessInfoNativeHandler::GetManifestVersion,
+ base::Unretained(this)));
+ }
+
+ v8::Handle<v8::Value> GetExtensionId(const v8::Arguments& args) {
+ return v8::String::New(extension_id_.c_str());
+ }
+
+ v8::Handle<v8::Value> GetContextType(const v8::Arguments& args) {
+ return v8::String::New(context_type_.c_str());
+ }
+
+ v8::Handle<v8::Value> InIncognitoContext(const v8::Arguments& args) {
+ return v8::Boolean::New(is_incognito_context_);
+ }
+
+ v8::Handle<v8::Value> GetManifestVersion(const v8::Arguments& args) {
+ return v8::Integer::New(manifest_version_);
+ }
+
+ private:
+ std::string extension_id_;
+ std::string context_type_;
+ bool is_incognito_context_;
+ int manifest_version_;
+};
+
class ChannelNativeHandler : public NativeHandler {
public:
explicit ChannelNativeHandler(chrome::VersionInfo::Channel channel)
@@ -738,6 +788,16 @@ void ExtensionDispatcher::DidCreateScriptContext(
static_cast<chrome::VersionInfo::Channel>(chrome_channel_))));
module_system->RegisterNativeHandler("logging",
scoped_ptr<NativeHandler>(new LoggingNativeHandler()));
+
+
+ int manifest_version = extension ? extension->manifest_version() : 1;
+ module_system->RegisterNativeHandler("process",
+ scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler(
+ this, context->GetExtensionID(),
+ context->GetContextTypeDescription(),
+ ChromeRenderProcessObserver::is_incognito_process(),
+ manifest_version)));
+
GetOrCreateChrome(v8_context);
// Loading JavaScript is expensive, so only run the full API bindings
@@ -784,9 +844,6 @@ void ExtensionDispatcher::DidCreateScriptContext(
context->set_module_system(module_system.Pass());
- int manifest_version = 1;
- if (extension)
- manifest_version = extension->manifest_version();
context->DispatchOnLoadEvent(
ChromeRenderProcessObserver::is_incognito_process(),
manifest_version);
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context.cc ('k') | chrome/renderer/resources/extensions/extension_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698