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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "grit/renderer_resources.h" | 10 #include "grit/renderer_resources.h" |
11 #include "v8/include/v8.h" | 11 #include "v8/include/v8.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 WebRequestCustomBindings::WebRequestCustomBindings() | 15 WebRequestCustomBindings::WebRequestCustomBindings( |
16 : ChromeV8Extension(NULL) { | 16 Dispatcher* dispatcher, v8::Handle<v8::Context> v8_context) |
| 17 : ChromeV8Extension(dispatcher, v8_context) { |
17 RouteStaticFunction("GetUniqueSubEventName", &GetUniqueSubEventName); | 18 RouteStaticFunction("GetUniqueSubEventName", &GetUniqueSubEventName); |
18 } | 19 } |
19 | 20 |
20 // Attach an event name to an object. | 21 // Attach an event name to an object. |
21 // static | 22 // static |
22 v8::Handle<v8::Value> WebRequestCustomBindings::GetUniqueSubEventName( | 23 v8::Handle<v8::Value> WebRequestCustomBindings::GetUniqueSubEventName( |
23 const v8::Arguments& args) { | 24 const v8::Arguments& args) { |
24 static int next_event_id = 0; | 25 static int next_event_id = 0; |
25 DCHECK(args.Length() == 1); | 26 DCHECK(args.Length() == 1); |
26 DCHECK(args[0]->IsString()); | 27 DCHECK(args[0]->IsString()); |
27 std::string event_name(*v8::String::AsciiValue(args[0])); | 28 std::string event_name(*v8::String::AsciiValue(args[0])); |
28 std::string unique_event_name = | 29 std::string unique_event_name = |
29 event_name + "/" + base::IntToString(++next_event_id); | 30 event_name + "/" + base::IntToString(++next_event_id); |
30 return v8::String::New(unique_event_name.c_str()); | 31 return v8::String::New(unique_event_name.c_str()); |
31 } | 32 } |
32 | 33 |
33 } // extensions | 34 } // extensions |
34 | 35 |
OLD | NEW |