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

Side by Side Diff: extensions/renderer/chrome_setting.cc

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "extensions/renderer/chrome_setting.h" 5 #include "extensions/renderer/chrome_setting.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "extensions/renderer/bindings/api_event_handler.h" 10 #include "extensions/renderer/bindings/api_event_handler.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 isolate, gin::StringToSymbol(isolate, "onChangeEvent")); 110 isolate, gin::StringToSymbol(isolate, "onChangeEvent"));
111 v8::Local<v8::Value> event; 111 v8::Local<v8::Value> event;
112 if (!wrapper->GetPrivate(context, key).ToLocal(&event)) { 112 if (!wrapper->GetPrivate(context, key).ToLocal(&event)) {
113 NOTREACHED(); 113 NOTREACHED();
114 return v8::Local<v8::Value>(); 114 return v8::Local<v8::Value>();
115 } 115 }
116 116
117 DCHECK(!event.IsEmpty()); 117 DCHECK(!event.IsEmpty());
118 if (event->IsUndefined()) { 118 if (event->IsUndefined()) {
119 bool supports_filters = false; 119 bool supports_filters = false;
120 bool supports_lazy_listeners = true;
120 event = event_handler_->CreateEventInstance( 121 event = event_handler_->CreateEventInstance(
121 base::StringPrintf("types.ChromeSetting.%s.onChange", 122 base::StringPrintf("types.ChromeSetting.%s.onChange",
122 pref_name_.c_str()), 123 pref_name_.c_str()),
123 supports_filters, binding::kNoListenerMax, true, context); 124 supports_filters, supports_lazy_listeners, binding::kNoListenerMax,
125 true, context);
124 v8::Maybe<bool> set_result = wrapper->SetPrivate(context, key, event); 126 v8::Maybe<bool> set_result = wrapper->SetPrivate(context, key, event);
125 if (!set_result.IsJust() || !set_result.FromJust()) { 127 if (!set_result.IsJust() || !set_result.FromJust()) {
126 NOTREACHED(); 128 NOTREACHED();
127 return v8::Local<v8::Value>(); 129 return v8::Local<v8::Value>();
128 } 130 }
129 } 131 }
130 return event; 132 return event;
131 } 133 }
132 134
133 void ChromeSetting::HandleFunction(const std::string& method_name, 135 void ChromeSetting::HandleFunction(const std::string& method_name,
(...skipping 19 matching lines...) Expand all
153 return; 155 return;
154 } 156 }
155 157
156 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_)); 158 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_));
157 request_handler_->StartRequest( 159 request_handler_->StartRequest(
158 context, full_name, std::move(converted_arguments), callback, 160 context, full_name, std::move(converted_arguments), callback,
159 v8::Local<v8::Function>(), binding::RequestThread::UI); 161 v8::Local<v8::Function>(), binding::RequestThread::UI);
160 } 162 }
161 163
162 } // namespace extensions 164 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/bindings/event_emitter_unittest.cc ('k') | extensions/renderer/event_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698