diff options
author | dcarney@chromium.org <dcarney@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-14 11:35:25 +0000 |
---|---|---|
committer | dcarney@chromium.org <dcarney@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-14 11:35:25 +0000 |
commit | d8c5fbbbf6cec9dee5524494506cfd8ad73281b1 (patch) | |
tree | e5225c918e73de1993e713a5d9314a5975dae721 | |
parent | e63cf9561fa8b7ece2452e4f25565061eeb6e15e (diff) | |
download | chromium_src-d8c5fbbbf6cec9dee5524494506cfd8ad73281b1.zip chromium_src-d8c5fbbbf6cec9dee5524494506cfd8ad73281b1.tar.gz chromium_src-d8c5fbbbf6cec9dee5524494506cfd8ad73281b1.tar.bz2 |
Convert remaining function callbacks in chrome
R=jochen@chromium.org
BUG=243656
Review URL: https://chromiumcodereview.appspot.com/16821009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206395 0039d316-1c4b-4281-b951-d872f2087c98
55 files changed, 353 insertions, 345 deletions
diff --git a/chrome/renderer/extensions/api_activity_logger.cc b/chrome/renderer/extensions/api_activity_logger.cc index 8f8b2a8..d9980ae 100644 --- a/chrome/renderer/extensions/api_activity_logger.cc +++ b/chrome/renderer/extensions/api_activity_logger.cc @@ -22,20 +22,21 @@ APIActivityLogger::APIActivityLogger( } // static -v8::Handle<v8::Value> APIActivityLogger::LogAPICall(const v8::Arguments& args) { +void APIActivityLogger::LogAPICall( + const v8::FunctionCallbackInfo<v8::Value>& args) { LogInternal(APICALL, args); - return v8::Undefined(); } // static -v8::Handle<v8::Value> APIActivityLogger::LogEvent(const v8::Arguments& args) { +void APIActivityLogger::LogEvent( + const v8::FunctionCallbackInfo<v8::Value>& args) { LogInternal(EVENT, args); - return v8::Undefined(); } // static -void APIActivityLogger::LogInternal(const CallType call_type, - const v8::Arguments& args) { +void APIActivityLogger::LogInternal( + const CallType call_type, + const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK_GT(args.Length(), 2); DCHECK(args[0]->IsString()); DCHECK(args[1]->IsString()); diff --git a/chrome/renderer/extensions/api_activity_logger.h b/chrome/renderer/extensions/api_activity_logger.h index 86240e9..8d675aa 100644 --- a/chrome/renderer/extensions/api_activity_logger.h +++ b/chrome/renderer/extensions/api_activity_logger.h @@ -25,7 +25,7 @@ class APIActivityLogger : public ChromeV8Extension { // arg1 - API call name as a string // arg2 - arguments to the API call // arg3 - any extra logging info as a string (optional) - static v8::Handle<v8::Value> LogAPICall(const v8::Arguments& args); + static void LogAPICall(const v8::FunctionCallbackInfo<v8::Value>& args); // This is ultimately invoked in schema_generated_bindings.js with // JavaScript arguments. Logged as an EventAction. @@ -33,7 +33,7 @@ class APIActivityLogger : public ChromeV8Extension { // arg1 - Event name as a string // arg2 - Event arguments // arg3 - any extra logging info as a string (optional) - static v8::Handle<v8::Value> LogEvent(const v8::Arguments& args); + static void LogEvent(const v8::FunctionCallbackInfo<v8::Value>& args); // This is for the Dispatcher to use to log blocked API calls. static void LogBlockedCall(const std::string& extension_id, @@ -49,7 +49,7 @@ class APIActivityLogger : public ChromeV8Extension { // LogAPICall and LogEvent are really the same underneath except for // how they are ultimately dispatched to the log. static void LogInternal(const CallType call_type, - const v8::Arguments& args); + const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(APIActivityLogger); }; diff --git a/chrome/renderer/extensions/api_definitions_natives.cc b/chrome/renderer/extensions/api_definitions_natives.cc index cb337ae..2fa300b 100644 --- a/chrome/renderer/extensions/api_definitions_natives.cc +++ b/chrome/renderer/extensions/api_definitions_natives.cc @@ -23,8 +23,8 @@ ApiDefinitionsNatives::ApiDefinitionsNatives(Dispatcher* dispatcher, base::Unretained(this))); } -v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest( - const v8::Arguments& args) { +void ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest( + const v8::FunctionCallbackInfo<v8::Value>& args) { std::vector<std::string> apis; FeatureProvider* feature_provider = BaseFeatureProvider::GetByName("api"); const std::vector<std::string>& feature_names = @@ -36,7 +36,8 @@ v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest( apis.push_back(*i); } } - return dispatcher()->v8_schema_registry()->GetSchemas(apis); + args.GetReturnValue().Set( + dispatcher()->v8_schema_registry()->GetSchemas(apis)); } } // namespace extensions diff --git a/chrome/renderer/extensions/api_definitions_natives.h b/chrome/renderer/extensions/api_definitions_natives.h index d421f84d..cc3f0a7 100644 --- a/chrome/renderer/extensions/api_definitions_natives.h +++ b/chrome/renderer/extensions/api_definitions_natives.h @@ -21,8 +21,8 @@ class ApiDefinitionsNatives : public ChromeV8Extension { private: // Returns the list of all schemas that are available to the calling context. - v8::Handle<v8::Value> GetExtensionAPIDefinitionsForTest( - const v8::Arguments& args); + void GetExtensionAPIDefinitionsForTest( + const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(ApiDefinitionsNatives); }; diff --git a/chrome/renderer/extensions/app_bindings.cc b/chrome/renderer/extensions/app_bindings.cc index 733f983..3baae2a 100644 --- a/chrome/renderer/extensions/app_bindings.cc +++ b/chrome/renderer/extensions/app_bindings.cc @@ -71,34 +71,36 @@ AppBindings::AppBindings(Dispatcher* dispatcher, ChromeV8Context* context) base::Bind(&AppBindings::GetRunningState, base::Unretained(this))); } -v8::Handle<v8::Value> AppBindings::GetIsInstalled( - const v8::Arguments& args) { +void AppBindings::GetIsInstalled( + const v8::FunctionCallbackInfo<v8::Value>& args) { const Extension* extension = context()->extension(); // TODO(aa): Why only hosted app? bool result = extension && extension->is_hosted_app() && dispatcher_->IsExtensionActive(extension->id()); - return v8::Boolean::New(result); + args.GetReturnValue().Set(result); } -v8::Handle<v8::Value> AppBindings::GetDetails( - const v8::Arguments& args) { +void AppBindings::GetDetails( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(context()->web_frame()); - return GetDetailsForFrameImpl(context()->web_frame()); + args.GetReturnValue().Set(GetDetailsForFrameImpl(context()->web_frame())); } -v8::Handle<v8::Value> AppBindings::GetDetailsForFrame( - const v8::Arguments& args) { +void AppBindings::GetDetailsForFrame( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(context()->web_frame()); if (!CheckAccessToAppDetails(context()->web_frame())) - return v8::Undefined(); + return; - if (args.Length() < 0) - return v8::ThrowException(v8::String::New("Not enough arguments.")); + if (args.Length() < 0) { + v8::ThrowException(v8::String::New("Not enough arguments.")); + return; + } if (!args[0]->IsObject()) { - return v8::ThrowException( - v8::String::New("Argument 0 must be an object.")); + v8::ThrowException(v8::String::New("Argument 0 must be an object.")); + return; } v8::Local<v8::Context> context = @@ -109,10 +111,10 @@ v8::Handle<v8::Value> AppBindings::GetDetailsForFrame( if (!target_frame) { console::Error(v8::Context::GetCalling(), "Could not find frame for specified object."); - return v8::Undefined(); + return; } - return GetDetailsForFrameImpl(target_frame); + args.GetReturnValue().Set(GetDetailsForFrameImpl(target_frame)); } v8::Handle<v8::Value> AppBindings::GetDetailsForFrameImpl( @@ -132,13 +134,14 @@ v8::Handle<v8::Value> AppBindings::GetDetailsForFrameImpl( frame->mainWorldScriptContext()); } -v8::Handle<v8::Value> AppBindings::GetInstallState(const v8::Arguments& args) { +void AppBindings::GetInstallState( + const v8::FunctionCallbackInfo<v8::Value>& args) { // Get the callbackId. int callback_id = 0; if (args.Length() == 1) { if (!args[0]->IsInt32()) { v8::ThrowException(v8::String::New(kInvalidCallbackIdError)); - return v8::Undefined(); + return; } callback_id = args[0]->Int32Value(); } @@ -149,10 +152,10 @@ v8::Handle<v8::Value> AppBindings::GetInstallState(const v8::Arguments& args) { Send(new ExtensionHostMsg_GetAppInstallState( render_view->GetRoutingID(), context()->web_frame()->document().url(), GetRoutingID(), callback_id)); - return v8::Undefined(); } -v8::Handle<v8::Value> AppBindings::GetRunningState(const v8::Arguments& args) { +void AppBindings::GetRunningState( + const v8::FunctionCallbackInfo<v8::Value>& args) { // To distinguish between ready_to_run and cannot_run states, we need the top // level frame. const WebFrame* parent_frame = context()->web_frame(); @@ -169,8 +172,11 @@ v8::Handle<v8::Value> AppBindings::GetRunningState(const v8::Arguments& args) { const Extension* this_app = extensions->GetHostedAppByURL(ExtensionURLInfo( context()->web_frame()->document().url())); - if (!this_app || !parent_app) - return v8::String::New(extension_misc::kAppStateCannotRun); + if (!this_app || !parent_app) { + args.GetReturnValue().Set( + v8::String::New(extension_misc::kAppStateCannotRun)); + return; + } const char* state = NULL; if (dispatcher_->IsExtensionActive(parent_app->id())) { @@ -184,7 +190,7 @@ v8::Handle<v8::Value> AppBindings::GetRunningState(const v8::Arguments& args) { state = extension_misc::kAppStateCannotRun; } - return v8::String::New(state); + args.GetReturnValue().Set(v8::String::New(state)); } bool AppBindings::OnMessageReceived(const IPC::Message& message) { diff --git a/chrome/renderer/extensions/app_bindings.h b/chrome/renderer/extensions/app_bindings.h index 5305783..9b4cdbc 100644 --- a/chrome/renderer/extensions/app_bindings.h +++ b/chrome/renderer/extensions/app_bindings.h @@ -30,11 +30,11 @@ class AppBindings : public ChromeV8Extension, // IPC::Listener virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - v8::Handle<v8::Value> GetIsInstalled(const v8::Arguments& args); - v8::Handle<v8::Value> GetDetails(const v8::Arguments& args); - v8::Handle<v8::Value> GetDetailsForFrame(const v8::Arguments& args); - v8::Handle<v8::Value> GetInstallState(const v8::Arguments& args); - v8::Handle<v8::Value> GetRunningState(const v8::Arguments& args); + void GetIsInstalled(const v8::FunctionCallbackInfo<v8::Value>& args); + void GetDetails(const v8::FunctionCallbackInfo<v8::Value>& args); + void GetDetailsForFrame(const v8::FunctionCallbackInfo<v8::Value>& args); + void GetInstallState(const v8::FunctionCallbackInfo<v8::Value>& args); + void GetRunningState(const v8::FunctionCallbackInfo<v8::Value>& args); v8::Handle<v8::Value> GetDetailsForFrameImpl(WebKit::WebFrame* frame); diff --git a/chrome/renderer/extensions/app_runtime_custom_bindings.cc b/chrome/renderer/extensions/app_runtime_custom_bindings.cc index 812f8a0..28cb59e 100644 --- a/chrome/renderer/extensions/app_runtime_custom_bindings.cc +++ b/chrome/renderer/extensions/app_runtime_custom_bindings.cc @@ -17,7 +17,7 @@ using WebKit::WebString; namespace { -v8::Handle<v8::Value> DeserializeString(const v8::Arguments &args) { +void DeserializeString(const v8::FunctionCallbackInfo<v8::Value> &args) { DCHECK(args.Length() == 1); DCHECK(args[0]->IsString()); @@ -25,20 +25,20 @@ v8::Handle<v8::Value> DeserializeString(const v8::Arguments &args) { WebString data_webstring = WebString::fromUTF8(data_v8); WebSerializedScriptValue serialized = WebSerializedScriptValue::fromString(data_webstring); - return serialized.deserialize(); + args.GetReturnValue().Set(serialized.deserialize()); } -v8::Handle<v8::Value> SerializeToString(const v8::Arguments &args) { +void SerializeToString(const v8::FunctionCallbackInfo<v8::Value> &args) { DCHECK(args.Length() == 1); WebSerializedScriptValue data = WebSerializedScriptValue::serialize(args[0]); WebString data_webstring = data.toString(); std::string v = std::string(data_webstring.utf8()); - return v8::String::New(v.c_str()); + args.GetReturnValue().Set(v8::String::New(v.c_str())); } -v8::Handle<v8::Value> CreateBlob(const v8::Arguments &args) { +void CreateBlob(const v8::FunctionCallbackInfo<v8::Value> &args) { DCHECK(args.Length() == 2); DCHECK(args[0]->IsString()); DCHECK(args[1]->IsNumber()); @@ -49,7 +49,7 @@ v8::Handle<v8::Value> CreateBlob(const v8::Arguments &args) { DCHECK(base::StringToInt64(blob_length_string, &blob_length)); WebKit::WebBlob web_blob = WebBlob::createFromFile( WebString::fromUTF8(blob_file_path), blob_length); - return web_blob.toV8Value(); + args.GetReturnValue().Set(web_blob.toV8Value()); } } // namespace diff --git a/chrome/renderer/extensions/app_window_custom_bindings.cc b/chrome/renderer/extensions/app_window_custom_bindings.cc index 5ff47fc88..ad71214 100644 --- a/chrome/renderer/extensions/app_window_custom_bindings.cc +++ b/chrome/renderer/extensions/app_window_custom_bindings.cc @@ -101,51 +101,51 @@ class LoadWatcher : public content::RenderViewObserver { }; } // namespace -v8::Handle<v8::Value> AppWindowCustomBindings::OnContextReady( - const v8::Arguments& args) { +void AppWindowCustomBindings::OnContextReady( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 2) - return v8::Undefined(); + return; if (!args[0]->IsInt32()) - return v8::Undefined(); + return; if (!args[1]->IsFunction()) - return v8::Undefined(); + return; int view_id = args[0]->Int32Value(); content::RenderView* view = content::RenderView::FromRoutingID(view_id); if (!view) - return v8::Undefined(); + return; v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(args[1]); new LoadWatcher(args.GetIsolate(), view, func); - return v8::True(); + args.GetReturnValue().Set(true); } -v8::Handle<v8::Value> AppWindowCustomBindings::GetView( - const v8::Arguments& args) { +void AppWindowCustomBindings::GetView( + const v8::FunctionCallbackInfo<v8::Value>& args) { // TODO(jeremya): convert this to IDL nocompile to get validation, and turn // these argument checks into CHECK(). if (args.Length() != 2) - return v8::Undefined(); + return; if (!args[0]->IsInt32()) - return v8::Undefined(); + return; if (!args[1]->IsBoolean()) - return v8::Undefined(); + return; int view_id = args[0]->Int32Value(); bool inject_titlebar = args[1]->BooleanValue(); if (view_id == MSG_ROUTING_NONE) - return v8::Undefined(); + return; content::RenderView* view = content::RenderView::FromRoutingID(view_id); if (!view) - return v8::Undefined(); + return; if (inject_titlebar) new DidCreateDocumentElementObserver(view, dispatcher()); @@ -156,7 +156,7 @@ v8::Handle<v8::Value> AppWindowCustomBindings::GetView( // opener through so opener_id is set in RenderViewImpl's constructor. content::RenderView* render_view = GetRenderView(); if (!render_view) - return v8::Undefined(); + return; WebKit::WebFrame* opener = render_view->GetWebView()->mainFrame(); WebKit::WebFrame* frame = view->GetWebView()->mainFrame(); frame->setOpener(opener); @@ -164,7 +164,7 @@ v8::Handle<v8::Value> AppWindowCustomBindings::GetView( new ExtensionHostMsg_ResumeRequests(view->GetRoutingID())); v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); - return window; + args.GetReturnValue().Set(window); } } // namespace extensions diff --git a/chrome/renderer/extensions/app_window_custom_bindings.h b/chrome/renderer/extensions/app_window_custom_bindings.h index f94aa74..1c27e10 100644 --- a/chrome/renderer/extensions/app_window_custom_bindings.h +++ b/chrome/renderer/extensions/app_window_custom_bindings.h @@ -16,8 +16,8 @@ class AppWindowCustomBindings : public ChromeV8Extension { AppWindowCustomBindings(Dispatcher* dispatcher, ChromeV8Context* context); private: - v8::Handle<v8::Value> GetView(const v8::Arguments& args); - v8::Handle<v8::Value> OnContextReady(const v8::Arguments& args); + void GetView(const v8::FunctionCallbackInfo<v8::Value>& args); + void OnContextReady(const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(AppWindowCustomBindings); }; diff --git a/chrome/renderer/extensions/content_watcher.cc b/chrome/renderer/extensions/content_watcher.cc index d19960e..0af9df3 100644 --- a/chrome/renderer/extensions/content_watcher.cc +++ b/chrome/renderer/extensions/content_watcher.cc @@ -30,12 +30,11 @@ class MutationHandler : public ChromeV8Extension { } private: - v8::Handle<v8::Value> FrameMutated(const v8::Arguments& args) { + void FrameMutated(const v8::FunctionCallbackInfo<v8::Value>& args) { if (content_watcher_.get()) { content_watcher_->ScanAndNotify( WebKit::WebFrame::frameForContext(context()->v8_context())); } - return v8::Undefined(); } base::WeakPtr<ContentWatcher> content_watcher_; diff --git a/chrome/renderer/extensions/context_menus_custom_bindings.cc b/chrome/renderer/extensions/context_menus_custom_bindings.cc index 05c0c54..f70359c 100644 --- a/chrome/renderer/extensions/context_menus_custom_bindings.cc +++ b/chrome/renderer/extensions/context_menus_custom_bindings.cc @@ -12,11 +12,11 @@ namespace { -v8::Handle<v8::Value> GetNextContextMenuId(const v8::Arguments& args) { +void GetNextContextMenuId(const v8::FunctionCallbackInfo<v8::Value>& args) { int context_menu_id = -1; content::RenderThread::Get()->Send( new ExtensionHostMsg_GenerateUniqueID(&context_menu_id)); - return v8::Integer::New(context_menu_id); + args.GetReturnValue().Set(static_cast<int32_t>(context_menu_id)); } } // namespace diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc index c7290fb..59c87b4 100644 --- a/chrome/renderer/extensions/dispatcher.cc +++ b/chrome/renderer/extensions/dispatcher.cc @@ -136,13 +136,14 @@ class TestFeaturesNativeHandler : public ObjectBackedNativeHandler { } private: - v8::Handle<v8::Value> GetAPIFeatures(const v8::Arguments& args) { + void GetAPIFeatures(const v8::FunctionCallbackInfo<v8::Value>& args) { base::Value* value = base::JSONReader::Read( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_EXTENSION_API_FEATURES).as_string()); scoped_ptr<content::V8ValueConverter> converter( content::V8ValueConverter::create()); - return converter->ToV8Value(value, context()->v8_context()); + args.GetReturnValue().Set( + converter->ToV8Value(value, context()->v8_context())); } }; @@ -161,7 +162,7 @@ class V8ContextNativeHandler : public ObjectBackedNativeHandler { } private: - v8::Handle<v8::Value> GetAvailability(const v8::Arguments& args) { + void GetAvailability(const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(args.Length(), 1); std::string api_name = *v8::String::AsciiValue(args[0]->ToString()); Feature::Availability availability = context_->GetAvailability(api_name); @@ -171,17 +172,17 @@ class V8ContextNativeHandler : public ObjectBackedNativeHandler { v8::Boolean::New(availability.is_available())); ret->Set(v8::String::New("message"), v8::String::New(availability.message().c_str())); - return ret; + args.GetReturnValue().Set(ret); } - v8::Handle<v8::Value> GetModuleSystem(const v8::Arguments& args) { + void GetModuleSystem(const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(args.Length(), 1); CHECK(args[0]->IsObject()); v8::Handle<v8::Context> v8_context = v8::Handle<v8::Object>::Cast(args[0])->CreationContext(); ChromeV8Context* context = dispatcher_->v8_context_set().GetByV8Context( v8_context); - return context->module_system()->NewInstance(); + args.GetReturnValue().Set(context->module_system()->NewInstance()); } ChromeV8Context* context_; @@ -196,8 +197,8 @@ class ChromeNativeHandler : public ObjectBackedNativeHandler { base::Bind(&ChromeNativeHandler::GetChrome, base::Unretained(this))); } - v8::Handle<v8::Value> GetChrome(const v8::Arguments& args) { - return GetOrCreateChrome(context()); + void GetChrome(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(GetOrCreateChrome(context())); } }; @@ -210,16 +211,15 @@ class PrintNativeHandler : public ObjectBackedNativeHandler { base::Unretained(this))); } - v8::Handle<v8::Value> Print(const v8::Arguments& args) { + void Print(const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() < 1) - return v8::Undefined(); + return; std::vector<std::string> components; for (int i = 0; i < args.Length(); ++i) components.push_back(*v8::String::Utf8Value(args[i]->ToString())); LOG(ERROR) << JoinString(components, ','); - return v8::Undefined(); } }; @@ -236,26 +236,26 @@ class LazyBackgroundPageNativeHandler : public ChromeV8Extension { base::Unretained(this))); } - v8::Handle<v8::Value> IncrementKeepaliveCount(const v8::Arguments& args) { + void IncrementKeepaliveCount( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (!context()) - return v8::Undefined(); + return; RenderView* render_view = context()->GetRenderView(); if (IsContextLazyBackgroundPage(render_view, context()->extension())) { render_view->Send(new ExtensionHostMsg_IncrementLazyKeepaliveCount( render_view->GetRoutingID())); } - return v8::Undefined(); } - v8::Handle<v8::Value> DecrementKeepaliveCount(const v8::Arguments& args) { + void DecrementKeepaliveCount( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (!context()) - return v8::Undefined(); + return; RenderView* render_view = context()->GetRenderView(); if (IsContextLazyBackgroundPage(render_view, context()->extension())) { render_view->Send(new ExtensionHostMsg_DecrementLazyKeepaliveCount( render_view->GetRoutingID())); } - return v8::Undefined(); } private: @@ -302,29 +302,28 @@ class ProcessInfoNativeHandler : public ChromeV8Extension { base::Unretained(this))); } - v8::Handle<v8::Value> GetExtensionId(const v8::Arguments& args) { - return v8::String::New(extension_id_.c_str()); + void GetExtensionId(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(v8::String::New(extension_id_.c_str())); } - v8::Handle<v8::Value> GetContextType(const v8::Arguments& args) { - return v8::String::New(context_type_.c_str()); + void GetContextType(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(v8::String::New(context_type_.c_str())); } - v8::Handle<v8::Value> InIncognitoContext(const v8::Arguments& args) { - return v8::Boolean::New(is_incognito_context_); + void InIncognitoContext(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(is_incognito_context_); } - v8::Handle<v8::Value> GetManifestVersion(const v8::Arguments& args) { - return v8::Integer::New(manifest_version_); + void GetManifestVersion(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(static_cast<int32_t>(manifest_version_)); } - v8::Handle<v8::Value> IsSendRequestDisabled(const v8::Arguments& args) { + void IsSendRequestDisabled(const v8::FunctionCallbackInfo<v8::Value>& args) { if (send_request_disabled_) { - return v8::String::New( + args.GetReturnValue().Set(v8::String::New( "sendRequest and onRequest are obsolete." - " Please use sendMessage and onMessage instead."); + " Please use sendMessage and onMessage instead.")); } - return v8::Undefined(); } private: diff --git a/chrome/renderer/extensions/event_bindings.cc b/chrome/renderer/extensions/event_bindings.cc index ce40cb7..8d45adb 100644 --- a/chrome/renderer/extensions/event_bindings.cc +++ b/chrome/renderer/extensions/event_bindings.cc @@ -90,7 +90,7 @@ class ExtensionImpl : public ChromeV8Extension { virtual ~ExtensionImpl() {} // Attach an event name to an object. - v8::Handle<v8::Value> AttachEvent(const v8::Arguments& args) { + void AttachEvent(const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK(args.Length() == 1); // TODO(erikkay) should enforce that event name is a string in the bindings DCHECK(args[0]->IsString() || args[0]->IsUndefined()); @@ -100,7 +100,7 @@ class ExtensionImpl : public ChromeV8Extension { CHECK(context()); if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context())) - return v8::Undefined(); + return; std::string extension_id = context()->GetExtensionID(); EventListenerCounts& listener_counts = @@ -118,10 +118,9 @@ class ExtensionImpl : public ChromeV8Extension { new ExtensionHostMsg_AddLazyListener(extension_id, event_name)); } } - return v8::Undefined(); } - v8::Handle<v8::Value> DetachEvent(const v8::Arguments& args) { + void DetachEvent(const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK(args.Length() == 2); // TODO(erikkay) should enforce that event name is a string in the bindings DCHECK(args[0]->IsString() || args[0]->IsUndefined()); @@ -131,7 +130,7 @@ class ExtensionImpl : public ChromeV8Extension { bool is_manual = args[1]->BooleanValue(); if (!context()) - return v8::Undefined(); + return; std::string extension_id = context()->GetExtensionID(); EventListenerCounts& listener_counts = @@ -152,7 +151,6 @@ class ExtensionImpl : public ChromeV8Extension { new ExtensionHostMsg_RemoveLazyListener(extension_id, event_name)); } } - return v8::Undefined(); } // MatcherID AttachFilteredEvent(string event_name, object filter) @@ -160,23 +158,27 @@ class ExtensionImpl : public ChromeV8Extension { // filter - Which instances of the named event are we interested in. // returns the id assigned to the listener, which will be returned from calls // to MatchAgainstEventFilter where this listener matches. - v8::Handle<v8::Value> AttachFilteredEvent(const v8::Arguments& args) { + void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK_EQ(2, args.Length()); DCHECK(args[0]->IsString()); DCHECK(args[1]->IsObject()); DCHECK(context()); - if (!context()) - return v8::Integer::New(-1); + if (!context()) { + args.GetReturnValue().Set(static_cast<int32_t>(-1)); + return; + } std::string event_name = *v8::String::AsciiValue(args[0]); // This method throws an exception if it returns false. if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context())) - return v8::Undefined(); + return; std::string extension_id = context()->GetExtensionID(); - if (extension_id.empty()) - return v8::Integer::New(-1); + if (extension_id.empty()) { + args.GetReturnValue().Set(static_cast<int32_t>(-1)); + return; + } scoped_ptr<base::DictionaryValue> filter; scoped_ptr<content::V8ValueConverter> converter( @@ -185,11 +187,14 @@ class ExtensionImpl : public ChromeV8Extension { base::DictionaryValue* filter_dict = NULL; base::Value* filter_value = converter->FromV8Value(args[1]->ToObject(), context()->v8_context()); - if (!filter_value) - return v8::Integer::New(-1); + if (!filter_value) { + args.GetReturnValue().Set(static_cast<int32_t>(-1)); + return; + } if (!filter_value->GetAsDictionary(&filter_dict)) { delete filter_value; - return v8::Integer::New(-1); + args.GetReturnValue().Set(static_cast<int32_t>(-1)); + return; } filter.reset(filter_dict); @@ -205,7 +210,7 @@ class ExtensionImpl : public ChromeV8Extension { *filter, lazy)); } - return v8::Integer::New(id); + args.GetReturnValue().Set(static_cast<int32_t>(id)); } // Add a filter to |event_name| in |extension_id|, returning true if it @@ -240,17 +245,17 @@ class ExtensionImpl : public ChromeV8Extension { // id - Id of the event to detach. // manual - false if this is part of the extension unload process where all // listeners are automatically detached. - v8::Handle<v8::Value> DetachFilteredEvent(const v8::Arguments& args) { + void DetachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK_EQ(2, args.Length()); DCHECK(args[0]->IsInt32()); DCHECK(args[1]->IsBoolean()); bool is_manual = args[1]->BooleanValue(); if (!context()) - return v8::Undefined(); + return; std::string extension_id = context()->GetExtensionID(); if (extension_id.empty()) - return v8::Undefined(); + return; int matcher_id = args[0]->Int32Value(); EventFilter& event_filter = g_event_filter.Get(); @@ -270,11 +275,10 @@ class ExtensionImpl : public ChromeV8Extension { } event_filter.RemoveEventMatcher(matcher_id); - - return v8::Undefined(); } - v8::Handle<v8::Value> MatchAgainstEventFilter(const v8::Arguments& args) { + void MatchAgainstEventFilter( + const v8::FunctionCallbackInfo<v8::Value>& args) { typedef std::set<EventFilter::MatcherID> MatcherIDs; EventFilter& event_filter = g_event_filter.Get(); @@ -288,7 +292,7 @@ class ExtensionImpl : public ChromeV8Extension { it != matched_event_filters.end(); ++it) { array->Set(v8::Integer::New(i++), v8::Integer::New(*it)); } - return array; + args.GetReturnValue().Set(array); } static EventFilteringInfo ParseFromObject(v8::Handle<v8::Object> object) { diff --git a/chrome/renderer/extensions/extension_custom_bindings.cc b/chrome/renderer/extensions/extension_custom_bindings.cc index 17d9642..ed33fe9 100644 --- a/chrome/renderer/extensions/extension_custom_bindings.cc +++ b/chrome/renderer/extensions/extension_custom_bindings.cc @@ -35,13 +35,13 @@ ExtensionCustomBindings::ExtensionCustomBindings(Dispatcher* dispatcher, base::Unretained(this))); } -v8::Handle<v8::Value> ExtensionCustomBindings::GetExtensionViews( - const v8::Arguments& args) { +void ExtensionCustomBindings::GetExtensionViews( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 2) - return v8::Undefined(); + return; if (!args[0]->IsInt32() || !args[1]->IsString()) - return v8::Undefined(); + return; // |browser_window_id| == extension_misc::kUnknownWindowId means getting // views attached to any browser window. @@ -69,12 +69,12 @@ v8::Handle<v8::Value> ExtensionCustomBindings::GetExtensionViews( } else if (view_type_string == kViewTypePanel) { view_type = VIEW_TYPE_PANEL; } else if (view_type_string != kViewTypeAll) { - return v8::Undefined(); + return; } const Extension* extension = GetExtensionForRenderView(); if (!extension) - return v8::Undefined(); + return; std::vector<content::RenderView*> views = ExtensionHelper::GetExtensionViews( extension->id(), browser_window_id, view_type); @@ -90,7 +90,7 @@ v8::Handle<v8::Value> ExtensionCustomBindings::GetExtensionViews( } } - return v8_views; + args.GetReturnValue().Set(v8_views); } } // namespace extensions diff --git a/chrome/renderer/extensions/extension_custom_bindings.h b/chrome/renderer/extensions/extension_custom_bindings.h index 1bb3ff3..9889d35 100644 --- a/chrome/renderer/extensions/extension_custom_bindings.h +++ b/chrome/renderer/extensions/extension_custom_bindings.h @@ -17,7 +17,7 @@ class ExtensionCustomBindings : public ChromeV8Extension { ChromeV8Context* context); private: - v8::Handle<v8::Value> GetExtensionViews(const v8::Arguments& args); + void GetExtensionViews(const v8::FunctionCallbackInfo<v8::Value>& args); }; } // namespace extensions diff --git a/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc b/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc index 3c6b89c..a504b47 100644 --- a/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc +++ b/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc @@ -26,8 +26,8 @@ FileBrowserHandlerCustomBindings::FileBrowserHandlerCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> FileBrowserHandlerCustomBindings::GetExternalFileEntry( - const v8::Arguments& args) { +void FileBrowserHandlerCustomBindings::GetExternalFileEntry( + const v8::FunctionCallbackInfo<v8::Value>& args) { // TODO(zelidrag): Make this magic work on other platforms when file browser // matures enough on ChromeOS. #if defined(OS_CHROMEOS) @@ -47,14 +47,12 @@ v8::Handle<v8::Value> FileBrowserHandlerCustomBindings::GetExternalFileEntry( file_def->Get(v8::String::New("fileIsDirectory"))->ToBoolean()->Value(); WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(context()->v8_context()); - return webframe->createFileEntry( + args.GetReturnValue().Set(webframe->createFileEntry( WebKit::WebFileSystemTypeExternal, WebKit::WebString::fromUTF8(file_system_name.c_str()), WebKit::WebString::fromUTF8(file_system_path.c_str()), WebKit::WebString::fromUTF8(file_full_path.c_str()), - is_directory); -#else - return v8::Undefined(); + is_directory)); #endif } diff --git a/chrome/renderer/extensions/file_browser_handler_custom_bindings.h b/chrome/renderer/extensions/file_browser_handler_custom_bindings.h index c02e501..b7fe203 100644 --- a/chrome/renderer/extensions/file_browser_handler_custom_bindings.h +++ b/chrome/renderer/extensions/file_browser_handler_custom_bindings.h @@ -17,7 +17,7 @@ class FileBrowserHandlerCustomBindings : public ChromeV8Extension { ChromeV8Context* context); private: - v8::Handle<v8::Value> GetExternalFileEntry(const v8::Arguments& args); + void GetExternalFileEntry(const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(FileBrowserHandlerCustomBindings); }; diff --git a/chrome/renderer/extensions/file_browser_private_custom_bindings.cc b/chrome/renderer/extensions/file_browser_private_custom_bindings.cc index 2e7e54a..4484a8a2 100644 --- a/chrome/renderer/extensions/file_browser_private_custom_bindings.cc +++ b/chrome/renderer/extensions/file_browser_private_custom_bindings.cc @@ -26,8 +26,8 @@ FileBrowserPrivateCustomBindings::FileBrowserPrivateCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> FileBrowserPrivateCustomBindings::GetFileSystem( - const v8::Arguments& args) { +void FileBrowserPrivateCustomBindings::GetFileSystem( + const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK(args.Length() == 2); DCHECK(args[0]->IsString()); DCHECK(args[1]->IsString()); @@ -37,10 +37,11 @@ v8::Handle<v8::Value> FileBrowserPrivateCustomBindings::GetFileSystem( WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(context()->v8_context()); DCHECK(webframe); - return webframe->createFileSystem( - WebKit::WebFileSystemTypeExternal, - WebKit::WebString::fromUTF8(name.c_str()), - WebKit::WebString::fromUTF8(path.c_str())); + args.GetReturnValue().Set( + webframe->createFileSystem( + WebKit::WebFileSystemTypeExternal, + WebKit::WebString::fromUTF8(name.c_str()), + WebKit::WebString::fromUTF8(path.c_str()))); } } // namespace extensions diff --git a/chrome/renderer/extensions/file_browser_private_custom_bindings.h b/chrome/renderer/extensions/file_browser_private_custom_bindings.h index 951aecc..8311739 100644 --- a/chrome/renderer/extensions/file_browser_private_custom_bindings.h +++ b/chrome/renderer/extensions/file_browser_private_custom_bindings.h @@ -16,7 +16,7 @@ class FileBrowserPrivateCustomBindings : public ChromeV8Extension { FileBrowserPrivateCustomBindings(Dispatcher* dispatcher, ChromeV8Context* context); - v8::Handle<v8::Value> GetFileSystem(const v8::Arguments& args); + void GetFileSystem(const v8::FunctionCallbackInfo<v8::Value>& args); private: DISALLOW_COPY_AND_ASSIGN(FileBrowserPrivateCustomBindings); diff --git a/chrome/renderer/extensions/file_system_natives.cc b/chrome/renderer/extensions/file_system_natives.cc index 7b28e48..9642dd3 100644 --- a/chrome/renderer/extensions/file_system_natives.cc +++ b/chrome/renderer/extensions/file_system_natives.cc @@ -34,8 +34,8 @@ FileSystemNatives::FileSystemNatives(ChromeV8Context* context) base::Unretained(this))); } -v8::Handle<v8::Value> FileSystemNatives::GetIsolatedFileSystem( - const v8::Arguments& args) { +void FileSystemNatives::GetIsolatedFileSystem( + const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK(args.Length() == 1 || args.Length() == 2); DCHECK(args[0]->IsString()); std::string file_system_id(*v8::String::Utf8Value(args[0])); @@ -63,14 +63,14 @@ v8::Handle<v8::Value> FileSystemNatives::GetIsolatedFileSystem( file_system_id, optional_root_name)); - return webframe->createFileSystem( + args.GetReturnValue().Set(webframe->createFileSystem( WebKit::WebFileSystemTypeIsolated, WebKit::WebString::fromUTF8(name), - WebKit::WebString::fromUTF8(root)); + WebKit::WebString::fromUTF8(root))); } -v8::Handle<v8::Value> FileSystemNatives::GetFileEntry( - const v8::Arguments& args) { +void FileSystemNatives::GetFileEntry( + const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK(args.Length() == 5); DCHECK(args[0]->IsString()); std::string type_string = *v8::String::Utf8Value(args[0]->ToString()); @@ -78,7 +78,7 @@ v8::Handle<v8::Value> FileSystemNatives::GetFileEntry( bool is_valid_type = fileapi::GetFileSystemPublicType(type_string, &type); DCHECK(is_valid_type); if (is_valid_type == false) { - return v8::Undefined(); + return; } DCHECK(args[1]->IsString()); @@ -96,24 +96,25 @@ v8::Handle<v8::Value> FileSystemNatives::GetFileEntry( WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(context()->v8_context()); DCHECK(webframe); - return webframe->createFileEntry( + args.GetReturnValue().Set(webframe->createFileEntry( type, WebKit::WebString::fromUTF8(file_system_name), WebKit::WebString::fromUTF8(file_system_root_url), WebKit::WebString::fromUTF8(file_path_string), - is_directory); + is_directory)); } -v8::Handle<v8::Value> FileSystemNatives::CrackIsolatedFileSystemName( - const v8::Arguments& args) { +void FileSystemNatives::CrackIsolatedFileSystemName( + const v8::FunctionCallbackInfo<v8::Value>& args) { DCHECK_EQ(args.Length(), 1); DCHECK(args[0]->IsString()); std::string filesystem_name = *v8::String::Utf8Value(args[0]->ToString()); std::string filesystem_id; if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) - return v8::Undefined(); + return; - return v8::String::New(filesystem_id.c_str(), filesystem_id.size()); + args.GetReturnValue().Set( + v8::String::New(filesystem_id.c_str(), filesystem_id.size())); } } // namespace extensions diff --git a/chrome/renderer/extensions/file_system_natives.h b/chrome/renderer/extensions/file_system_natives.h index b3f9cbc..4fb4b64 100644 --- a/chrome/renderer/extensions/file_system_natives.h +++ b/chrome/renderer/extensions/file_system_natives.h @@ -16,9 +16,10 @@ class FileSystemNatives : public ObjectBackedNativeHandler { explicit FileSystemNatives(ChromeV8Context* context); private: - v8::Handle<v8::Value> GetFileEntry(const v8::Arguments& args); - v8::Handle<v8::Value> GetIsolatedFileSystem(const v8::Arguments& args); - v8::Handle<v8::Value> CrackIsolatedFileSystemName(const v8::Arguments& args); + void GetFileEntry(const v8::FunctionCallbackInfo<v8::Value>& args); + void GetIsolatedFileSystem(const v8::FunctionCallbackInfo<v8::Value>& args); + void CrackIsolatedFileSystemName( + const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(FileSystemNatives); }; diff --git a/chrome/renderer/extensions/i18n_custom_bindings.cc b/chrome/renderer/extensions/i18n_custom_bindings.cc index eade2a6..04e4573 100644 --- a/chrome/renderer/extensions/i18n_custom_bindings.cc +++ b/chrome/renderer/extensions/i18n_custom_bindings.cc @@ -20,20 +20,20 @@ I18NCustomBindings::I18NCustomBindings(Dispatcher* dispatcher, base::Bind(&I18NCustomBindings::GetL10nMessage, base::Unretained(this))); } -v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( - const v8::Arguments& args) { +void I18NCustomBindings::GetL10nMessage( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 3 || !args[0]->IsString()) { NOTREACHED() << "Bad arguments"; - return v8::Undefined(); + return; } std::string extension_id; if (args[2]->IsNull() || !args[2]->IsString()) { - return v8::Undefined(); + return; } else { extension_id = *v8::String::Utf8Value(args[2]->ToString()); if (extension_id.empty()) - return v8::Undefined(); + return; } L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id); @@ -42,7 +42,7 @@ v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( // from the correct source. content::RenderView* renderview = GetRenderView(); if (!renderview) - return v8::Undefined(); + return; L10nMessagesMap messages; // A sync call to load message catalogs for current extension. @@ -67,7 +67,7 @@ v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( v8::Local<v8::Array> placeholders = v8::Local<v8::Array>::Cast(args[1]); uint32_t count = placeholders->Length(); if (count > 9) - return v8::Undefined(); + return; for (uint32_t i = 0; i < count; ++i) { substitutions.push_back( *v8::String::Utf8Value( @@ -78,8 +78,9 @@ v8::Handle<v8::Value> I18NCustomBindings::GetL10nMessage( substitutions.push_back(*v8::String::Utf8Value(args[1]->ToString())); } - return v8::String::New(ReplaceStringPlaceholders( - message, substitutions, NULL).c_str()); + args.GetReturnValue().Set( + v8::String::New(ReplaceStringPlaceholders( + message, substitutions, NULL).c_str())); } -} // namespace extension +} // namespace extensions diff --git a/chrome/renderer/extensions/i18n_custom_bindings.h b/chrome/renderer/extensions/i18n_custom_bindings.h index 26d62a3..634c72d 100644 --- a/chrome/renderer/extensions/i18n_custom_bindings.h +++ b/chrome/renderer/extensions/i18n_custom_bindings.h @@ -15,9 +15,9 @@ class I18NCustomBindings : public ChromeV8Extension { I18NCustomBindings(Dispatcher* dispatcher, ChromeV8Context* context); private: - v8::Handle<v8::Value> GetL10nMessage(const v8::Arguments& args); + void GetL10nMessage(const v8::FunctionCallbackInfo<v8::Value>& args); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_I18N_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/logging_native_handler.cc b/chrome/renderer/extensions/logging_native_handler.cc index e919c7f..3e84fc1 100644 --- a/chrome/renderer/extensions/logging_native_handler.cc +++ b/chrome/renderer/extensions/logging_native_handler.cc @@ -25,44 +25,43 @@ LoggingNativeHandler::LoggingNativeHandler(ChromeV8Context* context) LoggingNativeHandler::~LoggingNativeHandler() {} -v8::Handle<v8::Value> LoggingNativeHandler::Check(const v8::Arguments& args) { +void LoggingNativeHandler::Check( + const v8::FunctionCallbackInfo<v8::Value>& args) { bool check_value; std::string error_message; ParseArgs(args, &check_value, &error_message); CHECK(check_value) << error_message; - return v8::Undefined(); } -v8::Handle<v8::Value> LoggingNativeHandler::Dcheck(const v8::Arguments& args) { +void LoggingNativeHandler::Dcheck( + const v8::FunctionCallbackInfo<v8::Value>& args) { bool check_value; std::string error_message; ParseArgs(args, &check_value, &error_message); DCHECK(check_value) << error_message; - return v8::Undefined(); } -v8::Handle<v8::Value> LoggingNativeHandler::DcheckIsOn( - const v8::Arguments& args) { - return v8::Boolean::New(DCHECK_IS_ON()); +void LoggingNativeHandler::DcheckIsOn( + const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(DCHECK_IS_ON()); } -v8::Handle<v8::Value> LoggingNativeHandler::Log( - const v8::Arguments& args) { +void LoggingNativeHandler::Log( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(1, args.Length()); LOG(INFO) << *v8::String::AsciiValue(args[0]); - return v8::Undefined(); } -v8::Handle<v8::Value> LoggingNativeHandler::Warning( - const v8::Arguments& args) { +void LoggingNativeHandler::Warning( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(1, args.Length()); LOG(WARNING) << *v8::String::AsciiValue(args[0]); - return v8::Undefined(); } -void LoggingNativeHandler::ParseArgs(const v8::Arguments& args, - bool* check_value, - std::string* error_message) { +void LoggingNativeHandler::ParseArgs( + const v8::FunctionCallbackInfo<v8::Value>& args, + bool* check_value, + std::string* error_message) { CHECK_LE(args.Length(), 2); *check_value = args[0]->BooleanValue(); if (args.Length() == 2) { diff --git a/chrome/renderer/extensions/logging_native_handler.h b/chrome/renderer/extensions/logging_native_handler.h index 9097522..449499b 100644 --- a/chrome/renderer/extensions/logging_native_handler.h +++ b/chrome/renderer/extensions/logging_native_handler.h @@ -20,29 +20,29 @@ class LoggingNativeHandler : public ObjectBackedNativeHandler { // Equivalent to CHECK(predicate) << message. // // void(predicate, message?) - v8::Handle<v8::Value> Check(const v8::Arguments& args); + void Check(const v8::FunctionCallbackInfo<v8::Value>& args); // Equivalent to DCHECK(predicate) << message. // // void(predicate, message?) - v8::Handle<v8::Value> Dcheck(const v8::Arguments& args); + void Dcheck(const v8::FunctionCallbackInfo<v8::Value>& args); // Equivalent to DCHECK_IS_ON(). // // bool() - v8::Handle<v8::Value> DcheckIsOn(const v8::Arguments& args); + void DcheckIsOn(const v8::FunctionCallbackInfo<v8::Value>& args); // Equivalent to LOG(INFO) << message. // // void(message) - v8::Handle<v8::Value> Log(const v8::Arguments& args); + void Log(const v8::FunctionCallbackInfo<v8::Value>& args); // Equivalent to LOG(WARNING) << message. // // void(message) - v8::Handle<v8::Value> Warning(const v8::Arguments& args); + void Warning(const v8::FunctionCallbackInfo<v8::Value>& args); - void ParseArgs(const v8::Arguments& args, + void ParseArgs(const v8::FunctionCallbackInfo<v8::Value>& args, bool* check_value, std::string* error_message); diff --git a/chrome/renderer/extensions/media_galleries_custom_bindings.cc b/chrome/renderer/extensions/media_galleries_custom_bindings.cc index 25b06ce..bf29eb7 100644 --- a/chrome/renderer/extensions/media_galleries_custom_bindings.cc +++ b/chrome/renderer/extensions/media_galleries_custom_bindings.cc @@ -29,21 +29,21 @@ MediaGalleriesCustomBindings::MediaGalleriesCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> MediaGalleriesCustomBindings::GetMediaFileSystemObject( - const v8::Arguments& args) { +void MediaGalleriesCustomBindings::GetMediaFileSystemObject( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 1) { NOTREACHED(); - return v8::Undefined(); + return; } if (!args[0]->IsString()) { NOTREACHED(); - return v8::Undefined(); + return; } std::string fsid(*v8::String::Utf8Value(args[0])); if (fsid.empty()) { NOTREACHED(); - return v8::Undefined(); + return; } WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); @@ -52,21 +52,22 @@ v8::Handle<v8::Value> MediaGalleriesCustomBindings::GetMediaFileSystemObject( const std::string root_url = fileapi::GetIsolatedFileSystemRootURIString( origin, fsid, extension_misc::kMediaFileSystemPathPart); - return webframe->createFileSystem(WebKit::WebFileSystemTypeIsolated, - WebKit::WebString::fromUTF8(fs_name), - WebKit::WebString::fromUTF8(root_url)); + args.GetReturnValue().Set( + webframe->createFileSystem(WebKit::WebFileSystemTypeIsolated, + WebKit::WebString::fromUTF8(fs_name), + WebKit::WebString::fromUTF8(root_url))); } -v8::Handle<v8::Value> MediaGalleriesCustomBindings::ExtractEmbeddedThumbnails( - const v8::Arguments& args) { +void MediaGalleriesCustomBindings::ExtractEmbeddedThumbnails( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 1) { NOTREACHED() << "Bad arguments"; - return v8::Undefined(); + return; } // TODO(vandebo) Check that the object is a FileEntry. // TODO(vandebo) Create and return a Directory entry object. - return v8::Null(); + args.GetReturnValue().SetNull(); } } // namespace extensions diff --git a/chrome/renderer/extensions/media_galleries_custom_bindings.h b/chrome/renderer/extensions/media_galleries_custom_bindings.h index 3502843b..ef72312 100644 --- a/chrome/renderer/extensions/media_galleries_custom_bindings.h +++ b/chrome/renderer/extensions/media_galleries_custom_bindings.h @@ -18,16 +18,18 @@ class MediaGalleriesCustomBindings : public ChromeV8Extension { private: // FileSystemObject GetMediaFileSystem(string file_system_url): construct // a file system object from a file system url. - v8::Handle<v8::Value> GetMediaFileSystemObject(const v8::Arguments& args); + void GetMediaFileSystemObject( + const v8::FunctionCallbackInfo<v8::Value>& args); // DirectoryReader GetMediaFileSystem(FileEntry): synchronously return a // directory reader for a virtual directory. The directory will contain // all of the thumbnails embedded in the passed file. - v8::Handle<v8::Value> ExtractEmbeddedThumbnails(const v8::Arguments& args); + void ExtractEmbeddedThumbnails( + const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(MediaGalleriesCustomBindings); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_MEDIA_GALLERIES_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/miscellaneous_bindings.cc b/chrome/renderer/extensions/miscellaneous_bindings.cc index 96f5e68..52219b6 100644 --- a/chrome/renderer/extensions/miscellaneous_bindings.cc +++ b/chrome/renderer/extensions/miscellaneous_bindings.cc @@ -90,10 +90,10 @@ class ExtensionImpl : public extensions::ChromeV8Extension { virtual ~ExtensionImpl() {} // Sends a message along the given channel. - v8::Handle<v8::Value> PostMessage(const v8::Arguments& args) { + void PostMessage(const v8::FunctionCallbackInfo<v8::Value>& args) { content::RenderView* renderview = GetRenderView(); if (!renderview) - return v8::Undefined(); + return; // Arguments are (int32 port_id, object message). CHECK_EQ(2, args.Length()); @@ -101,8 +101,9 @@ class ExtensionImpl : public extensions::ChromeV8Extension { int port_id = args[0]->Int32Value(); if (!HasPortData(port_id)) { - return v8::ThrowException(v8::Exception::Error( + v8::ThrowException(v8::Exception::Error( v8::String::New(kPortClosedError))); + return; } // The message can be any base::Value but IPC can't serialize that, so we @@ -117,12 +118,10 @@ class ExtensionImpl : public extensions::ChromeV8Extension { renderview->Send(new ExtensionHostMsg_PostMessage( renderview->GetRoutingID(), port_id, message_as_list)); - - return v8::Undefined(); } // Forcefully disconnects a port. - v8::Handle<v8::Value> CloseChannel(const v8::Arguments& args) { + void CloseChannel(const v8::FunctionCallbackInfo<v8::Value>& args) { // Arguments are (int32 port_id, boolean notify_browser). CHECK_EQ(2, args.Length()); CHECK(args[0]->IsInt32()); @@ -130,7 +129,7 @@ class ExtensionImpl : public extensions::ChromeV8Extension { int port_id = args[0]->Int32Value(); if (!HasPortData(port_id)) - return v8::Undefined(); + return; // Send via the RenderThread because the RenderView might be closing. bool notify_browser = args[1]->BooleanValue(); @@ -140,27 +139,23 @@ class ExtensionImpl : public extensions::ChromeV8Extension { } ClearPortData(port_id); - - return v8::Undefined(); } // A new port has been created for a context. This occurs both when script // opens a connection, and when a connection is opened to this script. - v8::Handle<v8::Value> PortAddRef(const v8::Arguments& args) { + void PortAddRef(const v8::FunctionCallbackInfo<v8::Value>& args) { // Arguments are (int32 port_id). CHECK_EQ(1, args.Length()); CHECK(args[0]->IsInt32()); int port_id = args[0]->Int32Value(); ++GetPortData(port_id).ref_count; - - return v8::Undefined(); } // The frame a port lived in has been destroyed. When there are no more // frames with a reference to a given port, we will disconnect it and notify // the other end of the channel. - v8::Handle<v8::Value> PortRelease(const v8::Arguments& args) { + void PortRelease(const v8::FunctionCallbackInfo<v8::Value>& args) { // Arguments are (int32 port_id). CHECK_EQ(1, args.Length()); CHECK(args[0]->IsInt32()); @@ -172,8 +167,6 @@ class ExtensionImpl : public extensions::ChromeV8Extension { new ExtensionHostMsg_CloseChannel(port_id, std::string())); ClearPortData(port_id); } - - return v8::Undefined(); } struct GCCallbackArgs { @@ -203,13 +196,12 @@ class ExtensionImpl : public extensions::ChromeV8Extension { } // Binds a callback to be invoked when the given object is garbage collected. - v8::Handle<v8::Value> BindToGC(const v8::Arguments& args) { + void BindToGC(const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(args.Length() == 2 && args[0]->IsObject() && args[1]->IsFunction()); GCCallbackArgs* context = new GCCallbackArgs( v8::Handle<v8::Object>::Cast(args[0]), v8::Handle<v8::Function>::Cast(args[1])); context->object.MakeWeak(context, GCCallback); - return v8::Undefined(); } }; diff --git a/chrome/renderer/extensions/module_system.cc b/chrome/renderer/extensions/module_system.cc index 22d5be1..8d8a01e 100644 --- a/chrome/renderer/extensions/module_system.cc +++ b/chrome/renderer/extensions/module_system.cc @@ -139,10 +139,10 @@ v8::Handle<v8::Value> ModuleSystem::Require(const std::string& module_name) { RequireForJsInner(v8::String::New(module_name.c_str()))); } -v8::Handle<v8::Value> ModuleSystem::RequireForJs(const v8::Arguments& args) { - v8::HandleScope handle_scope; +void ModuleSystem::RequireForJs( + const v8::FunctionCallbackInfo<v8::Value>& args) { v8::Handle<v8::String> module_name = args[0]->ToString(); - return handle_scope.Close(RequireForJsInner(module_name)); + args.GetReturnValue().Set(RequireForJsInner(module_name)); } v8::Handle<v8::Value> ModuleSystem::RequireForJsInner( @@ -437,10 +437,11 @@ v8::Handle<v8::Value> ModuleSystem::GetSource(const std::string& module_name) { return handle_scope.Close(source_map_->GetSource(module_name)); } -v8::Handle<v8::Value> ModuleSystem::RequireNative(const v8::Arguments& args) { +void ModuleSystem::RequireNative( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(1, args.Length()); std::string native_name = *v8::String::AsciiValue(args[0]->ToString()); - return RequireNativeFromString(native_name); + args.GetReturnValue().Set(RequireNativeFromString(native_name)); } v8::Handle<v8::Value> ModuleSystem::RequireNativeFromString( diff --git a/chrome/renderer/extensions/module_system.h b/chrome/renderer/extensions/module_system.h index cd46280..42b268f 100644 --- a/chrome/renderer/extensions/module_system.h +++ b/chrome/renderer/extensions/module_system.h @@ -74,7 +74,7 @@ class ModuleSystem : public ObjectBackedNativeHandler { // Require the specified module. This is the equivalent of calling // require('module_name') from the loaded JS files. v8::Handle<v8::Value> Require(const std::string& module_name); - v8::Handle<v8::Value> Require(const v8::Arguments& args); + void Require(const v8::FunctionCallbackInfo<v8::Value>& args); // Calls the specified method exported by the specified module. This is // equivalent to calling require('module_name').method_name() from JS. @@ -161,7 +161,7 @@ class ModuleSystem : public ObjectBackedNativeHandler { v8::Handle<v8::Value> RunString(v8::Handle<v8::String> code, v8::Handle<v8::String> name); - v8::Handle<v8::Value> RequireForJs(const v8::Arguments& args); + void RequireForJs(const v8::FunctionCallbackInfo<v8::Value>& args); v8::Handle<v8::Value> RequireForJsInner(v8::Handle<v8::String> module_name); typedef v8::Handle<v8::Value> (ModuleSystem::*RequireFunction)( @@ -181,7 +181,7 @@ class ModuleSystem : public ObjectBackedNativeHandler { // NativeHandler. // |args[0]| - the name of a native handler object. v8::Handle<v8::Value> RequireNativeFromString(const std::string& native_name); - v8::Handle<v8::Value> RequireNative(const v8::Arguments& args); + void RequireNative(const v8::FunctionCallbackInfo<v8::Value>& args); // Wraps |source| in a (function(require, requireNative, exports) {...}). v8::Handle<v8::String> WrapSource(v8::Handle<v8::String> source); diff --git a/chrome/renderer/extensions/module_system_unittest.cc b/chrome/renderer/extensions/module_system_unittest.cc index 474be7f..886961f 100644 --- a/chrome/renderer/extensions/module_system_unittest.cc +++ b/chrome/renderer/extensions/module_system_unittest.cc @@ -21,13 +21,12 @@ class CounterNatives : public ObjectBackedNativeHandler { base::Unretained(this))); } - v8::Handle<v8::Value> Get(const v8::Arguments& args) { - return v8::Integer::New(counter_); + void Get(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(static_cast<int32_t>(counter_)); } - v8::Handle<v8::Value> Increment(const v8::Arguments& args) { + void Increment(const v8::FunctionCallbackInfo<v8::Value>& args) { counter_++; - return v8::Undefined(); } private: diff --git a/chrome/renderer/extensions/object_backed_native_handler.cc b/chrome/renderer/extensions/object_backed_native_handler.cc index 2ff1b60..9f72d9d 100644 --- a/chrome/renderer/extensions/object_backed_native_handler.cc +++ b/chrome/renderer/extensions/object_backed_native_handler.cc @@ -36,8 +36,8 @@ v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() { } // static -v8::Handle<v8::Value> ObjectBackedNativeHandler::Router( - const v8::Arguments& args) { +void ObjectBackedNativeHandler::Router( + const v8::FunctionCallbackInfo<v8::Value>& args) { v8::HandleScope handle_scope; v8::Handle<v8::Object> data = args.Data().As<v8::Object>(); @@ -48,11 +48,11 @@ v8::Handle<v8::Value> ObjectBackedNativeHandler::Router( handler_function_value->IsUndefined()) { console::Error(v8::Context::GetCalling(), "Extension view no longer exists"); - return v8::Undefined(); + return; } DCHECK(handler_function_value->IsExternal()); - return handle_scope.Close(static_cast<HandlerFunction*>( - handler_function_value.As<v8::External>()->Value())->Run(args)); + static_cast<HandlerFunction*>( + handler_function_value.As<v8::External>()->Value())->Run(args); } void ObjectBackedNativeHandler::RouteFunction( diff --git a/chrome/renderer/extensions/object_backed_native_handler.h b/chrome/renderer/extensions/object_backed_native_handler.h index ac10068..27b8196 100644 --- a/chrome/renderer/extensions/object_backed_native_handler.h +++ b/chrome/renderer/extensions/object_backed_native_handler.h @@ -31,7 +31,7 @@ class ObjectBackedNativeHandler : public NativeHandler { virtual v8::Handle<v8::Object> NewInstance() OVERRIDE; protected: - typedef base::Callback<v8::Handle<v8::Value>(const v8::Arguments&)> + typedef base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)> HandlerFunction; // Installs a new 'route' from |name| to |handler_function|. This means that @@ -47,7 +47,7 @@ class ObjectBackedNativeHandler : public NativeHandler { private: // Callback for RouteFunction which routes the V8 call to the correct // base::Bound callback. - static v8::Handle<v8::Value> Router(const v8::Arguments& args); + static void Router(const v8::FunctionCallbackInfo<v8::Value>& args); // When RouteFunction is called we create a v8::Object to hold the data we // need when handling it in Router() - this is the base::Bound function to diff --git a/chrome/renderer/extensions/page_actions_custom_bindings.cc b/chrome/renderer/extensions/page_actions_custom_bindings.cc index 8326072..3c93154 100644 --- a/chrome/renderer/extensions/page_actions_custom_bindings.cc +++ b/chrome/renderer/extensions/page_actions_custom_bindings.cc @@ -23,8 +23,8 @@ PageActionsCustomBindings::PageActionsCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> PageActionsCustomBindings::GetCurrentPageActions( - const v8::Arguments& args) { +void PageActionsCustomBindings::GetCurrentPageActions( + const v8::FunctionCallbackInfo<v8::Value>& args) { std::string extension_id = *v8::String::Utf8Value(args[0]->ToString()); CHECK(!extension_id.empty()); const Extension* extension = @@ -38,7 +38,7 @@ v8::Handle<v8::Value> PageActionsCustomBindings::GetCurrentPageActions( v8::String::New(id.c_str(), id.size())); } - return page_action_vector; + args.GetReturnValue().Set(page_action_vector); } -} // extensions +} // namespace extensions diff --git a/chrome/renderer/extensions/page_actions_custom_bindings.h b/chrome/renderer/extensions/page_actions_custom_bindings.h index b8e8018..b09babd 100644 --- a/chrome/renderer/extensions/page_actions_custom_bindings.h +++ b/chrome/renderer/extensions/page_actions_custom_bindings.h @@ -17,9 +17,9 @@ class PageActionsCustomBindings : public ChromeV8Extension { ChromeV8Context* context); private: - v8::Handle<v8::Value> GetCurrentPageActions(const v8::Arguments& args); + void GetCurrentPageActions(const v8::FunctionCallbackInfo<v8::Value>& args); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_PAGE_ACTIONS_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/page_capture_custom_bindings.cc b/chrome/renderer/extensions/page_capture_custom_bindings.cc index 51f1766..e695de9 100644 --- a/chrome/renderer/extensions/page_capture_custom_bindings.cc +++ b/chrome/renderer/extensions/page_capture_custom_bindings.cc @@ -26,19 +26,19 @@ PageCaptureCustomBindings::PageCaptureCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> PageCaptureCustomBindings::CreateBlob( - const v8::Arguments& args) { +void PageCaptureCustomBindings::CreateBlob( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(args.Length() == 2); CHECK(args[0]->IsString()); CHECK(args[1]->IsInt32()); WebKit::WebString path(UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); WebKit::WebBlob blob = WebKit::WebBlob::createFromFile(path, args[1]->Int32Value()); - return blob.toV8Value(); + args.GetReturnValue().Set(blob.toV8Value()); } -v8::Handle<v8::Value> PageCaptureCustomBindings::SendResponseAck( - const v8::Arguments& args) { +void PageCaptureCustomBindings::SendResponseAck( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(args.Length() == 1); CHECK(args[0]->IsInt32()); @@ -47,7 +47,6 @@ v8::Handle<v8::Value> PageCaptureCustomBindings::SendResponseAck( render_view->Send(new ExtensionHostMsg_ResponseAck( render_view->GetRoutingID(), args[0]->Int32Value())); } - return v8::Undefined(); } } // namespace extensions diff --git a/chrome/renderer/extensions/page_capture_custom_bindings.h b/chrome/renderer/extensions/page_capture_custom_bindings.h index 60cb19c..e568ab5 100644 --- a/chrome/renderer/extensions/page_capture_custom_bindings.h +++ b/chrome/renderer/extensions/page_capture_custom_bindings.h @@ -17,8 +17,8 @@ class PageCaptureCustomBindings : public ChromeV8Extension { private: // Creates a Blob with the content of the specified file. - v8::Handle<v8::Value> CreateBlob(const v8::Arguments& args); - v8::Handle<v8::Value> SendResponseAck(const v8::Arguments& args); + void CreateBlob(const v8::FunctionCallbackInfo<v8::Value>& args); + void SendResponseAck(const v8::FunctionCallbackInfo<v8::Value>& args); }; } // namespace extensions diff --git a/chrome/renderer/extensions/runtime_custom_bindings.cc b/chrome/renderer/extensions/runtime_custom_bindings.cc index f649c73..4f3ca5f 100644 --- a/chrome/renderer/extensions/runtime_custom_bindings.cc +++ b/chrome/renderer/extensions/runtime_custom_bindings.cc @@ -39,13 +39,13 @@ RuntimeCustomBindings::RuntimeCustomBindings(Dispatcher* dispatcher, RuntimeCustomBindings::~RuntimeCustomBindings() {} -v8::Handle<v8::Value> RuntimeCustomBindings::OpenChannelToExtension( - const v8::Arguments& args) { +void RuntimeCustomBindings::OpenChannelToExtension( + const v8::FunctionCallbackInfo<v8::Value>& args) { // Get the current RenderView so that we can send a routed IPC message from // the correct source. content::RenderView* renderview = GetRenderView(); if (!renderview) - return v8::Undefined(); + return; // The Javascript code should validate/fill the arguments. CHECK_EQ(2, args.Length()); @@ -59,25 +59,25 @@ v8::Handle<v8::Value> RuntimeCustomBindings::OpenChannelToExtension( int port_id = -1; renderview->Send(new ExtensionHostMsg_OpenChannelToExtension( renderview->GetRoutingID(), info, channel_name, &port_id)); - return v8::Integer::New(port_id); + args.GetReturnValue().Set(static_cast<int32_t>(port_id)); } -v8::Handle<v8::Value> RuntimeCustomBindings::OpenChannelToNativeApp( - const v8::Arguments& args) { +void RuntimeCustomBindings::OpenChannelToNativeApp( + const v8::FunctionCallbackInfo<v8::Value>& args) { // Verify that the extension has permission to use native messaging. if (!BaseFeatureProvider::GetByName("permission")->GetFeature( "nativeMessaging")->IsAvailableToContext( GetExtensionForRenderView(), context()->context_type(), context()->GetURL()).is_available()) { - return v8::Undefined(); + return; } // Get the current RenderView so that we can send a routed IPC message from // the correct source. content::RenderView* renderview = GetRenderView(); if (!renderview) - return v8::Undefined(); + return; // The Javascript code should validate/fill the arguments. CHECK(args.Length() >= 2 && @@ -93,16 +93,17 @@ v8::Handle<v8::Value> RuntimeCustomBindings::OpenChannelToNativeApp( extension_id, native_app_name, &port_id)); - return v8::Integer::New(port_id); + args.GetReturnValue().Set(static_cast<int32_t>(port_id)); } -v8::Handle<v8::Value> RuntimeCustomBindings::GetManifest( - const v8::Arguments& args) { +void RuntimeCustomBindings::GetManifest( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(context()->extension()); scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); - return converter->ToV8Value(context()->extension()->manifest()->value(), - context()->v8_context()); + args.GetReturnValue().Set( + converter->ToV8Value(context()->extension()->manifest()->value(), + context()->v8_context())); } } // namespace extensions diff --git a/chrome/renderer/extensions/runtime_custom_bindings.h b/chrome/renderer/extensions/runtime_custom_bindings.h index b7de030..c1c2dac 100644 --- a/chrome/renderer/extensions/runtime_custom_bindings.h +++ b/chrome/renderer/extensions/runtime_custom_bindings.h @@ -22,15 +22,15 @@ class RuntimeCustomBindings : public ChromeV8Extension { virtual ~RuntimeCustomBindings(); // Creates a new messaging channel to the given extension. - v8::Handle<v8::Value> OpenChannelToExtension(const v8::Arguments& args); + void OpenChannelToExtension(const v8::FunctionCallbackInfo<v8::Value>& args); // Creates a new messaging channels for the specified native application. - v8::Handle<v8::Value> OpenChannelToNativeApp(const v8::Arguments& args); + void OpenChannelToNativeApp(const v8::FunctionCallbackInfo<v8::Value>& args); private: - v8::Handle<v8::Value> GetManifest(const v8::Arguments& args); + void GetManifest(const v8::FunctionCallbackInfo<v8::Value>& args); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_RUNTIME_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/send_request_natives.cc b/chrome/renderer/extensions/send_request_natives.cc index 2ea83a0..db07d43 100644 --- a/chrome/renderer/extensions/send_request_natives.cc +++ b/chrome/renderer/extensions/send_request_natives.cc @@ -28,15 +28,16 @@ SendRequestNatives::SendRequestNatives(Dispatcher* dispatcher, base::Unretained(this))); } -v8::Handle<v8::Value> SendRequestNatives::GetNextRequestId( - const v8::Arguments& args) { - return v8::Integer::New(request_sender_->GetNextRequestId()); +void SendRequestNatives::GetNextRequestId( + const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set(static_cast<int32_t>( + request_sender_->GetNextRequestId())); } // Starts an API request to the browser, with an optional callback. The // callback will be dispatched to EventBindings::HandleResponse. -v8::Handle<v8::Value> SendRequestNatives::StartRequest( - const v8::Arguments& args) { +void SendRequestNatives::StartRequest( + const v8::FunctionCallbackInfo<v8::Value>& args) { std::string name = *v8::String::AsciiValue(args[0]); int request_id = args[2]->Int32Value(); bool has_callback = args[3]->BooleanValue(); @@ -56,19 +57,20 @@ v8::Handle<v8::Value> SendRequestNatives::StartRequest( converter->FromV8Value(args[1], context()->v8_context())); if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) { NOTREACHED() << "Unable to convert args passed to StartRequest"; - return v8::Undefined(); + return; } request_sender_->StartRequest( context(), name, request_id, has_callback, for_io_thread, static_cast<ListValue*>(value_args.get())); - return v8::Undefined(); } -v8::Handle<v8::Value> SendRequestNatives::GetGlobal(const v8::Arguments& args) { +void SendRequestNatives::GetGlobal( + const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(1, args.Length()); CHECK(args[0]->IsObject()); - return v8::Handle<v8::Object>::Cast(args[0])->CreationContext()->Global(); + args.GetReturnValue().Set( + v8::Handle<v8::Object>::Cast(args[0])->CreationContext()->Global()); } } // namespace extensions diff --git a/chrome/renderer/extensions/send_request_natives.h b/chrome/renderer/extensions/send_request_natives.h index 54bc78f..115e0bc 100644 --- a/chrome/renderer/extensions/send_request_natives.h +++ b/chrome/renderer/extensions/send_request_natives.h @@ -23,14 +23,14 @@ class SendRequestNatives : public ChromeV8Extension { ChromeV8Context* context); private: - v8::Handle<v8::Value> GetNextRequestId(const v8::Arguments& args); + void GetNextRequestId(const v8::FunctionCallbackInfo<v8::Value>& args); // Starts an API request to the browser, with an optional callback. The // callback will be dispatched to EventBindings::HandleResponse. - v8::Handle<v8::Value> StartRequest(const v8::Arguments& args); + void StartRequest(const v8::FunctionCallbackInfo<v8::Value>& args); // Gets a reference to an object's global object. - v8::Handle<v8::Value> GetGlobal(const v8::Arguments& args); + void GetGlobal(const v8::FunctionCallbackInfo<v8::Value>& args); RequestSender* request_sender_; diff --git a/chrome/renderer/extensions/set_icon_natives.cc b/chrome/renderer/extensions/set_icon_natives.cc index 614bbb2..c8f4127 100644 --- a/chrome/renderer/extensions/set_icon_natives.cc +++ b/chrome/renderer/extensions/set_icon_natives.cc @@ -90,7 +90,8 @@ bool SetIconNatives::ConvertImageDataToBitmapValue( } bool SetIconNatives::ConvertImageDataSetToBitmapValueSet( - const v8::Arguments& args, DictionaryValue* bitmap_set_value) { + const v8::FunctionCallbackInfo<v8::Value>& args, + DictionaryValue* bitmap_set_value) { v8::Local<v8::Object> extension_args = args[1]->ToObject(); v8::Local<v8::Object> details = extension_args->Get(v8::String::New("0"))->ToObject(); @@ -111,11 +112,11 @@ bool SetIconNatives::ConvertImageDataSetToBitmapValueSet( return true; } -v8::Handle<v8::Value> SetIconNatives::SetIconCommon( - const v8::Arguments& args) { +void SetIconNatives::SetIconCommon( + const v8::FunctionCallbackInfo<v8::Value>& args) { scoped_ptr<DictionaryValue> bitmap_set_value(new DictionaryValue()); if (!ConvertImageDataSetToBitmapValueSet(args, bitmap_set_value.get())) - return v8::Undefined(); + return; v8::Local<v8::Object> extension_args = args[1]->ToObject(); v8::Local<v8::Object> details = @@ -143,7 +144,6 @@ v8::Handle<v8::Value> SetIconNatives::SetIconCommon( has_callback, for_io_thread, &list_value); - return v8::Undefined(); } } // namespace extensions diff --git a/chrome/renderer/extensions/set_icon_natives.h b/chrome/renderer/extensions/set_icon_natives.h index 6e3c6d1..7864244 100644 --- a/chrome/renderer/extensions/set_icon_natives.h +++ b/chrome/renderer/extensions/set_icon_natives.h @@ -27,9 +27,10 @@ class SetIconNatives : public ChromeV8Extension { private: bool ConvertImageDataToBitmapValue(const v8::Local<v8::Object> image_data, Value** bitmap_value); - bool ConvertImageDataSetToBitmapValueSet(const v8::Arguments& args, - DictionaryValue* bitmap_value); - v8::Handle<v8::Value> SetIconCommon(const v8::Arguments& args); + bool ConvertImageDataSetToBitmapValueSet( + const v8::FunctionCallbackInfo<v8::Value>& args, + DictionaryValue* bitmap_value); + void SetIconCommon(const v8::FunctionCallbackInfo<v8::Value>& args); RequestSender* request_sender_; diff --git a/chrome/renderer/extensions/sync_file_system_custom_bindings.cc b/chrome/renderer/extensions/sync_file_system_custom_bindings.cc index 90d860b..815b7ab 100644 --- a/chrome/renderer/extensions/sync_file_system_custom_bindings.cc +++ b/chrome/renderer/extensions/sync_file_system_custom_bindings.cc @@ -23,38 +23,38 @@ SyncFileSystemCustomBindings::SyncFileSystemCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> SyncFileSystemCustomBindings::GetSyncFileSystemObject( - const v8::Arguments& args) { +void SyncFileSystemCustomBindings::GetSyncFileSystemObject( + const v8::FunctionCallbackInfo<v8::Value>& args) { if (args.Length() != 2) { NOTREACHED(); - return v8::Undefined(); + return; } if (!args[0]->IsString()) { NOTREACHED(); - return v8::Undefined(); + return; } if (!args[1]->IsString()) { NOTREACHED(); - return v8::Undefined(); + return; } std::string name(*v8::String::Utf8Value(args[0])); if (name.empty()) { NOTREACHED(); - return v8::Undefined(); + return; } std::string root_url(*v8::String::Utf8Value(args[1])); if (root_url.empty()) { NOTREACHED(); - return v8::Undefined(); + return; } WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(context()->v8_context()); - return webframe->createFileSystem( - WebKit::WebFileSystemTypeExternal, - WebKit::WebString::fromUTF8(name), - WebKit::WebString::fromUTF8(root_url)); + args.GetReturnValue().Set( + webframe->createFileSystem(WebKit::WebFileSystemTypeExternal, + WebKit::WebString::fromUTF8(name), + WebKit::WebString::fromUTF8(root_url))); } } // namespace extensions diff --git a/chrome/renderer/extensions/sync_file_system_custom_bindings.h b/chrome/renderer/extensions/sync_file_system_custom_bindings.h index 524f669..1372dc0c 100644 --- a/chrome/renderer/extensions/sync_file_system_custom_bindings.h +++ b/chrome/renderer/extensions/sync_file_system_custom_bindings.h @@ -19,11 +19,11 @@ class SyncFileSystemCustomBindings : public ChromeV8Extension { private: // FileSystemObject GetSyncFileSystemObject(string name, string root_url): // construct a file system object from the given name and root_url. - v8::Handle<v8::Value> GetSyncFileSystemObject(const v8::Arguments& args); + void GetSyncFileSystemObject(const v8::FunctionCallbackInfo<v8::Value>& args); DISALLOW_COPY_AND_ASSIGN(SyncFileSystemCustomBindings); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_SYNC_FILE_SYSTEM_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/tabs_custom_bindings.cc b/chrome/renderer/extensions/tabs_custom_bindings.cc index 7164e6b..84db118 100644 --- a/chrome/renderer/extensions/tabs_custom_bindings.cc +++ b/chrome/renderer/extensions/tabs_custom_bindings.cc @@ -22,13 +22,13 @@ TabsCustomBindings::TabsCustomBindings(Dispatcher* dispatcher, base::Unretained(this))); } -v8::Handle<v8::Value> TabsCustomBindings::OpenChannelToTab( - const v8::Arguments& args) { +void TabsCustomBindings::OpenChannelToTab( + const v8::FunctionCallbackInfo<v8::Value>& args) { // Get the current RenderView so that we can send a routed IPC message from // the correct source. content::RenderView* renderview = GetRenderView(); if (!renderview) - return v8::Undefined(); + return; if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() && args[2]->IsString()) { @@ -39,9 +39,9 @@ v8::Handle<v8::Value> TabsCustomBindings::OpenChannelToTab( renderview->Send(new ExtensionHostMsg_OpenChannelToTab( renderview->GetRoutingID(), tab_id, extension_id, channel_name, &port_id)); - return v8::Integer::New(port_id); + args.GetReturnValue().Set(static_cast<int32_t>(port_id)); + return; } - return v8::Undefined(); } -} // extensions +} // namespace extensions diff --git a/chrome/renderer/extensions/tabs_custom_bindings.h b/chrome/renderer/extensions/tabs_custom_bindings.h index 9b501e7..e7f4ca3 100644 --- a/chrome/renderer/extensions/tabs_custom_bindings.h +++ b/chrome/renderer/extensions/tabs_custom_bindings.h @@ -16,9 +16,9 @@ class TabsCustomBindings : public ChromeV8Extension { private: // Creates a new messaging channel to the tab with the given ID. - v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args); + void OpenChannelToTab(const v8::FunctionCallbackInfo<v8::Value>& args); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_TABS_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/tts_custom_bindings.cc b/chrome/renderer/extensions/tts_custom_bindings.cc index a2d0dca..414693c 100644 --- a/chrome/renderer/extensions/tts_custom_bindings.cc +++ b/chrome/renderer/extensions/tts_custom_bindings.cc @@ -20,12 +20,12 @@ TTSCustomBindings::TTSCustomBindings( base::Unretained(this))); } -v8::Handle<v8::Value> TTSCustomBindings::GetNextTTSEventId( - const v8::Arguments& args) { +void TTSCustomBindings::GetNextTTSEventId( + const v8::FunctionCallbackInfo<v8::Value>& args) { // Note: this works because the TTS API only works in the // extension process, not content scripts. - static int next_tts_event_id = 1; - return v8::Integer::New(next_tts_event_id++); + static int32_t next_tts_event_id = 1; + args.GetReturnValue().Set(next_tts_event_id++); } -} // extensions +} // namespace extensions diff --git a/chrome/renderer/extensions/tts_custom_bindings.h b/chrome/renderer/extensions/tts_custom_bindings.h index e3a49a6..6f7f4f53 100644 --- a/chrome/renderer/extensions/tts_custom_bindings.h +++ b/chrome/renderer/extensions/tts_custom_bindings.h @@ -15,9 +15,9 @@ class TTSCustomBindings : public ChromeV8Extension { TTSCustomBindings(Dispatcher* dispatcher, ChromeV8Context* context); private: - v8::Handle<v8::Value> GetNextTTSEventId(const v8::Arguments& args); + void GetNextTTSEventId(const v8::FunctionCallbackInfo<v8::Value>& args); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_TTS_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/v8_schema_registry.cc b/chrome/renderer/extensions/v8_schema_registry.cc index 5af6fb4..33d10d9 100644 --- a/chrome/renderer/extensions/v8_schema_registry.cc +++ b/chrome/renderer/extensions/v8_schema_registry.cc @@ -33,8 +33,9 @@ class SchemaRegistryNativeHandler : public ObjectBackedNativeHandler { } private: - v8::Handle<v8::Value> GetSchema(const v8::Arguments& args) { - return registry_->GetSchema(*v8::String::AsciiValue(args[0])); + void GetSchema(const v8::FunctionCallbackInfo<v8::Value>& args) { + args.GetReturnValue().Set( + registry_->GetSchema(*v8::String::AsciiValue(args[0]))); } scoped_ptr<ChromeV8Context> context_; diff --git a/chrome/renderer/extensions/web_request_custom_bindings.cc b/chrome/renderer/extensions/web_request_custom_bindings.cc index be606ea..17e9721 100644 --- a/chrome/renderer/extensions/web_request_custom_bindings.cc +++ b/chrome/renderer/extensions/web_request_custom_bindings.cc @@ -22,15 +22,15 @@ WebRequestCustomBindings::WebRequestCustomBindings( } // Attach an event name to an object. -v8::Handle<v8::Value> WebRequestCustomBindings::GetUniqueSubEventName( - const v8::Arguments& args) { +void WebRequestCustomBindings::GetUniqueSubEventName( + const v8::FunctionCallbackInfo<v8::Value>& args) { static int next_event_id = 0; DCHECK(args.Length() == 1); DCHECK(args[0]->IsString()); std::string event_name(*v8::String::AsciiValue(args[0])); std::string unique_event_name = event_name + "/" + base::IntToString(++next_event_id); - return v8::String::New(unique_event_name.c_str()); + args.GetReturnValue().Set(v8::String::New(unique_event_name.c_str())); } -} // extensions +} // namespace extensions diff --git a/chrome/renderer/extensions/web_request_custom_bindings.h b/chrome/renderer/extensions/web_request_custom_bindings.h index fddd624..cb3779a 100644 --- a/chrome/renderer/extensions/web_request_custom_bindings.h +++ b/chrome/renderer/extensions/web_request_custom_bindings.h @@ -15,9 +15,9 @@ class WebRequestCustomBindings : public ChromeV8Extension { WebRequestCustomBindings(Dispatcher* dispatcher, ChromeV8Context* context); private: - v8::Handle<v8::Value> GetUniqueSubEventName(const v8::Arguments& args); + void GetUniqueSubEventName(const v8::FunctionCallbackInfo<v8::Value>& args); }; -} // extensions +} // namespace extensions #endif // CHROME_RENDERER_EXTENSIONS_WEB_REQUEST_CUSTOM_BINDINGS_H_ diff --git a/chrome/renderer/extensions/webstore_bindings.cc b/chrome/renderer/extensions/webstore_bindings.cc index 817440a..29e6291 100644 --- a/chrome/renderer/extensions/webstore_bindings.cc +++ b/chrome/renderer/extensions/webstore_bindings.cc @@ -61,16 +61,16 @@ WebstoreBindings::WebstoreBindings(Dispatcher* dispatcher, base::Bind(&WebstoreBindings::Install, base::Unretained(this))); } -v8::Handle<v8::Value> WebstoreBindings::Install( - const v8::Arguments& args) { +void WebstoreBindings::Install( + const v8::FunctionCallbackInfo<v8::Value>& args) { WebFrame* frame = WebFrame::frameForContext(context()->v8_context()); if (!frame || !frame->view()) - return v8::Undefined(); + return; content::RenderView* render_view = content::RenderView::FromWebView(frame->view()); if (!render_view) - return v8::Undefined(); + return; std::string preferred_store_link_url; if (!args[0]->IsUndefined()) { @@ -78,7 +78,7 @@ v8::Handle<v8::Value> WebstoreBindings::Install( preferred_store_link_url = std::string(*v8::String::Utf8Value(args[0])); } else { v8::ThrowException(v8::String::New(kPreferredStoreLinkUrlNotAString)); - return v8::Undefined(); + return; } } @@ -87,18 +87,18 @@ v8::Handle<v8::Value> WebstoreBindings::Install( if (!GetWebstoreItemIdFromFrame( frame, preferred_store_link_url, &webstore_item_id, &error)) { v8::ThrowException(v8::String::New(error.c_str())); - return v8::Undefined(); + return; } int install_id = g_next_install_id++; if (!args[1]->IsUndefined() && !args[1]->IsFunction()) { v8::ThrowException(v8::String::New(kSuccessCallbackNotAFunctionError)); - return v8::Undefined(); + return; } if (!args[2]->IsUndefined() && !args[2]->IsFunction()) { v8::ThrowException(v8::String::New(kFailureCallbackNotAFunctionError)); - return v8::Undefined(); + return; } Send(new ExtensionHostMsg_InlineWebstoreInstall( @@ -108,7 +108,7 @@ v8::Handle<v8::Value> WebstoreBindings::Install( webstore_item_id, frame->document().url())); - return v8::Integer::New(install_id); + args.GetReturnValue().Set(static_cast<int32_t>(install_id)); } // static diff --git a/chrome/renderer/extensions/webstore_bindings.h b/chrome/renderer/extensions/webstore_bindings.h index 6f6ca1b..84cd523 100644 --- a/chrome/renderer/extensions/webstore_bindings.h +++ b/chrome/renderer/extensions/webstore_bindings.h @@ -25,7 +25,7 @@ class WebstoreBindings : public ChromeV8Extension, virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; private: - v8::Handle<v8::Value> Install(const v8::Arguments& args); + void Install(const v8::FunctionCallbackInfo<v8::Value>& args); void OnInlineWebstoreInstallResponse( int install_id, bool success, const std::string& error); diff --git a/chrome/test/base/module_system_test.cc b/chrome/test/base/module_system_test.cc index c8bfe0c..27caa33 100644 --- a/chrome/test/base/module_system_test.cc +++ b/chrome/test/base/module_system_test.cc @@ -39,18 +39,16 @@ class AssertNatives : public ObjectBackedNativeHandler { bool assertion_made() { return assertion_made_; } bool failed() { return failed_; } - v8::Handle<v8::Value> AssertTrue(const v8::Arguments& args) { + void AssertTrue(const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(1, args.Length()); assertion_made_ = true; failed_ = failed_ || !args[0]->ToBoolean()->Value(); - return v8::Undefined(); } - v8::Handle<v8::Value> AssertFalse(const v8::Arguments& args) { + void AssertFalse(const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(1, args.Length()); assertion_made_ = true; failed_ = failed_ || args[0]->ToBoolean()->Value(); - return v8::Undefined(); } private: |