OLD | NEW |
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/web_request_custom_bindings.h" | 5 #include "chrome/renderer/extensions/web_request_custom_bindings.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "grit/renderer_resources.h" | 10 #include "grit/renderer_resources.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 static v8::Handle<v8::Value> GetUniqueSubEventName(const v8::Arguments& args) { | 26 static v8::Handle<v8::Value> GetUniqueSubEventName(const v8::Arguments& args) { |
27 static int next_event_id = 0; | 27 static int next_event_id = 0; |
28 DCHECK(args.Length() == 1); | 28 DCHECK(args.Length() == 1); |
29 DCHECK(args[0]->IsString()); | 29 DCHECK(args[0]->IsString()); |
30 std::string event_name(*v8::String::AsciiValue(args[0])); | 30 std::string event_name(*v8::String::AsciiValue(args[0])); |
31 std::string unique_event_name = | 31 std::string unique_event_name = |
32 event_name + "/" + base::IntToString(++next_event_id); | 32 event_name + "/" + base::IntToString(++next_event_id); |
33 return v8::String::New(unique_event_name.c_str()); | 33 return v8::String::New(unique_event_name.c_str()); |
34 } | 34 } |
35 | 35 |
36 v8::Handle<v8::FunctionTemplate> WebRequestCustomBindings::GetNativeFunction( | 36 void WebRequestCustomBindings::SetNativeFunctions( |
37 v8::Handle<v8::String> name) { | 37 v8::Handle<v8::Object> object) { |
38 if (name->Equals(v8::String::New("GetUniqueSubEventName"))) | 38 RouteFunctionToStatic("GetUniqueSubEventName", GetUniqueSubEventName, object); |
39 return v8::FunctionTemplate::New(GetUniqueSubEventName); | |
40 | |
41 return ChromeV8Extension::GetNativeFunction(name); | |
42 } | 39 } |
43 | 40 |
44 } // extensions | 41 } // extensions |
45 | 42 |
OLD | NEW |