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

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: rebase 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
« no previous file with comments | « chrome/renderer/extensions/event_unittest.cc ('k') | chrome/renderer/module_system.h » ('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 (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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 base::Unretained(this))); 204 base::Unretained(this)));
205 } 205 }
206 206
207 v8::Handle<v8::Value> IsDevChannel(const v8::Arguments& args) { 207 v8::Handle<v8::Value> IsDevChannel(const v8::Arguments& args) {
208 return v8::Boolean::New(channel_ <= chrome::VersionInfo::CHANNEL_DEV); 208 return v8::Boolean::New(channel_ <= chrome::VersionInfo::CHANNEL_DEV);
209 } 209 }
210 210
211 chrome::VersionInfo::Channel channel_; 211 chrome::VersionInfo::Channel channel_;
212 }; 212 };
213 213
214 class LoggingNativeHandler : public NativeHandler {
215 public:
216 LoggingNativeHandler() {
217 RouteFunction("DCHECK",
218 base::Bind(&LoggingNativeHandler::Dcheck,
219 base::Unretained(this)));
220 }
221
222 v8::Handle<v8::Value> Dcheck(const v8::Arguments& args) {
223 CHECK_LE(args.Length(), 2);
224 bool check_value = args[0]->BooleanValue();
225 std::string error_message;
226 if (args.Length() == 2)
227 error_message += "Error: " + std::string(*v8::String::AsciiValue(args[1]))
228 + "\n";
229
230 v8::Handle<v8::Array> stack_trace(
231 v8::StackTrace::CurrentStackTrace(10)->AsArray());
232 error_message += "Stack trace: {\n";
233 for (size_t i = 0; i < stack_trace->Length(); i++) {
234 error_message += " "
235 + std::string(*v8::String::AsciiValue(stack_trace->Get(i))) + "\n";
236 }
237 error_message += "}";
238 DCHECK(check_value) << error_message;
239 return v8::Undefined();
240 }
241 };
242
214 void InstallAppBindings(ModuleSystem* module_system, 243 void InstallAppBindings(ModuleSystem* module_system,
215 v8::Handle<v8::Object> chrome, 244 v8::Handle<v8::Object> chrome,
216 v8::Handle<v8::Object> chrome_hidden) { 245 v8::Handle<v8::Object> chrome_hidden) {
217 module_system->SetLazyField(chrome, "app", "app", "chromeApp"); 246 module_system->SetLazyField(chrome, "app", "app", "chromeApp");
218 module_system->SetLazyField(chrome, "appNotifications", "app", 247 module_system->SetLazyField(chrome, "appNotifications", "app",
219 "chromeAppNotifications"); 248 "chromeAppNotifications");
220 module_system->SetLazyField(chrome_hidden, "app", "app", 249 module_system->SetLazyField(chrome_hidden, "app", "app",
221 "chromeHiddenApp"); 250 "chromeHiddenApp");
222 } 251 }
223 252
224 void InstallWebstoreBindings(ModuleSystem* module_system, 253 void InstallWebstoreBindings(ModuleSystem* module_system,
225 v8::Handle<v8::Object> chrome, 254 v8::Handle<v8::Object> chrome,
226 v8::Handle<v8::Object> chrome_hidden) { 255 v8::Handle<v8::Object> chrome_hidden) {
227 module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore"); 256 module_system->SetLazyField(chrome, "webstore", "webstore", "chromeWebstore");
228 module_system->SetLazyField(chrome_hidden, "webstore", "webstore", 257 module_system->SetLazyField(chrome_hidden, "webstore", "webstore",
229 "chromeHiddenWebstore"); 258 "chromeHiddenWebstore");
230 } 259 }
231 260
232 } 261 } // namespace
233 262
234 ExtensionDispatcher::ExtensionDispatcher() 263 ExtensionDispatcher::ExtensionDispatcher()
235 : is_webkit_initialized_(false), 264 : is_webkit_initialized_(false),
236 webrequest_adblock_(false), 265 webrequest_adblock_(false),
237 webrequest_adblock_plus_(false), 266 webrequest_adblock_plus_(false),
238 webrequest_other_(false), 267 webrequest_other_(false),
239 source_map_(&ResourceBundle::GetSharedInstance()), 268 source_map_(&ResourceBundle::GetSharedInstance()),
240 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), 269 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN),
241 event_filter_(new extensions::EventFilter) { 270 event_filter_(new extensions::EventFilter) {
242 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 271 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 712
684 module_system->RegisterNativeHandler("chrome_hidden", 713 module_system->RegisterNativeHandler("chrome_hidden",
685 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler())); 714 scoped_ptr<NativeHandler>(new ChromeHiddenNativeHandler()));
686 module_system->RegisterNativeHandler("print", 715 module_system->RegisterNativeHandler("print",
687 scoped_ptr<NativeHandler>(new PrintNativeHandler())); 716 scoped_ptr<NativeHandler>(new PrintNativeHandler()));
688 module_system->RegisterNativeHandler("lazy_background_page", 717 module_system->RegisterNativeHandler("lazy_background_page",
689 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this))); 718 scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(this)));
690 module_system->RegisterNativeHandler("channel", 719 module_system->RegisterNativeHandler("channel",
691 scoped_ptr<NativeHandler>(new ChannelNativeHandler( 720 scoped_ptr<NativeHandler>(new ChannelNativeHandler(
692 static_cast<chrome::VersionInfo::Channel>(chrome_channel_)))); 721 static_cast<chrome::VersionInfo::Channel>(chrome_channel_))));
722 module_system->RegisterNativeHandler("logging",
723 scoped_ptr<NativeHandler>(new LoggingNativeHandler()));
693 // Create the 'chrome' variable if it doesn't already exist. 724 // Create the 'chrome' variable if it doesn't already exist.
694 { 725 {
695 v8::HandleScope handle_scope; 726 v8::HandleScope handle_scope;
696 v8::Handle<v8::String> chrome_string(v8::String::New("chrome")); 727 v8::Handle<v8::String> chrome_string(v8::String::New("chrome"));
697 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global()); 728 v8::Handle<v8::Object> global(v8::Context::GetCurrent()->Global());
698 v8::Handle<v8::Value> chrome(global->Get(chrome_string)); 729 v8::Handle<v8::Value> chrome(global->Get(chrome_string));
699 if (chrome.IsEmpty() || chrome->IsUndefined()) 730 if (chrome.IsEmpty() || chrome->IsUndefined())
700 global->Set(chrome_string, v8::Object::New()); 731 global->Set(chrome_string, v8::Object::New());
701 } 732 }
702 733
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 // APIs, they don't get extension bindings injected. If we end up here it 1063 // APIs, they don't get extension bindings injected. If we end up here it
1033 // means that a sandboxed page somehow managed to invoke an API anyway, so 1064 // means that a sandboxed page somehow managed to invoke an API anyway, so
1034 // we should abort. 1065 // we should abort.
1035 WebKit::WebFrame* frame = context->web_frame(); 1066 WebKit::WebFrame* frame = context->web_frame();
1036 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1067 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1037 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1068 UserScriptSlave::GetDataSourceURLForFrame(frame));
1038 CHECK(!extensions_.IsSandboxedPage(url_info)); 1069 CHECK(!extensions_.IsSandboxedPage(url_info));
1039 1070
1040 return true; 1071 return true;
1041 } 1072 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/event_unittest.cc ('k') | chrome/renderer/module_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698