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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.cc

Issue 10704073: Plumb listenerIDs correctly for events that clobber chrome.Event.prototype.dispatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 base::Unretained(this))); 201 base::Unretained(this)));
202 } 202 }
203 203
204 v8::Handle<v8::Value> IsDevChannel(const v8::Arguments& args) { 204 v8::Handle<v8::Value> IsDevChannel(const v8::Arguments& args) {
205 return v8::Boolean::New(channel_ <= chrome::VersionInfo::CHANNEL_DEV); 205 return v8::Boolean::New(channel_ <= chrome::VersionInfo::CHANNEL_DEV);
206 } 206 }
207 207
208 chrome::VersionInfo::Channel channel_; 208 chrome::VersionInfo::Channel channel_;
209 }; 209 };
210 210
211 class DebugNativeHandler : public NativeHandler {
212 public:
213 DebugNativeHandler() {
214 RouteFunction("DCHECK",
215 base::Bind(&DebugNativeHandler::Dcheck,
216 base::Unretained(this)));
217 }
218
219 v8::Handle<v8::Value> Dcheck(const v8::Arguments& args) {
220 CHECK_LE(args.Length(), 2);
221 bool check_value = args[0]->BooleanValue();
benwells 2012/07/03 23:34:29 Oh yeah, forgot to ask: Does this handle passing n
koz (OOO until 15th September) 2012/07/05 04:38:32 This will convert any JS values to bools using the
222 std::string error_message;
223 if (args.Length() == 2)
224 error_message = *v8::String::AsciiValue(args[1]);
not at google - send to devlin 2012/07/03 07:47:04 Is there a way to get a v8 stack trace in here?
koz (OOO until 15th September) 2012/07/05 04:38:32 Yes, it turns out. Done.
225 DCHECK(check_value) << error_message;
226 return v8::Undefined();
227 }
228 };
229
211 void InstallAppBindings(ModuleSystem* module_system, 230 void InstallAppBindings(ModuleSystem* module_system,
212 v8::Handle<v8::Object> chrome, 231 v8::Handle<v8::Object> chrome,
213 v8::Handle<v8::Object> chrome_hidden) { 232 v8::Handle<v8::Object> chrome_hidden) {
214 module_system->SetLazyField(chrome, "app", "app", "chromeApp"); 233 module_system->SetLazyField(chrome, "app", "app", "chromeApp");
215 module_system->SetLazyField(chrome, "appNotifications", "app", 234 module_system->SetLazyField(chrome, "appNotifications", "app",
216 "chromeAppNotifications"); 235 "chromeAppNotifications");
217 module_system->SetLazyField(chrome_hidden, "app", "app", 236 module_system->SetLazyField(chrome_hidden, "app", "app",
218 "chromeHiddenApp"); 237 "chromeHiddenApp");
219 } 238 }
220 239
221 void InstallWebstoreBindings(ModuleSystem* module_system, 240 void InstallWebstoreBindings(ModuleSystem* module_system,
222 v8::Handle<v8::Object> chrome, 241 v8::Handle<v8::Object> chrome,
223 v8::Handle<v8::Object> chrome_hidden) { 242 v8::Handle<v8::Object> chrome_hidden) {
224 module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore"); 243 module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore");
225 module_system->SetLazyField(chrome_hidden, "webstore", "webstore", 244 module_system->SetLazyField(chrome_hidden, "webstore", "webstore",
226 "chromeHiddenWebstore"); 245 "chromeHiddenWebstore");
227 } 246 }
228 247
229 } 248 } // namespace
230 249
231 ExtensionDispatcher::ExtensionDispatcher() 250 ExtensionDispatcher::ExtensionDispatcher()
232 : is_webkit_initialized_(false), 251 : is_webkit_initialized_(false),
233 webrequest_adblock_(false), 252 webrequest_adblock_(false),
234 webrequest_adblock_plus_(false), 253 webrequest_adblock_plus_(false),
235 webrequest_other_(false), 254 webrequest_other_(false),
236 source_map_(&ResourceBundle::GetSharedInstance()), 255 source_map_(&ResourceBundle::GetSharedInstance()),
237 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), 256 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN),
238 event_filter_(new extensions::EventFilter) { 257 event_filter_(new extensions::EventFilter) {
239 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 258 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 693
675 module_system->RegisterNativeHandler("chrome_hidden", 694 module_system->RegisterNativeHandler("chrome_hidden",
676 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler())); 695 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler()));
677 module_system->RegisterNativeHandler("print", 696 module_system->RegisterNativeHandler("print",
678 scoped_ptr<NativeHandler>(new PrintNativeHandler())); 697 scoped_ptr<NativeHandler>(new PrintNativeHandler()));
679 module_system->RegisterNativeHandler("lazy_background_page", 698 module_system->RegisterNativeHandler("lazy_background_page",
680 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this))); 699 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this)));
681 module_system->RegisterNativeHandler("channel", 700 module_system->RegisterNativeHandler("channel",
682 scoped_ptr<NativeHandler>(new ChannelNativeHandler( 701 scoped_ptr<NativeHandler>(new ChannelNativeHandler(
683 static_cast<chrome::VersionInfo::Channel>(chrome_channel_)))); 702 static_cast<chrome::VersionInfo::Channel>(chrome_channel_))));
703 module_system->RegisterNativeHandler("debug",
704 scoped_ptr<NativeHandler>(new DebugNativeHandler()));
not at google - send to devlin 2012/07/03 07:47:04 drive-by: DCHECK is in base/logging.h, so perhaps
koz (OOO until 15th September) 2012/07/05 04:38:32 Done.
684 // Create the 'chrome' variable if it doesn't already exist. 705 // Create the 'chrome' variable if it doesn't already exist.
685 { 706 {
686 v8::HandleScope handle_scope; 707 v8::HandleScope handle_scope;
687 v8::Handle<v8::String> chrome_string(v8::String::New("chrome")); 708 v8::Handle<v8::String> chrome_string(v8::String::New("chrome"));
688 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); 709 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global());
689 if (global->Get(chrome_string)->IsUndefined()) 710 if (global->Get(chrome_string)->IsUndefined())
690 global->Set(chrome_string, v8::Object::New()); 711 global->Set(chrome_string, v8::Object::New());
691 } 712 }
692 713
693 // Loading JavaScript is expensive, so only run the full API bindings 714 // Loading JavaScript is expensive, so only run the full API bindings
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 // APIs, they don't get extension bindings injected. If we end up here it 1038 // APIs, they don't get extension bindings injected. If we end up here it
1018 // means that a sandboxed page somehow managed to invoke an API anyway, so 1039 // means that a sandboxed page somehow managed to invoke an API anyway, so
1019 // we should abort. 1040 // we should abort.
1020 WebKit::WebFrame* frame = context->web_frame(); 1041 WebKit::WebFrame* frame = context->web_frame();
1021 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1042 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1022 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1043 UserScriptSlave::GetDataSourceURLForFrame(frame));
1023 CHECK(!extensions_.IsSandboxedPage(url_info)); 1044 CHECK(!extensions_.IsSandboxedPage(url_info));
1024 1045
1025 return true; 1046 return true;
1026 } 1047 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698