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

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

Issue 453613002: Implement support for <extensionoptions> embedding in WebUI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add left brace Created 6 years, 4 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/browser/guest_view/guest_view_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/event_bindings.h" 5 #include "extensions/renderer/event_bindings.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 CHECK(args[0]->IsString()); 203 CHECK(args[0]->IsString());
204 CHECK(args[1]->IsObject()); 204 CHECK(args[1]->IsObject());
205 205
206 std::string event_name = *v8::String::Utf8Value(args[0]); 206 std::string event_name = *v8::String::Utf8Value(args[0]);
207 207
208 // This method throws an exception if it returns false. 208 // This method throws an exception if it returns false.
209 if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context())) 209 if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context()))
210 return; 210 return;
211 211
212 std::string extension_id = context()->GetExtensionID(); 212 std::string extension_id = context()->GetExtensionID();
213 if (extension_id.empty()) {
214 args.GetReturnValue().Set(static_cast<int32_t>(-1));
215 return;
216 }
217 213
218 scoped_ptr<base::DictionaryValue> filter; 214 scoped_ptr<base::DictionaryValue> filter;
219 scoped_ptr<content::V8ValueConverter> converter( 215 scoped_ptr<content::V8ValueConverter> converter(
220 content::V8ValueConverter::create()); 216 content::V8ValueConverter::create());
221 217
222 base::DictionaryValue* filter_dict = NULL; 218 base::DictionaryValue* filter_dict = NULL;
223 base::Value* filter_value = 219 base::Value* filter_value =
224 converter->FromV8Value(args[1]->ToObject(), context()->v8_context()); 220 converter->FromV8Value(args[1]->ToObject(), context()->v8_context());
225 if (!filter_value) { 221 if (!filter_value) {
226 args.GetReturnValue().Set(static_cast<int32_t>(-1)); 222 args.GetReturnValue().Set(static_cast<int32_t>(-1));
(...skipping 22 matching lines...) Expand all
249 } 245 }
250 246
251 void EventBindings::DetachFilteredEvent( 247 void EventBindings::DetachFilteredEvent(
252 const v8::FunctionCallbackInfo<v8::Value>& args) { 248 const v8::FunctionCallbackInfo<v8::Value>& args) {
253 CHECK_EQ(2, args.Length()); 249 CHECK_EQ(2, args.Length());
254 CHECK(args[0]->IsInt32()); 250 CHECK(args[0]->IsInt32());
255 CHECK(args[1]->IsBoolean()); 251 CHECK(args[1]->IsBoolean());
256 bool is_manual = args[1]->BooleanValue(); 252 bool is_manual = args[1]->BooleanValue();
257 253
258 std::string extension_id = context()->GetExtensionID(); 254 std::string extension_id = context()->GetExtensionID();
259 if (extension_id.empty())
260 return;
261 255
262 int matcher_id = args[0]->Int32Value(); 256 int matcher_id = args[0]->Int32Value();
263 EventFilter& event_filter = g_event_filter.Get(); 257 EventFilter& event_filter = g_event_filter.Get();
264 EventMatcher* event_matcher = event_filter.GetEventMatcher(matcher_id); 258 EventMatcher* event_matcher = event_filter.GetEventMatcher(matcher_id);
265 259
266 const std::string& event_name = event_filter.GetEventName(matcher_id); 260 const std::string& event_name = event_filter.GetEventName(matcher_id);
267 261
268 // Only send IPCs the last time a filter gets removed. 262 // Only send IPCs the last time a filter gets removed.
269 if (RemoveFilter(event_name, extension_id, event_matcher->value())) { 263 if (RemoveFilter(event_name, extension_id, event_matcher->value())) {
270 bool lazy = is_manual && IsLazyBackgroundPage(context()->GetRenderView(), 264 bool lazy = is_manual && IsLazyBackgroundPage(context()->GetRenderView(),
(...skipping 29 matching lines...) Expand all
300 } 294 }
301 295
302 scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher( 296 scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher(
303 base::DictionaryValue* filter_dict) { 297 base::DictionaryValue* filter_dict) {
304 return scoped_ptr<EventMatcher>(new EventMatcher( 298 return scoped_ptr<EventMatcher>(new EventMatcher(
305 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()), 299 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()),
306 context()->GetRenderView()->GetRoutingID())); 300 context()->GetRenderView()->GetRoutingID()));
307 } 301 }
308 302
309 } // namespace extensions 303 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/guest_view_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698