OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 base::LINKER_INITIALIZED); | 65 base::LINKER_INITIALIZED); |
66 | 66 |
67 static EventListenerCounts& GetListenerCounts(const std::string& extension_id) { | 67 static EventListenerCounts& GetListenerCounts(const std::string& extension_id) { |
68 return g_singleton_data.Get().listener_counts_[extension_id]; | 68 return g_singleton_data.Get().listener_counts_[extension_id]; |
69 } | 69 } |
70 | 70 |
71 class ExtensionImpl : public ExtensionBase { | 71 class ExtensionImpl : public ExtensionBase { |
72 public: | 72 public: |
73 ExtensionImpl() | 73 ExtensionImpl() |
74 : ExtensionBase(EventBindings::kName, | 74 : ExtensionBase(EventBindings::kName, |
75 GetStringResource<IDR_EVENT_BINDINGS_JS>(), | 75 GetStringResource(IDR_EVENT_BINDINGS_JS), |
76 0, NULL) { | 76 0, NULL) { |
77 } | 77 } |
78 ~ExtensionImpl() {} | 78 ~ExtensionImpl() {} |
79 | 79 |
80 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 80 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
81 v8::Handle<v8::String> name) { | 81 v8::Handle<v8::String> name) { |
82 if (name->Equals(v8::String::New("AttachEvent"))) { | 82 if (name->Equals(v8::String::New("AttachEvent"))) { |
83 return v8::FunctionTemplate::New(AttachEvent); | 83 return v8::FunctionTemplate::New(AttachEvent); |
84 } else if (name->Equals(v8::String::New("DetachEvent"))) { | 84 } else if (name->Equals(v8::String::New("DetachEvent"))) { |
85 return v8::FunctionTemplate::New(DetachEvent); | 85 return v8::FunctionTemplate::New(DetachEvent); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // TODO(rafaelw): Consider only doing this check if function_name == | 371 // TODO(rafaelw): Consider only doing this check if function_name == |
372 // "Event.dispatchJSON". | 372 // "Event.dispatchJSON". |
373 #ifdef _DEBUG | 373 #ifdef _DEBUG |
374 if (!retval.IsEmpty() && !retval->IsUndefined()) { | 374 if (!retval.IsEmpty() && !retval->IsUndefined()) { |
375 std::string error = *v8::String::AsciiValue(retval); | 375 std::string error = *v8::String::AsciiValue(retval); |
376 DCHECK(false) << error; | 376 DCHECK(false) << error; |
377 } | 377 } |
378 #endif | 378 #endif |
379 } | 379 } |
380 } | 380 } |
OLD | NEW |