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

Side by Side Diff: chrome/renderer/extensions/event_bindings.cc

Issue 115681: switch to using native JSON object (Closed)
Patch Set: all in one Created 11 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/renderer/extensions/extension_api_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/event_bindings.h" 5 #include "chrome/renderer/extensions/event_bindings.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/renderer/extensions/bindings_utils.h" 10 #include "chrome/renderer/extensions/bindings_utils.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 int EventIncrementListenerCount(const std::string& event_name) { 35 int EventIncrementListenerCount(const std::string& event_name) {
36 ExtensionData *data = Singleton<ExtensionData>::get(); 36 ExtensionData *data = Singleton<ExtensionData>::get();
37 return ++(data->listener_count[event_name]); 37 return ++(data->listener_count[event_name]);
38 } 38 }
39 int EventDecrementListenerCount(const std::string& event_name) { 39 int EventDecrementListenerCount(const std::string& event_name) {
40 ExtensionData *data = Singleton<ExtensionData>::get(); 40 ExtensionData *data = Singleton<ExtensionData>::get();
41 return --(data->listener_count[event_name]); 41 return --(data->listener_count[event_name]);
42 } 42 }
43 43
44
45 const char* kExtensionDeps[] = { JsonJsV8Extension::kName };
46 const char* kContextAttachCount = "chromium.attachCount"; 44 const char* kContextAttachCount = "chromium.attachCount";
47 45
48 class ExtensionImpl : public v8::Extension { 46 class ExtensionImpl : public v8::Extension {
49 public: 47 public:
50 ExtensionImpl() 48 ExtensionImpl()
51 : v8::Extension(EventBindings::kName, 49 : v8::Extension(EventBindings::kName,
52 GetStringResource<IDR_EVENT_BINDINGS_JS>(), 50 GetStringResource<IDR_EVENT_BINDINGS_JS>(),
53 arraysize(kExtensionDeps), kExtensionDeps) { 51 0, NULL) {
54 } 52 }
55 ~ExtensionImpl() {} 53 ~ExtensionImpl() {}
56 54
57 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 55 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
58 v8::Handle<v8::String> name) { 56 v8::Handle<v8::String> name) {
59 if (name->Equals(v8::String::New("AttachEvent"))) { 57 if (name->Equals(v8::String::New("AttachEvent"))) {
60 return v8::FunctionTemplate::New(AttachEvent); 58 return v8::FunctionTemplate::New(AttachEvent);
61 } else if (name->Equals(v8::String::New("DetachEvent"))) { 59 } else if (name->Equals(v8::String::New("DetachEvent"))) {
62 return v8::FunctionTemplate::New(DetachEvent); 60 return v8::FunctionTemplate::New(DetachEvent);
63 } 61 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 v8::Local<v8::Value> function_obj = script->Run(); 177 v8::Local<v8::Value> function_obj = script->Run();
180 if (!function_obj->IsFunction()) 178 if (!function_obj->IsFunction())
181 continue; 179 continue;
182 180
183 v8::Local<v8::Function> function = 181 v8::Local<v8::Function> function =
184 v8::Local<v8::Function>::Cast(function_obj); 182 v8::Local<v8::Function>::Cast(function_obj);
185 if (!function.IsEmpty()) 183 if (!function.IsEmpty())
186 function->Call(v8::Object::New(), argc, argv); 184 function->Call(v8::Object::New(), argc, argv);
187 } 185 }
188 } 186 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/extensions/extension_api_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698