Chromium Code Reviews| Index: content/renderer/browser_plugin/browser_plugin.cc |
| diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc |
| index 712c41a93f060738323e498f6fa612bbd476bcd5..d9b2354c31ffb28173d8a4fa50748211d591de27 100644 |
| --- a/content/renderer/browser_plugin/browser_plugin.cc |
| +++ b/content/renderer/browser_plugin/browser_plugin.cc |
| @@ -43,11 +43,16 @@ namespace content { |
| namespace { |
| const char kCrashEventName[] = "crash"; |
| +const char kLoadRedirectEventName[] = "loadRedirect"; |
| const char kNavigationEventName[] = "navigation"; |
| const char* kPartitionAttribute = "partition"; |
| const char* kPersistPrefix = "persist:"; |
| const char* kSrcAttribute = "src"; |
| +const std::string kNewURL = "newUrl"; |
|
Fady Samuel
2012/10/04 15:15:30
Please make these const char[] to match my loadSta
|
| +const std::string kOldURL = "oldUrl"; |
| +const std::string kIsTopLevel = "isTopLevel"; |
| + |
| } |
| BrowserPlugin::BrowserPlugin( |
| @@ -342,6 +347,39 @@ void BrowserPlugin::DidNavigate(const GURL& url, int process_id) { |
| } |
| } |
| +void BrowserPlugin::LoadRedirect(const GURL& old_url, |
| + const GURL& new_url, |
| + bool is_top_level) { |
| + if (!HasListeners(kLoadRedirectEventName)) |
| + return; |
| + |
| + EventListeners& listeners = event_listener_map_[kLoadRedirectEventName]; |
| + EventListeners::iterator it = listeners.begin(); |
| + |
| + v8::Context::Scope context_scope(v8::Context::New()); |
| + v8::HandleScope handle_scope; |
| + // Construct the loadRedirect event object. |
| + v8::Local<v8::Value> event = |
| + v8::Local<v8::Object>::New(v8::Object::New()); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kOldURL.c_str(), kOldURL.size()), |
|
Fady Samuel
2012/10/04 15:15:30
Please use char[] instead of string to match my pa
Charlie Reis
2012/10/04 19:05:58
Done.
|
| + v8::String::New(old_url.spec().c_str(), old_url.spec().size())); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kNewURL.c_str(), kNewURL.size()), |
| + v8::String::New(new_url.spec().c_str(), new_url.spec().size())); |
| + v8::Local<v8::Object>::Cast(event)->Set( |
| + v8::String::New(kIsTopLevel.c_str(), kIsTopLevel.size()), |
| + v8::Boolean::New(is_top_level)); |
| + for (; it != listeners.end(); ++it) { |
| + // Fire the event listener. |
| + container()->element().document().frame()-> |
| + callFunctionEvenIfScriptDisabled(*it, |
| + v8::Object::New(), |
| + 1, |
| + &event); |
| + } |
| +} |
| + |
| void BrowserPlugin::AdvanceFocus(bool reverse) { |
| // We do not have a RenderView when we are testing. |
| if (render_view_) |