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

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

Issue 2768093002: [Reland][Extensions Bindings] Add support for filtered events (Closed)
Patch Set: Fix Created 3 years, 9 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 | « extensions/renderer/api_event_listeners_unittest.cc ('k') | extensions/renderer/dispatcher.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 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/api_event_handler.h" 10 #include "extensions/renderer/api_event_handler.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 v8::Local<v8::Private> key = v8::Private::ForApi( 136 v8::Local<v8::Private> key = v8::Private::ForApi(
137 isolate, gin::StringToSymbol(isolate, "onChangeEvent")); 137 isolate, gin::StringToSymbol(isolate, "onChangeEvent"));
138 v8::Local<v8::Value> event; 138 v8::Local<v8::Value> event;
139 if (!wrapper->GetPrivate(context, key).ToLocal(&event)) { 139 if (!wrapper->GetPrivate(context, key).ToLocal(&event)) {
140 NOTREACHED(); 140 NOTREACHED();
141 return v8::Local<v8::Value>(); 141 return v8::Local<v8::Value>();
142 } 142 }
143 143
144 DCHECK(!event.IsEmpty()); 144 DCHECK(!event.IsEmpty());
145 if (event->IsUndefined()) { 145 if (event->IsUndefined()) {
146 bool supports_filters = false;
146 event = event_handler_->CreateEventInstance( 147 event = event_handler_->CreateEventInstance(
147 base::StringPrintf("types.ChromeSetting.%s.onChange", 148 base::StringPrintf("types.ChromeSetting.%s.onChange",
148 pref_name_.c_str()), 149 pref_name_.c_str()),
149 context); 150 supports_filters, context);
150 v8::Maybe<bool> set_result = wrapper->SetPrivate(context, key, event); 151 v8::Maybe<bool> set_result = wrapper->SetPrivate(context, key, event);
151 if (!set_result.IsJust() || !set_result.FromJust()) { 152 if (!set_result.IsJust() || !set_result.FromJust()) {
152 NOTREACHED(); 153 NOTREACHED();
153 return v8::Local<v8::Value>(); 154 return v8::Local<v8::Value>();
154 } 155 }
155 } 156 }
156 return event; 157 return event;
157 } 158 }
158 159
159 void ChromeSetting::HandleFunction(const std::string& method_name, 160 void ChromeSetting::HandleFunction(const std::string& method_name,
(...skipping 21 matching lines...) Expand all
181 return; 182 return;
182 } 183 }
183 184
184 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_)); 185 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_));
185 request_handler_->StartRequest(context, full_name, 186 request_handler_->StartRequest(context, full_name,
186 std::move(converted_arguments), callback, 187 std::move(converted_arguments), callback,
187 v8::Local<v8::Function>()); 188 v8::Local<v8::Function>());
188 } 189 }
189 190
190 } // namespace extensions 191 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api_event_listeners_unittest.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698