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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 kNavigationEventName[] = "navigation"; | 50 const char kNavigationEventName[] = "navigation"; |
| 51 const char kNewURL[] = "newUrl"; | 51 const char kNewURL[] = "newUrl"; |
| 52 const char kOldURL[] = "oldUrl"; | 52 const char kOldURL[] = "oldUrl"; |
| 53 const char kPartitionAttribute[] = "partition"; | 53 const char kPartitionAttribute[] = "partition"; |
| 54 const char kPersistPrefix[] = "persist:"; | 54 const char kPersistPrefix[] = "persist:"; |
| 55 const char kSrcAttribute[] = "src"; | 55 const char kSrcAttribute[] = "src"; |
| 56 const char kTitle[] = "title"; | |
| 57 const char kTitleChangedEventName[] = "titleChanged"; | |
| 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( |
| 61 int instance_id, | 63 int instance_id, |
| 62 RenderViewImpl* render_view, | 64 RenderViewImpl* render_view, |
| 63 WebKit::WebFrame* frame, | 65 WebKit::WebFrame* frame, |
| 64 const WebPluginParams& params) | 66 const WebPluginParams& params) |
| 65 : instance_id_(instance_id), | 67 : instance_id_(instance_id), |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 for (; it != listeners.end(); ++it) { | 447 for (; it != listeners.end(); ++it) { |
| 446 // Fire the event listener. | 448 // Fire the event listener. |
| 447 container()->element().document().frame()-> | 449 container()->element().document().frame()-> |
| 448 callFunctionEvenIfScriptDisabled(*it, | 450 callFunctionEvenIfScriptDisabled(*it, |
| 449 v8::Object::New(), | 451 v8::Object::New(), |
| 450 1, | 452 1, |
| 451 &event); | 453 &event); |
| 452 } | 454 } |
| 453 } | 455 } |
| 454 | 456 |
| 457 void BrowserPlugin::TitleChanged(const string16& title) { | |
| 458 if (!HasListeners(kTitleChangedEventName)) | |
| 459 return; | |
| 460 | |
| 461 EventListeners& listeners = event_listener_map_[kTitleChangedEventName]; | |
| 462 EventListeners::iterator it = listeners.begin(); | |
| 463 | |
| 464 v8::Context::Scope context_scope(v8::Context::New()); | |
| 465 v8::HandleScope handle_scope; | |
| 466 | |
| 467 // Construct the loadRedirect event object. | |
|
Fady Samuel
2012/10/05 17:45:52
Please update this comment :-)
Charlie Reis
2012/10/05 19:20:48
Good copy/paste catch. :) Done.
| |
| 468 v8::Local<v8::Value> event = | |
| 469 v8::Local<v8::Object>::New(v8::Object::New()); | |
| 470 v8::Local<v8::Object>::Cast(event)->Set( | |
| 471 v8::String::New(kTitle, sizeof(kTitle) - 1), | |
| 472 v8::String::New(title.c_str(), title.size())); | |
| 473 for (; it != listeners.end(); ++it) { | |
| 474 // Fire the event listener. | |
| 475 container()->element().document().frame()-> | |
| 476 callFunctionEvenIfScriptDisabled(*it, | |
| 477 v8::Object::New(), | |
| 478 1, | |
| 479 &event); | |
| 480 } | |
| 481 } | |
| 482 | |
| 455 void BrowserPlugin::AdvanceFocus(bool reverse) { | 483 void BrowserPlugin::AdvanceFocus(bool reverse) { |
| 456 // We do not have a RenderView when we are testing. | 484 // We do not have a RenderView when we are testing. |
| 457 if (render_view_) | 485 if (render_view_) |
| 458 render_view_->GetWebView()->advanceFocus(reverse); | 486 render_view_->GetWebView()->advanceFocus(reverse); |
| 459 } | 487 } |
| 460 | 488 |
| 461 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 489 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
| 462 if (container()) | 490 if (container()) |
| 463 container()->setIsAcceptingTouchEvents(accept); | 491 container()->setIsAcceptingTouchEvents(accept); |
| 464 } | 492 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 void* notify_data) { | 756 void* notify_data) { |
| 729 } | 757 } |
| 730 | 758 |
| 731 void BrowserPlugin::didFailLoadingFrameRequest( | 759 void BrowserPlugin::didFailLoadingFrameRequest( |
| 732 const WebKit::WebURL& url, | 760 const WebKit::WebURL& url, |
| 733 void* notify_data, | 761 void* notify_data, |
| 734 const WebKit::WebURLError& error) { | 762 const WebKit::WebURLError& error) { |
| 735 } | 763 } |
| 736 | 764 |
| 737 } // namespace content | 765 } // namespace content |
| OLD | NEW |