| OLD | NEW |
| 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/process_info_native_handler.h" | 5 #include "extensions/renderer/process_info_native_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "extensions/renderer/bindings/api_binding_util.h" |
| 11 #include "extensions/renderer/script_context.h" | 12 #include "extensions/renderer/script_context.h" |
| 13 #include "gin/converter.h" |
| 12 | 14 |
| 13 namespace extensions { | 15 namespace extensions { |
| 14 | 16 |
| 15 ProcessInfoNativeHandler::ProcessInfoNativeHandler( | 17 ProcessInfoNativeHandler::ProcessInfoNativeHandler( |
| 16 ScriptContext* context, | 18 ScriptContext* context, |
| 17 const std::string& extension_id, | 19 const std::string& extension_id, |
| 18 const std::string& context_type, | 20 const std::string& context_type, |
| 19 bool is_incognito_context, | 21 bool is_incognito_context, |
| 20 bool is_component_extension, | 22 bool is_component_extension, |
| 21 int manifest_version, | 23 int manifest_version, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 41 base::Unretained(this))); | 43 base::Unretained(this))); |
| 42 RouteFunction("GetManifestVersion", | 44 RouteFunction("GetManifestVersion", |
| 43 base::Bind(&ProcessInfoNativeHandler::GetManifestVersion, | 45 base::Bind(&ProcessInfoNativeHandler::GetManifestVersion, |
| 44 base::Unretained(this))); | 46 base::Unretained(this))); |
| 45 RouteFunction("IsSendRequestDisabled", | 47 RouteFunction("IsSendRequestDisabled", |
| 46 base::Bind(&ProcessInfoNativeHandler::IsSendRequestDisabled, | 48 base::Bind(&ProcessInfoNativeHandler::IsSendRequestDisabled, |
| 47 base::Unretained(this))); | 49 base::Unretained(this))); |
| 48 RouteFunction( | 50 RouteFunction( |
| 49 "HasSwitch", | 51 "HasSwitch", |
| 50 base::Bind(&ProcessInfoNativeHandler::HasSwitch, base::Unretained(this))); | 52 base::Bind(&ProcessInfoNativeHandler::HasSwitch, base::Unretained(this))); |
| 53 RouteFunction("GetPlatform", |
| 54 base::Bind(&ProcessInfoNativeHandler::GetPlatform, |
| 55 base::Unretained(this))); |
| 51 } | 56 } |
| 52 | 57 |
| 53 void ProcessInfoNativeHandler::GetExtensionId( | 58 void ProcessInfoNativeHandler::GetExtensionId( |
| 54 const v8::FunctionCallbackInfo<v8::Value>& args) { | 59 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 55 args.GetReturnValue().Set( | 60 args.GetReturnValue().Set( |
| 56 v8::String::NewFromUtf8(args.GetIsolate(), extension_id_.c_str())); | 61 v8::String::NewFromUtf8(args.GetIsolate(), extension_id_.c_str())); |
| 57 } | 62 } |
| 58 | 63 |
| 59 void ProcessInfoNativeHandler::GetContextType( | 64 void ProcessInfoNativeHandler::GetContextType( |
| 60 const v8::FunctionCallbackInfo<v8::Value>& args) { | 65 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 } | 93 } |
| 89 | 94 |
| 90 void ProcessInfoNativeHandler::HasSwitch( | 95 void ProcessInfoNativeHandler::HasSwitch( |
| 91 const v8::FunctionCallbackInfo<v8::Value>& args) { | 96 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 92 CHECK(args.Length() == 1 && args[0]->IsString()); | 97 CHECK(args.Length() == 1 && args[0]->IsString()); |
| 93 bool has_switch = base::CommandLine::ForCurrentProcess()->HasSwitch( | 98 bool has_switch = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 94 *v8::String::Utf8Value(args[0])); | 99 *v8::String::Utf8Value(args[0])); |
| 95 args.GetReturnValue().Set(v8::Boolean::New(args.GetIsolate(), has_switch)); | 100 args.GetReturnValue().Set(v8::Boolean::New(args.GetIsolate(), has_switch)); |
| 96 } | 101 } |
| 97 | 102 |
| 103 void ProcessInfoNativeHandler::GetPlatform( |
| 104 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 105 CHECK_EQ(0, args.Length()); |
| 106 args.GetReturnValue().Set( |
| 107 gin::StringToSymbol(args.GetIsolate(), binding::GetPlatformString())); |
| 108 } |
| 109 |
| 98 } // namespace extensions | 110 } // namespace extensions |
| OLD | NEW |