Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 using WebKit::WebVector; | 40 using WebKit::WebVector; |
| 41 | 41 |
| 42 namespace content { | 42 namespace content { |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 const char kCrashEventName[] = "crash"; | 45 const char kCrashEventName[] = "crash"; |
| 46 const char kIsTopLevel[] = "isTopLevel"; | 46 const char kIsTopLevel[] = "isTopLevel"; |
| 47 const char kLoadAbortEventName[] = "loadAbort"; | 47 const char kLoadAbortEventName[] = "loadAbort"; |
| 48 const char kLoadRedirectEventName[] = "loadRedirect"; | 48 const char kLoadRedirectEventName[] = "loadRedirect"; |
| 49 const char kLoadStartEventName[] = "loadStart"; | 49 const char kLoadStartEventName[] = "loadStart"; |
| 50 const char kLoadStopEventName[] = "loadStop"; | |
| 51 const char kLoadCommitEventName[] = "loadCommit"; | |
|
Charlie Reis
2012/10/08 19:03:39
Please keep these alphabetized.
irobert
2012/10/10 23:55:16
Done.
| |
| 50 const char kNavigationEventName[] = "navigation"; | 52 const char kNavigationEventName[] = "navigation"; |
|
Charlie Reis
2012/10/08 19:03:39
We can remove this one now, right?
irobert
2012/10/10 23:55:16
Done.
| |
| 51 const char kNewURL[] = "newUrl"; | 53 const char kNewURL[] = "newUrl"; |
| 52 const char kOldURL[] = "oldUrl"; | 54 const char kOldURL[] = "oldUrl"; |
| 53 const char kPartitionAttribute[] = "partition"; | 55 const char kPartitionAttribute[] = "partition"; |
| 54 const char kPersistPrefix[] = "persist:"; | 56 const char kPersistPrefix[] = "persist:"; |
| 55 const char kSrcAttribute[] = "src"; | 57 const char kSrcAttribute[] = "src"; |
| 56 const char kType[] = "type"; | 58 const char kType[] = "type"; |
| 57 const char kURL[] = "url"; | 59 const char kURL[] = "url"; |
| 58 } | 60 } |
| 59 | 61 |
| 60 BrowserPlugin::BrowserPlugin( | 62 BrowserPlugin::BrowserPlugin( |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 v8::Context::Scope context_scope(v8::Context::New()); | 331 v8::Context::Scope context_scope(v8::Context::New()); |
| 330 v8::HandleScope handle_scope; | 332 v8::HandleScope handle_scope; |
| 331 container()->element().document().frame()-> | 333 container()->element().document().frame()-> |
| 332 callFunctionEvenIfScriptDisabled(*it, | 334 callFunctionEvenIfScriptDisabled(*it, |
| 333 v8::Object::New(), | 335 v8::Object::New(), |
| 334 0, | 336 0, |
| 335 NULL); | 337 NULL); |
| 336 } | 338 } |
| 337 } | 339 } |
| 338 | 340 |
| 339 void BrowserPlugin::DidNavigate(const GURL& url, int process_id) { | 341 void BrowserPlugin::LoadStop() { |
| 340 src_ = url.spec(); | 342 if (!HasListeners(kLoadStopEventName)) |
| 341 process_id_ = process_id; | |
| 342 if (!HasListeners(kNavigationEventName)) | |
| 343 return; | 343 return; |
| 344 EventListeners& listeners = event_listener_map_[kLoadStopEventName]; | |
| 345 EventListeners::iterator it = listeners.begin(); | |
| 344 | 346 |
| 345 EventListeners& listeners = event_listener_map_[kNavigationEventName]; | 347 v8::Context::Scope context_scope(v8::Context::New()); |
| 346 EventListeners::iterator it = listeners.begin(); | 348 v8::HandleScope handle_scope; |
| 349 // Construct the loadStop event object. | |
| 350 v8::Local<v8::Value> event = | |
| 351 v8::Local<v8::Object>::New(v8::Object::New()); | |
| 347 for (; it != listeners.end(); ++it) { | 352 for (; it != listeners.end(); ++it) { |
| 348 v8::Context::Scope context_scope(v8::Context::New()); | 353 // Fire the event listener. |
| 349 v8::HandleScope handle_scope; | |
| 350 v8::Local<v8::Value> param = | |
| 351 v8::Local<v8::Value>::New(v8::String::New(src_.c_str())); | |
| 352 container()->element().document().frame()-> | 354 container()->element().document().frame()-> |
| 353 callFunctionEvenIfScriptDisabled(*it, | 355 callFunctionEvenIfScriptDisabled(*it, |
| 354 v8::Object::New(), | 356 v8::Object::New(), |
| 355 1, | 357 1, |
| 356 ¶m); | 358 &event); |
| 357 } | 359 } |
| 358 } | 360 } |
| 359 | 361 |
| 362 void BrowserPlugin::LoadCommit( | |
| 363 const GURL& url, | |
| 364 int process_id, | |
| 365 bool is_top_level) { | |
| 366 process_id_ = process_id; | |
| 367 if (!HasListeners(kLoadCommitEventName)) | |
| 368 return; | |
| 369 | |
| 370 EventListeners& listeners = event_listener_map_[kLoadCommitEventName]; | |
| 371 EventListeners::iterator it = listeners.begin(); | |
| 372 | |
| 373 v8::Context::Scope context_scope(v8::Context::New()); | |
|
Charlie Reis
2012/10/08 19:03:39
Note: We've learned that this approach doesn't wor
irobert
2012/10/10 23:55:16
Done.
| |
| 374 v8::HandleScope handle_scope; | |
| 375 // Construct the loadCommit event object. | |
| 376 v8::Local<v8::Value> event = | |
| 377 v8::Local<v8::Object>::New(v8::Object::New()); | |
| 378 v8::Local<v8::Object>::Cast(event)->Set( | |
| 379 v8::String::New(kURL, sizeof(kURL) - 1), | |
| 380 v8::String::New(url.spec().c_str(), url.spec().size())); | |
| 381 v8::Local<v8::Object>::Cast(event)->Set( | |
| 382 v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1), | |
| 383 v8::Boolean::New(is_top_level)); | |
| 384 for (; it != listeners.end(); ++it) { | |
| 385 // Fire the event listener. | |
| 386 container()->element().document().frame()-> | |
| 387 callFunctionEvenIfScriptDisabled(*it, | |
| 388 v8::Object::New(), | |
| 389 1, | |
| 390 &event); | |
| 391 } | |
| 392 } | |
| 393 | |
| 360 void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) { | 394 void BrowserPlugin::LoadStart(const GURL& url, bool is_top_level) { |
| 361 if (!HasListeners(kLoadStartEventName)) | 395 if (!HasListeners(kLoadStartEventName)) |
| 362 return; | 396 return; |
| 363 | 397 |
| 364 EventListeners& listeners = event_listener_map_[kLoadStartEventName]; | 398 EventListeners& listeners = event_listener_map_[kLoadStartEventName]; |
| 365 EventListeners::iterator it = listeners.begin(); | 399 EventListeners::iterator it = listeners.begin(); |
| 366 | 400 |
| 367 v8::Context::Scope context_scope(v8::Context::New()); | 401 v8::Context::Scope context_scope(v8::Context::New()); |
| 368 v8::HandleScope handle_scope; | 402 v8::HandleScope handle_scope; |
| 369 // Construct the loadStart event object. | 403 // Construct the loadStart event object. |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 void* notify_data) { | 762 void* notify_data) { |
| 729 } | 763 } |
| 730 | 764 |
| 731 void BrowserPlugin::didFailLoadingFrameRequest( | 765 void BrowserPlugin::didFailLoadingFrameRequest( |
| 732 const WebKit::WebURL& url, | 766 const WebKit::WebURL& url, |
| 733 void* notify_data, | 767 void* notify_data, |
| 734 const WebKit::WebURLError& error) { | 768 const WebKit::WebURLError& error) { |
| 735 } | 769 } |
| 736 | 770 |
| 737 } // namespace content | 771 } // namespace content |
| OLD | NEW |