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

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

Issue 794803002: Refactor: cleanup declarative_api.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 RouteFunction("MatchAgainstEventFilter", 158 RouteFunction("MatchAgainstEventFilter",
159 base::Bind(&EventBindings::MatchAgainstEventFilter, 159 base::Bind(&EventBindings::MatchAgainstEventFilter,
160 base::Unretained(this))); 160 base::Unretained(this)));
161 } 161 }
162 162
163 EventBindings::~EventBindings() {} 163 EventBindings::~EventBindings() {}
164 164
165 // Attach an event name to an object. 165 // Attach an event name to an object.
166 void EventBindings::AttachEvent( 166 void EventBindings::AttachEvent(
167 const v8::FunctionCallbackInfo<v8::Value>& args) { 167 const v8::FunctionCallbackInfo<v8::Value>& args) {
168 CHECK_EQ(1, args.Length()); 168 CHECK_EQ(2, args.Length());
169 CHECK(args[0]->IsString()); 169 CHECK(args[0]->IsString());
170 CHECK(args[1]->IsInt32());
170 171
171 std::string event_name = *v8::String::Utf8Value(args[0]); 172 std::string event_name = *v8::String::Utf8Value(args[0]);
173 int guest_view_instance_id = args[1]->Int32Value();
172 174
173 if (!dispatcher_->CheckContextAccessToExtensionAPI(event_name, context())) 175 if (!guest_view_instance_id &&
not at google - send to devlin 2014/12/11 22:10:48 If it's an int, prefer to use guest_view_instance_
Xi Han 2014/12/12 22:28:30 Done.
176 !dispatcher_->CheckContextAccessToExtensionAPI(event_name, context()))
not at google - send to devlin 2014/12/11 22:10:48 It's nice to surround this in {} when the conditio
Xi Han 2014/12/12 22:28:30 Done.
174 return; 177 return;
175 178
not at google - send to devlin 2014/12/11 22:10:48 All the above said, it's pretty weird to see secur
Xi Han 2014/12/12 22:28:30 As discussed offline, the problem here is: if pass
176 const std::string& extension_id = context()->GetExtensionID(); 179 const std::string& extension_id = context()->GetExtensionID();
177 if (IncrementEventListenerCount(context(), event_name) == 1) { 180 if (IncrementEventListenerCount(context(), event_name) == 1) {
178 content::RenderThread::Get()->Send(new ExtensionHostMsg_AddListener( 181 content::RenderThread::Get()->Send(new ExtensionHostMsg_AddListener(
179 extension_id, context()->GetURL(), event_name)); 182 extension_id, context()->GetURL(), event_name));
180 } 183 }
181 184
182 // This is called the first time the page has added a listener. Since 185 // This is called the first time the page has added a listener. Since
183 // the background page is the only lazy page, we know this is the first 186 // the background page is the only lazy page, we know this is the first
184 // time this listener has been registered. 187 // time this listener has been registered.
185 if (IsLazyBackgroundPage(context()->GetRenderView(), 188 if (IsLazyBackgroundPage(context()->GetRenderView(),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 321 }
319 322
320 scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher( 323 scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher(
321 base::DictionaryValue* filter_dict) { 324 base::DictionaryValue* filter_dict) {
322 return scoped_ptr<EventMatcher>(new EventMatcher( 325 return scoped_ptr<EventMatcher>(new EventMatcher(
323 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()), 326 scoped_ptr<base::DictionaryValue>(filter_dict->DeepCopy()),
324 context()->GetRenderView()->GetRoutingID())); 327 context()->GetRenderView()->GetRoutingID()));
325 } 328 }
326 329
327 } // namespace extensions 330 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698