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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 : instance_id_(instance_id), | 65 : instance_id_(instance_id), |
| 66 render_view_(render_view), | 66 render_view_(render_view), |
| 67 container_(NULL), | 67 container_(NULL), |
| 68 damage_buffer_(NULL), | 68 damage_buffer_(NULL), |
| 69 sad_guest_(NULL), | 69 sad_guest_(NULL), |
| 70 guest_crashed_(false), | 70 guest_crashed_(false), |
| 71 resize_pending_(false), | 71 resize_pending_(false), |
| 72 navigate_src_sent_(false), | 72 navigate_src_sent_(false), |
| 73 process_id_(-1), | 73 process_id_(-1), |
| 74 persist_storage_(false), | 74 persist_storage_(false), |
| 75 guest_routing_id_(MSG_ROUTING_NONE), | |
| 75 visible_(true) { | 76 visible_(true) { |
| 76 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); | 77 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
| 77 bindings_.reset(new BrowserPluginBindings(this)); | 78 bindings_.reset(new BrowserPluginBindings(this)); |
| 78 | 79 |
| 79 ParseAttributes(params); | 80 ParseAttributes(params); |
| 80 } | 81 } |
| 81 | 82 |
| 82 BrowserPlugin::~BrowserPlugin() { | 83 BrowserPlugin::~BrowserPlugin() { |
| 83 if (damage_buffer_) | 84 if (damage_buffer_) |
| 84 FreeDamageBuffer(); | 85 FreeDamageBuffer(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // guest's |src| to empty value, resize and then set the |src| to a | 134 // guest's |src| to empty value, resize and then set the |src| to a |
| 134 // non-empty value). | 135 // non-empty value). |
| 135 // Additionally, once this instance has navigated, the storage partition | 136 // Additionally, once this instance has navigated, the storage partition |
| 136 // cannot be changed, so this value is used for enforcing this. | 137 // cannot be changed, so this value is used for enforcing this. |
| 137 navigate_src_sent_ = true; | 138 navigate_src_sent_ = true; |
| 138 } | 139 } |
| 139 src_ = src; | 140 src_ = src; |
| 140 guest_crashed_ = false; | 141 guest_crashed_ = false; |
| 141 } | 142 } |
| 142 | 143 |
| 144 NPObject* BrowserPlugin::GetContentWindow() const { | |
| 145 if (guest_routing_id_ == MSG_ROUTING_NONE) | |
| 146 return NULL; | |
| 147 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( | |
| 148 ChildThread::current()->ResolveRoute(guest_routing_id_)); | |
|
Charlie Reis
2012/10/12 00:31:43
nit: wrong indent.
Fady Samuel
2012/10/12 18:07:53
Done.
| |
| 149 if (!guest_render_view) | |
| 150 return NULL; | |
| 151 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | |
| 152 return guest_frame->windowObject(); | |
|
Charlie Reis
2012/10/12 00:31:43
This is beyond my knowledge. Is it safe to return
Fady Samuel
2012/10/12 18:07:53
I will ask abarth@ to at a look at BrowserPlugin::
| |
| 153 } | |
| 154 | |
| 143 std::string BrowserPlugin::GetPartitionAttribute() const { | 155 std::string BrowserPlugin::GetPartitionAttribute() const { |
| 144 std::string value; | 156 std::string value; |
| 145 if (persist_storage_) | 157 if (persist_storage_) |
| 146 value.append(kPersistPrefix); | 158 value.append(kPersistPrefix); |
| 147 | 159 |
| 148 value.append(storage_partition_id_); | 160 value.append(storage_partition_id_); |
| 149 return value; | 161 return value; |
| 150 } | 162 } |
| 151 | 163 |
| 152 bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id, | 164 bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val); | 474 frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val); |
| 463 } | 475 } |
| 464 } | 476 } |
| 465 | 477 |
| 466 void BrowserPlugin::AdvanceFocus(bool reverse) { | 478 void BrowserPlugin::AdvanceFocus(bool reverse) { |
| 467 // We do not have a RenderView when we are testing. | 479 // We do not have a RenderView when we are testing. |
| 468 if (render_view_) | 480 if (render_view_) |
| 469 render_view_->GetWebView()->advanceFocus(reverse); | 481 render_view_->GetWebView()->advanceFocus(reverse); |
| 470 } | 482 } |
| 471 | 483 |
| 484 void BrowserPlugin::GuestContentWindowReady(int guest_routing_id) { | |
| 485 DCHECK(guest_routing_id != MSG_ROUTING_NONE); | |
| 486 guest_routing_id_ = guest_routing_id; | |
| 487 } | |
| 488 | |
| 472 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 489 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
| 473 if (container()) | 490 if (container()) |
| 474 container()->setIsAcceptingTouchEvents(accept); | 491 container()->setIsAcceptingTouchEvents(accept); |
| 475 } | 492 } |
| 476 | 493 |
| 477 bool BrowserPlugin::HasListeners(const std::string& event_name) { | 494 bool BrowserPlugin::HasListeners(const std::string& event_name) { |
| 478 return event_listener_map_.find(event_name) != event_listener_map_.end(); | 495 return event_listener_map_.find(event_name) != event_listener_map_.end(); |
| 479 } | 496 } |
| 480 | 497 |
| 481 bool BrowserPlugin::AddEventListener(const std::string& event_name, | 498 bool BrowserPlugin::AddEventListener(const std::string& event_name, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 void* notify_data) { | 767 void* notify_data) { |
| 751 } | 768 } |
| 752 | 769 |
| 753 void BrowserPlugin::didFailLoadingFrameRequest( | 770 void BrowserPlugin::didFailLoadingFrameRequest( |
| 754 const WebKit::WebURL& url, | 771 const WebKit::WebURL& url, |
| 755 void* notify_data, | 772 void* notify_data, |
| 756 const WebKit::WebURLError& error) { | 773 const WebKit::WebURLError& error) { |
| 757 } | 774 } |
| 758 | 775 |
| 759 } // namespace content | 776 } // namespace content |
| OLD | NEW |