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 27 matching lines...) Expand all Loading... |
38 using WebKit::WebRect; | 38 using WebKit::WebRect; |
39 using WebKit::WebURL; | 39 using WebKit::WebURL; |
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 kLoadStartEventName[] = "loadStart"; | 49 const char kLoadStartEventName[] = "loadStart"; |
49 const char kNavigationEventName[] = "navigation"; | 50 const char kNavigationEventName[] = "navigation"; |
| 51 const char kNewURL[] = "newUrl"; |
| 52 const char kOldURL[] = "oldUrl"; |
50 const char kPartitionAttribute[] = "partition"; | 53 const char kPartitionAttribute[] = "partition"; |
51 const char kPersistPrefix[] = "persist:"; | 54 const char kPersistPrefix[] = "persist:"; |
52 const char kSrcAttribute[] = "src"; | 55 const char kSrcAttribute[] = "src"; |
53 const char kType[] = "type"; | 56 const char kType[] = "type"; |
54 const char kURL[] = "url"; | 57 const char kURL[] = "url"; |
55 } | 58 } |
56 | 59 |
57 BrowserPlugin::BrowserPlugin( | 60 BrowserPlugin::BrowserPlugin( |
58 int instance_id, | 61 int instance_id, |
59 RenderViewImpl* render_view, | 62 RenderViewImpl* render_view, |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 for (; it != listeners.end(); ++it) { | 411 for (; it != listeners.end(); ++it) { |
409 // Fire the event listener. | 412 // Fire the event listener. |
410 container()->element().document().frame()-> | 413 container()->element().document().frame()-> |
411 callFunctionEvenIfScriptDisabled(*it, | 414 callFunctionEvenIfScriptDisabled(*it, |
412 v8::Object::New(), | 415 v8::Object::New(), |
413 1, | 416 1, |
414 &event); | 417 &event); |
415 } | 418 } |
416 } | 419 } |
417 | 420 |
| 421 void BrowserPlugin::LoadRedirect(const GURL& old_url, |
| 422 const GURL& new_url, |
| 423 bool is_top_level) { |
| 424 if (!HasListeners(kLoadRedirectEventName)) |
| 425 return; |
| 426 |
| 427 EventListeners& listeners = event_listener_map_[kLoadRedirectEventName]; |
| 428 EventListeners::iterator it = listeners.begin(); |
| 429 |
| 430 v8::Context::Scope context_scope(v8::Context::New()); |
| 431 v8::HandleScope handle_scope; |
| 432 |
| 433 // Construct the loadRedirect event object. |
| 434 v8::Local<v8::Value> event = |
| 435 v8::Local<v8::Object>::New(v8::Object::New()); |
| 436 v8::Local<v8::Object>::Cast(event)->Set( |
| 437 v8::String::New(kOldURL, sizeof(kOldURL) - 1), |
| 438 v8::String::New(old_url.spec().c_str(), old_url.spec().size())); |
| 439 v8::Local<v8::Object>::Cast(event)->Set( |
| 440 v8::String::New(kNewURL, sizeof(kNewURL) - 1), |
| 441 v8::String::New(new_url.spec().c_str(), new_url.spec().size())); |
| 442 v8::Local<v8::Object>::Cast(event)->Set( |
| 443 v8::String::New(kIsTopLevel, sizeof(kIsTopLevel) - 1), |
| 444 v8::Boolean::New(is_top_level)); |
| 445 for (; it != listeners.end(); ++it) { |
| 446 // Fire the event listener. |
| 447 container()->element().document().frame()-> |
| 448 callFunctionEvenIfScriptDisabled(*it, |
| 449 v8::Object::New(), |
| 450 1, |
| 451 &event); |
| 452 } |
| 453 } |
| 454 |
418 void BrowserPlugin::AdvanceFocus(bool reverse) { | 455 void BrowserPlugin::AdvanceFocus(bool reverse) { |
419 // We do not have a RenderView when we are testing. | 456 // We do not have a RenderView when we are testing. |
420 if (render_view_) | 457 if (render_view_) |
421 render_view_->GetWebView()->advanceFocus(reverse); | 458 render_view_->GetWebView()->advanceFocus(reverse); |
422 } | 459 } |
423 | 460 |
424 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 461 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
425 if (container()) | 462 if (container()) |
426 container()->setIsAcceptingTouchEvents(accept); | 463 container()->setIsAcceptingTouchEvents(accept); |
427 } | 464 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 void* notify_data) { | 728 void* notify_data) { |
692 } | 729 } |
693 | 730 |
694 void BrowserPlugin::didFailLoadingFrameRequest( | 731 void BrowserPlugin::didFailLoadingFrameRequest( |
695 const WebKit::WebURL& url, | 732 const WebKit::WebURL& url, |
696 void* notify_data, | 733 void* notify_data, |
697 const WebKit::WebURLError& error) { | 734 const WebKit::WebURLError& error) { |
698 } | 735 } |
699 | 736 |
700 } // namespace content | 737 } // namespace content |
OLD | NEW |